Skip to content

asubit/javascript-langton-ant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Langton's ant with JavaScipt

Description

I have created a small JavaScript script that reproduces the rules of the Langton ant.
Just to check out for myself the reason for the "highway" pattern. And it happens well from about 11000 movements.
Still as mysterious and astonishing! ...

Based on this video of "ScienceEtonnante" YouTube channel.

Rules

Squares on a plane are colored variously either black or white.We arbitrarily identify one square as the "ant". The ant can travel in any of the four cardinal directions at each step it takes. The "ant" moves according to the rules below:

At a white square, turn 90° right, flip the color of the square, move forward one unit At a black square, turn 90° left, flip the color of the square, move forward one unit Langton's ant can also be described as a cellular automaton, where the grid is colored black or white and the “ant” square has one of eight different colors assigned to encode the combination of black/white state and the current direction of motion of the ant.

Screenshot

alt tag

This is an example with 472 movements

Here the link to the online demo.

Input parameters

  • Ant's movements (iteration number)
  • Speed per iteration (millisecond)
  • Grid size X (boxes number)
  • Grid size Y (boxes number)

About

The game of life "Langton's ant" create with JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published