A nice robot-control puzzle

The goal is to find a sequence (a "program") of max 6 commands that will move the triangle (the "robot") through the grid and make it visit all the squares marked with a star.

Two types of commands can be used:

• P0 makes the sequence start over.
• The arrows (↑, ↱, ↰) move the triangle (forward) or make it change orientation (clockwise, anti-clockwise).

Each command can (but does not need to) have a color. A colored command is only executed if the triangle is in a square of the same color.

Attempting to move out of the board is not allowed.

You can play with it here if you want (no signup required). I'm the dev.

It's been a while since I posted one of these. Hope you like the changes to the UI :)

Oct 12 Edit: The link is temporarily directing to a different puzzle. Will fix that soon.

• Are you the dev of Robozzle or are you just reprogramming that game? – WhatsUp Sep 29 at 13:50
• @WhatsUp I was thinking the same! Robozzle brings sweet memories of ten years ago. It required Silverlight back then, which shows how much time has passed! One day I'll get around to writing a program to brute-force the solution of Hammered, which is still a mystery to me... Looking so simple, and yet so devilishly hard! – Fabio says Reinstate Monica Sep 29 at 15:57
• @FabiosaysReinstateMonica The whole Robozzle is just so simple and yet so amazingly complicated. It probably got the idea from cellular automatons such as Langton's ant, but turning it into a puzzle game is also genius. P.S. Hammered has only $6.4\times 10^7$ possible programs, so bruteforce should be doable... – WhatsUp Sep 29 at 17:02
• You should make a question of gauss-turing.herokuapp.com/p/15, love it btw. – hkBst Sep 30 at 11:45

Can't you just do

forward --- forward --- turn right --- turn right --- turn left if pink --- start over

?

• Yes. Much cleaner than what I had in mind, not gonna lie. Excellent job! – Lucas Sep 28 at 15:15
• @Lucas Perhaps try and come up with a slightly harder v2? I mean you've done all that programming why not show it off a bit more? – Albert.Lang Sep 28 at 15:25
• Absolutely. Stay tuned! In the meantime: puzzling.stackexchange.com/questions/92039/… – Lucas Sep 28 at 15:31

The poor robot might get slightly less dizzy with

forward --- forward --- turn right --- turn right if yellow --- turn right if purple --- start over

A slightly different approach as the other answers

[forward] [reset if green] [rotate left] [reset if pink] [rotate left] [reset]

I now wonder how many solutions there are.
Just in case the purpose is to take as long as possible: "the tourist".

move, right on green, left, left on purple , left on yellow, start over

• Maybe I'm not reading something right or I got the order mixed up, but I couldn't get this sequence to work; I did try, however, a similar approach which uses ROT13(Hc E(T) Y(C) Y Y(L) C0)... maybe you intended something more along those lines? – Omicron Zed Sep 29 at 12:22
• Yes, copy paste error, very sloppy of me. 1 yellow should be green which is identical to your suggestion. I'll edit – Retudin Sep 29 at 13:18
• Your answer does not work in the simulator. Do you assume that you cannot fall off the path? – hkBst Sep 30 at 8:56
• @hkBst Really? I just checked with the OPs simulator and it is ok. Maybe you got pink/purple mixed up? – Retudin Sep 30 at 9:10
• I got blue and purple mixed up as I do. – hkBst Sep 30 at 11:40

One sequence is:

[Up] [Up] [Turn](Pink) [*] [*] [P0], where * must be a turn in same direction. For example, [Up] [Up] [Left](Pink) [Left] [Left] [P0] should work.

First, it seems clear that we need at least:

A P0 at the end to ensure some repetition (since we have only six actions to choose from) and some means to turn around when we are at the end of a 'spire' in the cross, which would require two turns in the same direction.

This would give something along the lines of:

[-] [-] [-] [Left/Right]* [Left/Right]* [P0], where * are in the same direction.

We obviously need something else, though, because:

We need a way to move towards and away from the center pink square while we are in a 'spire'. Given we start at the end of a 'spire' and are facing the center, the easiest way out is to move forward by two (i.e., [Up] [Up] [-] [-] [-] [-]).

However, we just need a bit of additional logic:

We have a way to move in and out of 'spires', but we currently have no way to 'select' a 'spire'. To do so, we have to rotate to each 'spire' of the cross, but we should only do that if we are at the center square; one simple way to do this is to have [Left/Right](Pink) after we move forward.

Notice, however, there is no one answer:

As long as we have some pattern similar to [Up] [Up] [Turn] [Turn] [Turn] [P0], where one turn is conditioned on Pink and the other two turns are in the same direction (i.e., the Pink-conditioned turn need not be in the same direction as the two other turns, and the order of turns does not matter, so long as the turns occur after the forward motion), we have a solution.

• Your answer reads a bit like you are enumerating all possible answers. Other forms are possible though. – hkBst Sep 30 at 8:58
• @hkBst Keep in mind, I did say "one" solution; I'm aware of the many answers and multiple forms that could solve the scenario, but there are certain observable patterns which I think fall in line with what I wrote... Maybe not word for word, but the logical components and framework is self-evident. However, isn't that a flaw of the question if there are multiple solutions that are equally desirable? Wasn't that then my intention, to point out the countless enumerations, rather than argue for a truly singular answer? – Omicron Zed Sep 30 at 14:56

Another way to do it is:

[go] [go] [turn] [middle P0] [turn] [P0]

• Yep, we definitely disagree on what purple is – Retudin Sep 30 at 9:30
• @Retudin, thanks, I thought there was disagreement on the color of the middle square, but it turns out the blue squares are really purple. – hkBst Sep 30 at 11:31