Question: WRITE IN PYTHON:in the previous questions we assumed the Vacuuminator had a perfect knowledge of the world around it . In practice, mobile robots need
WRITE IN PYTHON:in the previous questions we assumed the Vacuuminator had a perfect knowledge of the world around it In practice, mobile robots need to rely on sensors to find out information about the world. In this question we assume that the Vacuuminator has exactly four sensors:WRI
A 'left sensor which will identify the nearest dirty square immediately to the left of the Vacuuminator ie in the same row with a lower index position
A 'right sensor which will identify the nearest dirty square immediately to the right of the Vacuuminator ie in the same row with a higher index position
An up sensor which will identify the nearest dirty square immediately above the Vacuuminator ie in the same column with a lower index position
A 'down sensor which will identify the nearest dirty square immediately below the Vacuuminator ie in the same column with a higher index position
The Vacuuminator's sensors are unable to penetrate walls, ie dirt on the opposite side of a wall will not be detected. The Vaccuminator is also unable to identify dirt that its sensors can't see eg dirt that is diagonal to its current position
Write a function pathtonextworld that will identify the nearest piece of dirt that will be detected using the Vacuuminator's sensors Your function should return a list containing the moves required for the Vacuuminator to reach that piece of dirt from its current position.
In the event that there are multiple pieces of dirt that are at an equal distance from the Vacuuminator, they should be prioritised in the following order:
Highest Priority: Dirt above the Vacuuminator
Second Priority: Dirt to the right of the Vacuuminator
Third Priority: Dirt below the Vacuuminator
Lowest Priority: Dirt to the left of the Vacuuminator
The Vaccumunator stays at its position when scanning, then goes straight to the nearest target dirt which is directly at up right, down or left directions from the vaccumators current position, and the target maybe one or more unit distances further away
If no dirt can be detected, your function should return an empty list.
Example Calls
printpathtonextEDEX
u
printpathtonextEDEEEX
uu
printpathtonextDEEX
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
