Langton's ant: Difference between revisions
→{{header|Ada}}: Fix chirality - test before toggle.
(→{{header|Run BASIC}}: replace graphical output image to fix chirality there, too.) |
(→{{header|Ada}}: Fix chirality - test before toggle.) |
||
Line 12:
=={{header|Ada}}==
<lang Ada>with Ada.Text_IO;
Line 48 ⟶ 47:
begin
loop -- iterate the loop until an exception is raised
Is_Black(Ant_X, Ant_Y) := not Is_Black(Ant_X, Ant_Y);▼
if Is_Black(Ant_X, Ant_Y) then
Left(Ant_North, Ant_West);
Line 54 ⟶ 52:
Right(Ant_North, Ant_West);
end if;
▲ Is_Black(Ant_X, Ant_Y) := not Is_Black(Ant_X, Ant_Y);
Ant_X := Ant_X - Ant_North; -- this may raise an exception
Ant_Y := Ant_Y - Ant_West; -- this may raise an exception
Line 71 ⟶ 70:
</lang>
Ouptut (to save space, I have removed the all-blank lines):[[File:Ada_Langton.png|right|thumb|Output png]]
<pre style="height:30ex;overflow:scroll"> ## ############ ##
# ### #
# ### # # # # #### # #####
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
# ### # #
### # ##
## # #
## # ##
# # # #
#### ##
# ## #
####
##
# Iteration:
</pre>
|