Closed nardost closed 5 years ago
Updated. Two switch statements, one for state transitions and one for state execution. Ask me about it and let's discuss.
while (true) { // state transitions switch (state) {
case STANDBY
if dirt tank is full
switch state to FULL_TANK
else if battery is low
switch state to LOW_BATTERY
else if any tiles not visited and cleaned
switch state to WORKING
else
switch state to OFF
case WORKING
if dirt tank is full
switch state to FULL_TANK
else if battery is low
switch state to LOW_BATTERY
else if all tiles visited/clean
switch state to STANDBY
case LOW_BATTERY
if at charging station
switch state to CHARGING
case CHARGING
if battery fully charged
switch state to STANDBY
case FULL_TANK
if tank emptied
switch state to STANDBY
case OFF
}
// state execution
switch (state) {
case STANDBY
case WORKING
use traversal algorithm to move and clean
case LOW_BATTERY
look for nearest charging station and go to it
case CHARGING
wait until battery fully charged
case FULL_TANK
stop and wait to be emptied
case OFF
turnOff()
}
}
will be on wiki
I am trying to figure out the robot's course of action. Comment on this pseudo-code.