Langton's ant: Difference between revisions
→But, if one remembers complex numbers: A variation to distinguish the unsullied from the cleaned.
(→{{header|Fortran}}: This can be rather more compact, and older-style statements suffice.) |
(→But, if one remembers complex numbers: A variation to distinguish the unsullied from the cleaned.) |
||
Line 2,500:
EXIT !And wander no further.
END IF !But, if we're within bounds,
IF (CELL(X,Y).
CELL(X,Y) = "#" !A blank cell becomes black. Ish.
WAY = WAY*(0,-1) !Turn right.
ELSE !Otherwise,
CELL(X,Y) = "
WAY = WAY*(0,+1) !Turn left.
END IF !So much for changing direction.
Line 2,524:
</lang>
Output is the same, except for orientation. Here I have stuck to (x,y) Cartesian orientation rather than lines (y) increasing downwards. Just for fun, + signs mark cells that have been trampled and then cleaned. But not to pure white... Notice that some interior cells have never been trampled.
{{out}} (Cropped to save space)
<pre style="height:60ex;overflow:scroll">
Step 11669 to (26,101) is out of bounds!
#
## #
#
####
#####
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
###
#
#### ###
#
###
###
#
#
#
###
##
#
#
#
#
#
####
#
###
#
#
##
##
####
#
#
###
#
#
####
##
#
###
#
##
#
##
#
#
#
##+
##
</pre>
|