Bender - Episode 1 - Puzzle discussion


#149

It’s the second way.
And when he comes to the next Inverter, his preferences will reverse again (so he will go south).
If he comes to an Inverter he’s been to already the preference will always be set to default.


#150

When attempting to pass the Obstacles test the expected behavior is different to what is in the task description:

Input (using dots instead of spaces):

    ########
    #.@....#
    #.....X#
    #.XXX..#
    #...XX.#
    #...XX.#
    #.....$#
    ########

Output:

    SOUTH
    EAST
    EAST
    EAST
    NORTH - test expects SOUTH at this point

Help, is the logic supposed to be inverted in some cases besides stepping on an I square?


#151

No, it isn’t. When encountering an obstacle (He cannot go EAST), as per rule 4, he tries to go SOUTH first, then EAST, then NORTH, then WEST. Because he can go SOUTH in this scenario, he goes SOUTH.
He always tries SOUTH first, when he is not inverted.


#152

Expected result:

    SOUTH
    EAST
    EAST
    EAST
    SOUTH
    EAST
    SOUTH
    SOUTH
    SOUTH

As you can see there is no NORTH at all. So it is not like Bender is trying to go SOUTH and fails. He turns before going SOUTH again. It is as if the shortest path is described here instead of the simple: “go until you hit a wall, then turn, repeat”


#153

Oh wait, do you mean he always starts with SOUTH when hitting a wall?


#154

Yes, when not inverted, Bendy always tries to move SOUTH when hitting a wall.
The only time he would go WEST is in this constellation, if he went “EAST” into it:

.XX
..X
.XX

(Can’t go SOUTH, can’t go EAST, can’t go NORTH, so he goes WEST)

Larger example:

######
#.@.$#
#....#
#.X..#
#....#
######

Here, he would go
SOUTH (Obstacle)
EAST
EAST (Obstacle)
SOUTH
SOUTH (Obstacle, Obstacle)
NORTH
NORTH
NORTH

He doesn’t go NORTH immediately when hitting the right wall, because he always goes SOUTH first. On the bottom right corner, he cannot go SOUTH, cannot go EAST, thus goes NORTH.


#155

Thank you for the clarifications. This was unexpected as most bots depend on their current direction.