eration. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If it is feasible to move to the left, right, up, or down, then move and repeat the process. If it is not feasible to move to the respective positions, then repeat the generation of random numbers modulo 4 and generate numbers 0, 1, 2, or 3. Take decisions whether to move left, right, up or down now and continue the process of cleaning the respective array positions. You can stop the process when all array positions are cleaned. You need to show the source code and the output. The o
Implement the vacuum cleaning agent function in Python/Java for the scenario described below: Consider two-dimensional Boolean array of size m x n (m and n can each be equal to 4) where m is the number of rows, and n is the number of columns. Obtain numerical positive integer values for m and n as inputs from the user. Generate random numbers and scale them down to either a “0” or a “1” according to whether they represent “Clean” or “Dirty”, respectively. After filling the array with 0s or 1s, start at some random array position indicating the initial position of the vacuum cleaner. First check if at that current position, there is the presence of a “Dirt” or not determined by whether 0 or 1 is filled in at that initial position of the vacuum cleaner. If there is a “Dirt”, clean it, and if there is no “Dirt” do a No-operation. After this is done, generate random numbers modulo 4 to obtain random numbers 0, 1, 2, 3 indicating whether to take a left, right, up or down correspondingly. If it is feasible to move to the left, right, up, or down, then move and repeat the process. If it is not feasible to move to the respective positions, then repeat the generation of random numbers modulo 4 and generate numbers 0, 1, 2, or 3. Take decisions whether to move left, right, up or down now and continue the process of cleaning the respective array positions. You can stop the process when all array positions are cleaned. You need to show the source code and the output. The output needs to be shown after the result of each action. The output can be shown as a 4 x 4 square grid (matrix-like) containing numbers 0s and/or 1s.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps