9
1
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.
And this:
is an anthill in Langton's backyard.
The anthill is big enough to hold Markov's golfball, MarGolf. However, the anthill moves and changes direction depending on the surrounding terrain.
The Task
Take an input of a 10x20 field:
*
MarGolfO
Lanton's Anthill,
Anthill turns 90 degrees clockwise.
Anthill turns 90 degrees counterclockwise0
MarGolf in Langton's Anthill
A field looks like this:
,...,.,,..,...,.,,..
..,.,,,..,...,..,.,.
.,,*.,....,.,,,.,,,.
,.,,.,...,,.,.,,,,,.
.,..,....,,.....,,.,
,.,.,...,..,.,,,,..,
....,,,,,,,,,.......
........,,.,...,...,
,,,,,,,,,,,,....,O.,
,.,.,.,.....,,.,,,,,
Game rules:
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.
Movement rules:
- 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.
Notes
- 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.
Could anyone point where the "be like <insert name here> meme originated? – proud haskeller – 2016-01-22T08:40:59.967
@proudhaskeller I guess from the Be Like Bill facebook page, there's an article on Wikipedia you might want to read. https://en.wikipedia.org/wiki/Be_like_Bill
– busukxuan – 2016-01-22T09:09:02.970@proudhaskeller http://knowyourmeme.com/memes/be-like-bill-se-como-jose
– Martin Ender – 2016-01-22T09:58:37.760How do we know whether the tile "under" the
*
and theO
is a,
or a.
? – Doorknob – 2016-01-22T12:35:04.0902@Doorknob If I understand the challenge correctly, there is no tile under them. When you move one of them it swaps with the tile they move onto, and that tile determines the
O
s direction for the next step. – Martin Ender – 2016-01-22T12:44:06.9871@MartinButtner yes that is mostly correct. I avoided the term "swap" for one corner case, but the term is otherwise truthy. – busukxuan – 2016-01-22T12:49:18.403
Shouldn't the sentence "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." be "All eight cells in the 3x3 area around MarGolf has equal chance of being selected. This becomes a choice among 4 cells at an edge of the field, and 4 cells at a corner." instead? Or is it possible for MarGolf to stay at its current position? – Kevin Cruijssen – 2018-03-07T11:02:12.240
"If both MarGolf and the anthill move to the same cell in the next tick, the game ends." So the final tick is the tick before MarGolf ends up in the anthill? If so, why is "
0
MarGolf in Langton's Anthill" specified? And if we indeed need to print the final tick as well with0
being MarGolf in Langton's Anthill, what character need to be placed at the swap (since we swap.
/,
with*
, and then*
withO
(transformingO
into0
), but which character does the*
become? – Kevin Cruijssen – 2018-03-07T13:15:11.727