AoCG2021 Day 17: Langton's Hexa-VirusAoCG2021 Day 17: Langton's Hexa-Virus
code-golf hexagonal-grid sequence
The story continues from AoC2017 Day 22, Part 2.
The damn virus that was infecting a grid computing cluster now has jumped to a hexagonal computing cluster! In this cluster, the computers are connected in the honeycomb-like shape, and each computer has three neighbors.
.. .. ..
. .. .. .
.. .. ..
. .. .. .
.. .x ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
Initially, the cluster is completely clean, and the virus is at x
, facing east. At each tick, the virus moves in the following manner:
- If the current computer is clean, infect it, turn left (60 degrees), and move forward once (move to the neighboring computer in that direction).
- Otherwise (the current computer is infected), clean it, turn right, and move forward once.
Some initial iterations look like this (generated using this program; .
is clean, *
is infected, x
is the virus at a clean computer, and X
is the virus at an infected one):
.. .. ..
. .. .. .
.. .. ..
. .. .. .
.. .x ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. .. ..
. .. x. .
.. .* ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. .x ..
. .. *. .
.. .* ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. x* ..
. .. *. .
.. .* ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .x *. .
.. .* ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *. .
.. x* ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *. .
.. *X ..
. .. .. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *. .
.. *. ..
. .. x. .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *. .
.. *. ..
. .. *x .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *. .
.. *. x.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* *x .
.. *. *.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. ** ..
. .* X* .
.. *. *.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. .. .
.. *X ..
. .* .* .
.. *. *.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
.. .. ..
. .. x. .
.. *. ..
. .* .* .
.. *. *.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
.. .x ..
. .. *. .
.. *. ..
. .* .* .
.. *. *.
. .. ** .
.. .. ..
. .. .. .
.. .. ..
A better visualization can be seen here (pdf).
The number of infected computers at each iteration is A269757:
0, 1, 2, 3, 4, 5, 6, 5, 6, 7,
8, 9, 8, 7, 8, 9, 10, 11, 10, 9,
10, 11, 12, 13, 12, 13, 14, 15, 16, 17,
18, 17, 16, 17, 18, 19, 20, 19, 18, 19,
20, 21, 22, 21, 20, 19, 18, 19, 20, 21,
22, 21, 20, 21, 22, 23, 24, 23, 22, 21,
20, 21, 22, 23, 24, 23, 22, 23, 24, 25, 26, ...
Your task is to output the sequence. Standard code-golf rules and sequence I/O methods apply. (0-based and 1-based indexing allowed.) The shortest code in bytes wins.