This is Markov. Markov's golf ball rolls around randomly. Markov's ball will hole however he strikes it. Markov is smart. Be like Markov.
Take an input of a 10x20 field:
,Anthill turns 90 degrees clockwise
.Anthill turns 90 degrees counterclockwise
0MarGolf in Langton's Anthill
A field looks like this:
,...,.,,..,...,.,,.. ..,.,,,..,...,..,.,. .,,*.,....,.,,,.,,,. ,.,,.,...,,.,.,,,,,. .,..,....,,.....,,., ,.,.,...,..,.,,,,.., ....,,,,,,,,,....... ........,,.,...,..., ,,,,,,,,,,,,....,O., ,.,.,.,.....,,.,,,,,
The configuration of the input field is called tick 0. Your program needs to evaluate and print out the configuration of the next tick, in which both MarGolf and Langton's Anthill will move to another cell. The the item in the current cell will become the item currently in the target cell. If both MarGolf and the anthill move to the same cell in the next tick, the game ends.
- MarGolf moves randomly. All nine cells in the 3x3 area around MarGolf has equal chance of being selected. This becomes a choice among 6 cells at an edge of the field, and 4 cells at a corner.
- Langton's Anthill needs to remember its movement direction of either up, down, left, or right (NSEW or whatever equivalent). It moves one cell in its direction each tick, and the original content of the cell changes its direction clockwise or anti-clockwise, as specified above. Initial direction at tick 0 is random, each direction has an equal chance of being the initial.
- The program needs to print the configuration of each tick, until the game ends.
- The tick number precedes the field configuration of each tick.
- You may assume the input is always valid.
- The shortest program is bytes wins.
Update: forgot to mention anthill reverses direction before moving if it would otherwise go off the field. Credit to user81655 for reminding.