Langton's ant: Difference between revisions
Content added Content deleted
(→{{header|Run BASIC}}: replace graphical output image to fix chirality there, too.) |
(→{{header|Ada}}: Fix chirality - test before toggle.) |
||
Line 12: | Line 12: | ||
=={{header|Ada}}== |
=={{header|Ada}}== |
||
{{incorrect|Ada|The chirality of the output is reversed, meaning the ant is turning left when the spec says it should turn right, and vice-versa.}} |
|||
<lang Ada>with Ada.Text_IO; |
<lang Ada>with Ada.Text_IO; |
||
Line 48: | Line 47: | ||
begin |
begin |
||
loop -- iterate the loop until an exception is raised |
loop -- iterate the loop until an exception is raised |
||
⚫ | |||
if Is_Black(Ant_X, Ant_Y) then |
if Is_Black(Ant_X, Ant_Y) then |
||
Left(Ant_North, Ant_West); |
Left(Ant_North, Ant_West); |
||
Line 54: | Line 52: | ||
Right(Ant_North, Ant_West); |
Right(Ant_North, Ant_West); |
||
end if; |
end if; |
||
⚫ | |||
Ant_X := Ant_X - Ant_North; -- this may raise an exception |
Ant_X := Ant_X - Ant_North; -- this may raise an exception |
||
Ant_Y := Ant_Y - Ant_West; -- this may raise an exception |
Ant_Y := Ant_Y - Ant_West; -- this may raise an exception |
||
Line 71: | Line 70: | ||
</lang> |
</lang> |
||
Ouptut (to save space, I have removed the all-blank lines):[[File:Ada_Langton.png|right|thumb|Output png]] |
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"> ## ############ ## |
<pre style="height:30ex;overflow:scroll"> ## ############ ## |
||
# #### # ## |
|||
### ## ## # |
|||
# # # # # # |
|||
## ## # # ### # |
|||
### # # # # ## ## ### |
|||
# # ### ## #### ## # # # ## ## |
|||
# ### ## # ## ### # # ### ### |
|||
# # ##### # # #### # ### # # # |
|||
### ## # #### ## ## ###### # ### # # |
|||
# ### # ## # # ## ## ## # ##### ### ## |
|||
# # # ## ### # # # #### # ## |
|||
# # ## ## # ## ## # ## |
|||
### # # ## ### # ## # ### ## ## # |
|||
# ### ## ## ## ### # # ## #### # |
|||
### # # # # # #### ## # ## ### # # |
|||
# ### # ## # # ### # ### ## # # ## |
|||
### # # ## # ## ## ##### #### #### ## # |
|||
# ### # # # # ### # # ## ## # # # # # |
|||
### # ## ### ## # ## #### #### # # |
|||
# # |
# ### # # # ## ########### # #### # # # |
||
### # ## # #### ## ######### # ## # ## |
|||
# ### # # ## # ## ## ## ### ### # # ## #### # |
|||
### # ## # # ###### ## # ## # # ### ### ## # |
|||
# ### # # # ##### # ##### # # ## # ## # |
|||
### # ## # # ## ##### ## # # # # ## # # # |
|||
## ########## |
# ### # # # # #### # ##### ## ########## ## |
||
### # ## # ## ## # # #### # ## #### ## |
|||
# ### # # ##### # ## ## # # # # # # # # |
|||
### # ## ## ## # # # ## ## # # ## # ## ## |
|||
# ### # # # # # ######## # # ## #### # |
|||
### # ## # # # ## ## # # ## # |
|||
# ### # # # # # # ## ## ## #### |
|||
### # ## ## # ## ## # # ### |
|||
# ### # # # ## #### #### ### #### |
|||
### # ## ## #### ## # ## # # # |
|||
# ### # # ## ## ## ### ## ##### |
|||
### # ## # ## # #### |
|||
# ### # # ## ## ## |
|||
### # ## ## |
|||
# ### # # # ## #### # |
|||
### # ## # # ### ### |
|||
# ### # # # ## # # # |
|||
### # ## ## ## |
|||
## # # ## |
|||
## # ## |
|||
# # # # |
|||
#### ## |
|||
# ## # |
|||
#### |
|||
## |
|||
# Iteration: |
# Iteration: 11656 |
||
</pre> |
</pre> |
||