Question: So far i was able to come up with a code to generate a random number (1-4) in a mx2 matrix with the first one

So far i was able to come up with a code to generate a random number (1-4) in a mx2 matrix with the first one being (0,0). I don't know where to start with the coding.
Vacuum Robot Path In this problem, we are going to study the displacement of a vacuum cleaner robot that randomly wanders around a closed square room The room is represented by a square grid L ft XLft, so there are (L+1? grid points," each of size 1 ft2 in the room. Each grid point is represented by (x,y) coordinates, where x and y are both integers The robot cleans the room by randomly moving from one grid point to another Whenever the robot stops on a grid point, the area around that grid point is cleaned The robot also cleans as it moves, meaning that if it moves from (x y) (1; 1) to (x, y) (1; 3), then the points defined by (x, y) (1; 1), (1; 2), and (1; 3) have now all been cleaned. The robot starts in the bottom left corner of the room (x, y) (0,0) The direction and length of each robot movement is determined by two random numbers, which are provided in the input argument rmat. The first movement is determined by the first row of rmat, the second movement is determined by the second row, and so on. The first number in each row determines the direction (1 for +y, 2 for -y, 3 for +x, and 4 for -x), and the second number in each row determines the length of each movement. For example, if the robot's current position is (x, y) (2, 3) and the next row in rmat is 1,3, then the robot's next position is (x, y) (2, 6) (if L 26) f all rows of rmat have been used and the robot still has not cleaned the entire room then the values of t are recycled, starting with the first row If a step would cause the robot to hit a wall, then the robot should not take that step but instead go to the next row of rmat Write a function with the header function IN, path] Robo vacuum (L, rmat where L determines the size of the room as described above and rmat is a MX 2 matrix of random integers 1 through 4, which will tell the robot where to move. Your function will output N, the number of steps it takes for the robot to cover the entire room, as well as path, a (N +1) X 2 matrix where each row contains (x, y) coordinates of every step The first row of path will be 0, 0, and the second row will have the (x, y) coordinates of the robot after the first step When testing your code, make sure that rmat is big enough that the robot doesn't get stuck in a repeating path that doesn't cover the entire room. The larger L you use, the more rows rmat should have. Reasonable values for L should range from about 5 to 15 along with a few hundred rows in rmat. Also, plot the path of the robot to confirm that it has covered all the squares in the room
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
