7
$\begingroup$

enter image description here

Say I had the following 7x7 grid and two agents on the grid facing one another as shown.

  • The agents can follow the following commands: moveForward, turnRight, turnLeft.
  • The agents have to follow the same set of instructions.
  • Any instruction that would result in two agents sharing the same square will be ignored.
  • Any instruction that would result in the two agents colliding/phasing through one another would be ignored.
  • Any instruction that would cause an agent to leave the board would be ignored by that agent. (e.g. if you gave the instructions turnRight and moveForward, the green would turn right and move forward but the purple would simply turn right and remain in place)

What set of instructions would get the green agent on the green square and the purple agent on the purple square?

$\endgroup$
  • 1
    $\begingroup$ What happens if agents collide? (Meaning, what happens if A would go to B's square, and B would go to A's square, simultaneously? Do they phase through each other? After all, they're not going to end up on the exact same square) $\endgroup$ – Avi Jan 16 at 18:31
  • $\begingroup$ As the question is currently stated phasing would be fine since, after the move is made, they wouldn't be sharing a square. However when I thought of the question, collisions wouldn't be possible. I'll edit the question so that commands that result in collisions wouldn't be followed $\endgroup$ – Alfonso Canady Jan 16 at 18:36
10
$\begingroup$

The solution is:

There is no solution.

Because,

turns are never blocked. Thus, the two agents are always facing opposite directions. Thus, anytime one agent attempts to move up, the other agent attempts to move down. The downward move can be blocked at the bottom, allowing the average vertical position to increase, but once one agent has reached the top row, it is no longer possible to increase the average vertical position above the fourth row. After that, whenever one agent moves up, the other must move down.

$\endgroup$
  • 1
    $\begingroup$ That's almost exactly what I was going to post. Nicely done! $\endgroup$ – Jaap Scherphuis Jan 16 at 19:08
  • 1
    $\begingroup$ It would be possible if an agent stopped receiving instructions once it reached the target square. $\endgroup$ – Chris Cudmore Jan 16 at 19:08
  • $\begingroup$ A simpler explanation would be that there is no way for one agent to reach the top row while the other remains there. $\endgroup$ – Florian F Jan 18 at 23:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.