I figured it out!
Image the rooms on a coordinate grid according to their position on the grid in the top left of the screen with the top left room being (0, 0). This means the top right room is (3, 0), the bottom right room is (0, 3) and the bottom right room is (3, 3).
At each room, you have the option to walk forward, right, back, or left. The coordinates of the room you inhabit are determined by the last two directions you walked, according to this:
forward 0
right 1
back 2
left 3
The y-coordinate is the first direction you walked and the x-coordinate is the second direction you walked.
For example, to get to the top right room (the one with the palm tree), you need to walk forward and left. This will put you in room (3, 0).