Treasure Hunt
🗺️ Real agents work in a loop: look, think, act. Look at the world, decide a move, make it, look again. Your bot stands on a treasure map at x = 0, y = 0. Each time it calls look(x, y), the map says which way to go:
look(0, 0) # "east": add 1 to x look(3, 0) # "north": add 1 to y look(3, 2) # "treasure"!
Your bot doesn't know where the treasure is. It just follows what it sees, and it stops after 20 moves so it never wanders forever. The checker hides the treasure somewhere else too.
Instructions
- Start at
x = 0andy = 0. - Loop up to 20 times:
look(x, y), and move 1 step for"east","west","north"or"south". - When it says
"treasure", printFound the treasure at 3, 2!with the real x and y, and stop.
💡 Hint
east is x = x + 1, west is x = x - 1, north is y = y + 1, south is y = y - 1. Check for treasure first, print, then break.