Langton’s Ant
An ant is sitting on an infinite grid of white and black squares. It initially faces right. At each step, it does the following :-
- At a white square,
- flip the color of the square,
- turn 90 degree right (clockwise) and
- move forward one unit
- At a black square,
- flip the color the square,
- turn 90 degree left (counter-clockwise) and
- move forward one unit
Implement simulator for first K moves that the ant makes and print the final board as a grid.
Note: – You are not provided data structure to represent the grid.
Latest Source Code:
Github: LangtonsAnt.java
Output:
XX__ XXX_ ←_X_ ____ Ant :←.