Please read the full question carefully before attempting the solution. Con- sider a two-dimensional grid map of a city,
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Please read the full question carefully before attempting the solution. Con- sider a two-dimensional grid map of a city,
Please read the full question carefully before attempting thesolution. Con- sider a two-dimensional grid map of a city, with anx-axis (horizontal) of streets and y-axis (vertical) of avenues.Coordinates on the map may be represented as a two-dimensionalvector (x,y), representing the intersection points of the streetsand avenues. For this problem, the grid is made of discrete integervalues with reference to an origin (0,0). Here (-1, 1) is onestreet to the left, and one avenue above, the origin (0, 0). Atourist is standing at coordinates (0, 0), and is looking for thetourist in- formation centre, located at (-1, 3). However, thetourist is completely lost and instead of asking for directions,begins a random walk to search for the tourist information centre.The tourist moves one road at a time, either horizontally orvertically (but can not move diagonally). Movement can be forwardsor backwards (posi- five or negative, respectively). Therefore, atevery point, there are 4 possible moves the tourist can make. Forinstance, when standing at the origin (0,0), the tourist can moveeither to (0, 1), (0, -1), (1, 0), or (-1, 0), and has an equalprobability of 0.25 of moving in each direction. However, thetourist can easily miss the tourist information centre completely.Use Repp to complete the following exercises. You will be graded onthe efficiency and readability of your code. 1. Write a code thatsimulates a random walk over N roads (streets or avenues) with anoutput stating if the tourist information centre was reached duringthe walk. Provide an example of calling this code for N=100. Forrepeatability use the set seed function. Note: the code shouldidentify if the tourist reaches the tourist centre (yes/no or 1/0or T/F). After the tourist visits the tourist centre, the touristshould finish travelling the N roads (i.e., the code does not stopat the tourist centre). [40 marks]