COD

COD is a two-dimensional esolang by User:PythonshellDebugwindow where cod are the instruction pointers. It has nothing to do with Deadfish.
==Overview==
Programs in COD are two-dimensional. They are made up of "ponds", which must be fully enclosed by waves (excluding the ... and --- commands). Instruction pointers ("cods") move around ("swim") in the ponds, guided by "waves", which the cods can't move through. If a cod encounters a branch in its pond, so that it can go in multiple different ways, it will choose a random valid (unblocked) direction. If a cod reaches a dead end, it will turn around; if it's completely blocked in, the program will loop forever as a result. Programs can have multiple individual ponds in them, but each one must have access to either the left, right, or both sides of the program.
==Syntax==
The most basic ponds are made only of waves (~ tilde characters) and water (spaces), like this one, which is basically just a rectangle:
<nowiki>
~~~
~ ~
~~~
</nowiki>
Cods can move freely through everything but waves and other cods, meaning the commands don't affect cods' motion (except for _).
> represents a cod. Without any cods, a program will instantly terminate (and if at any time during execution a program has no cods, it will terminate). For example, the aforementioned rectangle has no cods and would terminate instantly. This program, however, would loop forever, as its cod will stay there forever):
<nowiki>
~~~
~>~
~~~
</nowiki>
==Cod values==
Each cod has a value, an unbounded signed integer that starts at zero.
==Commands==
Where "the cod" is any cod that passes over a command:
Command	Meaning
+ 	Duplicate the cod (if there are two branches, one of them will continue and one of them will go back; if there are three branches, they will each go different forward branches; more, then they will each go different, but otherwise random, ways)
- 	Remove the cod
) 	Increment the cod's value
( 	Decrement the cod's value
< 	Remove the cod if its value is equal to zero
_ 	If the cod is going up when it hits this command, then send it back down if its value is nonzero; otherwise, do nothing
===Edge commands===
The --- (three dashes) command (output the cod's value, then remove the cod) must be touching either the left or right side of the program, without any waves or other characters in between, otherwise it will count as three - commands. This command is executed when a cod encounters one of the side dashes on this command. This command must go left-to-right, e.g. the dashes must all be right beside each other.
Similarly, the ... (three periods) command (input a number to the cod's value from STDIN) must be touching either the top or bottom edge of the program, without any waves or other characters in between, otherwise it will be completely ignored. This command is executed when a cod encounters any of the periods in this command. This command must go top-to-bottom, e.g. the periods must all be right on top of another.
==Examples==
===Infinite loop===
Basic one:
<nowiki>
~~~
~>~
~~~
</nowiki>
More advanced one:
<nowiki>
~~~~~
~> ~
~ ~ ~
~ ~
~~~~~
</nowiki>
===Infinite numeric cat===
<nowiki>
 ~.~
~~.~~~~
~>.+---
~ ~ ~~~
~ ~
~~~~~
</nowiki>
===Truth-machine===
<nowiki>
 ~.~
~~.~~~~
~>.+---
~~~<~~~
 ~_~~~
 ~+---
 ~ ~~~
 ~~~
</nowiki>
===Raise an error (takes 3 inputs first)===
<nowiki>
 ~.~
 ~.~
~~.~
~> ~
~~~~
</nowiki>
This program raises an error, since the cod turns to the left and then goes up through the input command and into nothing.
Category:Languages Category:2020 Category:Unknown computational class Category:Two-dimensional languages Category:Nondeterministic Category:Concurrent programming Category:Unimplemented