Question: In this exercise, you will write a Python program that helps you navigate a treasure map represented by a grid. Your task is to find
In this exercise, you will write a Python program that helps you navigate a "treasure map"
represented by a grid. Your task is to find the hidden treasure by following a series of directional
commands. This exercise will help you practice Python basics, including loops, conditionals, and
list manipulation.
Scenario:
You are on a treasure hunt, and you have a map represented by a x grid. The grid looks like
this:
X
The X marks the spot where the treasure is hidden, and you start at the topleft corner of the grid
position
Instructions:
Map Initialization:
o Create a x grid filled with dots except for the treasure, which is marked by X
at a random position shown as in the matrix above
Navigating the Map:
o You will navigate the grid using a series of commands: up down, left, and
right.
o Write a function moveposition direction that takes the current position as
a list row col and a direction as a string, and returns the new position after
moving one step in that direction.
o Ensure that your function doesn't allow movement outside the grid boundaries.
Finding the Treasure:
o This is a text input based game. You will start at position
o Type commands rightleftupdown into the ipython console. Use the
move function you created to move to another location. You are searching for the
treasure.
o Have the program return a value giving how close you are to the treasure.
o Continue issuing commands until you reach the treasure, and print "Treasure
found!" along with the final position.
Plotting the Path:
o Use matplotlib to visualize the grid and the path you took to find the treasure.
o Plot the starting point, each move, and the treasure location.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
