Multicolor Langton's ant

There is several ways to extend the concept of Langton's ant. In this exercise, we explore first one, using more than two colors. It remains very similar to the base case: the behavior at each step still depends on the ground color, but you have more than 2 possibilities. It allows to have more than one kind of ant, depending on what you decide to do for each color. For example, the ant LRL takes 3 colors. It turns left on the first color, right on the second one and left on the third color. According to this definition, the basic ant is a RL (since it turns right on white cells and left on black ones).

Some of these ants draw fascinating patterns (switch the world to see them): LLRR build a symmetric figure resembling loosely to a ball, LRRRRRLLR draws a square, LLRRRLRLRLLR draws a convoluted regular pattern after a period of seemingly chaotic behavior, and RRLLLRLLLRRR seems to fill a hour glass...

Changing your buggle into a generic Langton's ant is not very complicated, although it is not completely trivial. As previously, you have to write a step function. But this time, it receives two arrays as parameters. The first one defines the rules to follow depending on the ground color while the second one gives the sequence of colors to use. For example, the basic ant would have [!java]{'R', 'L'} and {Color.white, Color.black}[/!] [!python]['R', 'L'] and [Color.white, Color.black][/!] [!scala]Array('R', 'L') and Array(Color.white, Color.black)[/!] as arguments.

At each step, you thus have to apply the following pseudo-code:

You now should have enough information to succeed.