Fishing

Fishing is a two dimensional esoteric programming language created by User:OriginalOldMan in 2013. Programs are controlled by a fisherman who walks along a dock, casts, and catches different fish. Commands can be given through the dock that the fisherman walks on and through the fish that the fisherman catches. Fishing's memory is in the form of a tape like BF's memory tape.
==Basics== 
The fisherman starts at the top left corner of the program and begins to move to the right through the program. If at any point the fisherman encounters a character that is not a valid piece of dock, the program ends.
Dock Piece 	Effect
D 	Does nothing. The fisherman will continue to move in his current direction.
C 	Makes the fisherman cast his line in the current direction with the current cast length.
Increases the fisherman's casting length by one character. 
The casting length is automatically 0 at the start of the program.	
Decreases the fisherman's casting length by one character.	
[ 	Causes the fisherman to start moving right.
] 	Causes the fisherman to start moving left.
_ 	Causes the fisherman to start moving downwards.
 	Causes the fisherman to start moving upwards.
v 	Changes the fisherman's casting direction to downwards.
^ 	Changes the fisherman's casting direction to upwards.
< 	Changes the fisherman's casting direction to leftwards.
> 	Changes the fisherman's casting direction to rightwards.
? 	An if statement. If the current cell on the tape is equal to the cell on the right of the current cell,
then the fisherman begins to move in the direction of the = that should be placed next to the ?.
Otherwise the fisherman will begin to move in the direction of the !.
==Fish==
When the fisherman casts, the character at the position of his cast will be considered the fish that he catches. The position of the cast is determined by the cast direction and the length of the cast. The fish will be interpreted depending on what character it is. When a fisherman catches a fish, that fish is not removed from the program.
Fish	Effect
` 	Enters/Exits textmode. Any fish caught while in textmode will be added to the current cell on the tape.
P 	Prints the value of the current cell on the tape.
N 	Prints the value of the current cell on the tape with a newline after it.
n 	Converts the current cell to a number (a floating decimal).
I 	Takes the user input and sets the current cell equal to it. User input is by default a string.
{ 	Moves to the cell to the right of the current cell on the tape.
==Programs==
===Hello, World!===
 v+CCCCCCCCCCCCCCCC
 `Hello, World!`N
===Truth Machine===
v+CCCCCC?=[C]
 `1`{I}! P
 [CC
 {N
===Cat Program===
v+CC
 IN
===Deadfish Interpreter===
Interprets one command per line.
v+CC[vCCCCCCCC?!CCCCCCCCCC?!CCCCCCCCCCCCCCCCC?!CCCCCC?!CCCCCC?!CCCCCC?!CCCCCCD_
 n{D E`-1`n} = {E`256`n} = { E`>>`PEI{E`i`}= {E`d`}= {E`s`}= {E`o`}= {{N}} D
 D _DDDDDDDDDDD] D D D D D 
 D < D D D D D
 D D < < < < D
 D EC }C }C }C }C D
 D `C iC dC SC NC D
 D 0C {C {C {C {C D
 D `C D D D D D
 D nC D D D D D
 D {C D D D D D 
 |DDDDDDDDD]DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD]DDDDDDD]DDDDDDD]DDDDDDD]DDDDDDDD]
==Interpreter==
Written in ruby.
$pcx = 0
$pcy = 0
$castlen = 0
$stack = [""]
$dir = 0
$movdir = 0
$textmode = false
$cell = 0
def run(program)
e = false
while !e
if program[$pcy][$pcx] == "v"
$dir = 3
elsif program[$pcy][$pcx] == "_"
$movdir = 3
elsif program[$pcy][$pcx] == "|"
$movdir = 1
elsif program[$pcy][$pcx] == "["
$movdir = 0
elsif program[$pcy][$pcx] == "]"
$movdir = 2
elsif program[$pcy][$pcx] == "?"
if $stack[$cell] == $stack[$cell+1]
if program[$pcy-1][$pcx] == "="
$movdir = 1
elsif program[$pcy][$pcx+1] == "="
$movdir = 0
elsif program[$pcy][$pcx-1] == "="
$movdir = 2
elsif program[$pcy+1][$pcx] == "="
$movdir = 3
end
else
if program[$pcy][$pcx+1] == "!"
$movdir = 0
elsif program[$pcy][$pcx-1] == "!"
$movdir = 2
elsif program[$pcy+1][$pcx] == "!"
$movdir = 3
elsif program[$pcy-1][$pcx] == "!"
$movdir = 1
end
end
elsif program[$pcy][$pcx] == "^"
$dir = 1
elsif program[$pcy][$pcx] == ">"
$dir = 0
elsif program[$pcy][$pcx] == "<"
$dir = 2
elsif program[$pcy][$pcx] == "+"
$castlen+=1
elsif program[$pcy][$pcx] == "-"
$castlen -= 1
elsif program[$pcy][$pcx] == "C"
if $textmode == true
if $dir == 0
if program[$pcy][$pcx+$castlen] == "`"
$textmode = false
else
$stack[$cell] += program[$pcy][$pcx+$castlen]
end
elsif $dir == 1
if program[$pcy-$castlen][$pcx] == "`"
$textmode = false
else
$stack[$cell] += program[$pcy-$castlen][$pcx]
end
elsif $dir == 2 
if program[$pcy][$pcx-$castlen] == "`"
$textmode = false
else
$stack[$cell] += program[$pcy][$pcx-$castlen]
end
elsif $dir == 3
if program[$pcy+$castlen][$pcx] == "`"
$textmode = false
else
$stack[$cell] += program[$pcy+$castlen][$pcx]
end
end
else
x = ""
if $dir == 0 
x = program[$pcy][$pcx+$castlen]
elsif $dir == 1 
x = program[$pcy-$castlen][$pcx]
elsif $dir == 2 
x = program[$pcy][$pcx-$castlen]
elsif $dir == 3 
x = program[$pcy+$castlen][$pcx]
end
if x == "P"
print $stack[$cell]
elsif x == "c"
$stack << $stack[$cell].to_s + $stack[$cell+1].to_s
elsif x == "s"
n = $stack[$cell].to_s.split(//)
lcount = 0
while lcount < n.count
$stack << n[lcount]
lcount+=1
end
elsif x == "l"
$stack << $stack.count
elsif x == "N"
puts $stack[$cell]
elsif x == "`"
$textmode = true
elsif x == "E"
$stack[$cell] = ""
elsif x == "r"
$stack[$cell] = $stack[$cell].reverse
elsif x == "f"
$stack[$cell] = -$stack[$cell]
elsif x == "n"
$stack[$cell] = $stack[$cell].to_f
elsif x == "i"
$stack[$cell]+=1
elsif x == "d"
$stack[$cell]-=1
elsif x == "I"
$stack[$cell] = gets.delete("\n")
elsif x == "S"
$stack[$cell] = $stack[$cell]*$stack[$cell]
elsif x == "p"
$stack[$cell] = $stack[$cell]**$stack[$cell+1]
elsif x == "a"
$stack[$cell]+=$stack[$cell+1]
elsif x == "s"
$stack[$cell]-=$stack[$cell+1]
elsif x == "m"
$stack[$cell]*=$stack[$cell+1]
elsif x == "D"
$stack[$cell]/=$stack[$cell+1]
elsif x == "{"
$cell+=1
if $stack[$cell] == nil
$stack[$cell] = ""
end
elsif x == "}"
$cell-=1
if $stack[$cell] == nil
$stack[$cell] = ""
end
end
end
elsif program[$pcy][$pcx] == "D" 
elsif program[$pcy][$pcx] == "="
elsif program[$pcy][$pcx] == "!"
else
puts "Ended at #{$pcy},#{$pcx}" #for debugging
abort
end
if $movdir == 0
$pcx+=1
elsif $movdir == 1
$pcy-=1
elsif $movdir == 2
$pcx-=1
elsif $movdir == 3
$pcy+=1
end
if $pcy >= program.count 
e = true
end
end
end
run(File.open(gets.delete("\n"),"r").read.split("\n"))
puts "Ended at #{$pcy},#{$pcx}" #for debugging
Category:LanguagesCategory:Cell-basedCategory:two-dimensional languagesCategory:ThematicCategory:2013Category:Implemented