Download Method Summary

Transcript
Section III
Source Code --- ROBOT PATROL SYSTEM
case 2:
MyDir = LeftOf;
break;
// go right
actuator.Right();
Right_of(MyDir);
MyDir = RightOf;
break;
}
if(NextMove != -1)
//Should we move forward?
{
actuator.Travel();
MyPath[PathCounter ++] = NextMove;
RelX(MyDir);
MyPosX = RelPosX;
RelY(MyDir);
MyPosY = RelPosY;
continue;
}
actuator.back();
while(Map[MyPosX][MyPosY] < 2 && PathCounter-- >
0)
{
switch(MyPath[PathCounter])
{
case 0:
//go back right
actuator.Right();
Right_of(MyDir);
MyDir = RightOf;
break;
case 2:
//go back left
actuator.Left();
Left_of(MyDir);
MyDir = LeftOf;
break;
}
actuator.Travel();
RelX(MyDir);
RelY(MyDir);
//change position
MyPosX += RelPosX;
MyPosY += RelPosY;
}
}
actuator.stop();
}
}
Daniel Egido Sánchez de Vega
164