[Pogamut-list] Player Vs Player
M.A.H
pogamut-forum at artemis.ms.mff.cuni.cz
Thu May 8 00:19:13 CEST 2008
Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Re: Player Vs Player
What im trying to do is create a bot like Kheperalike but with another sensor at the back. Here is the code. The error occurs at the end where it says "} catch (Exception e) {"
try{
//
if (sensor) {
// if some sensor is signalizing...
if (moving) {
// and we're moving ...
body.stop(); // stop the movement
moving = false;
}
// according to the signals, take action...
// follows 8 cases that might happen
if (sensorFront) {
if (sensorBack) {
if (sensorLeft) {
if (sensorRight) {
// LEFT, RIGHT, FRONT, BACK are signalizing
body.turnHorizontal(bigTurn);
Thread.sleep(turnSleep);
} else {
// LEFT, FRONT are signalizing
body.turnHorizontal(smallTurn);
Thread.sleep(turnSleep);
}
} else {
if (sensorRight) {
// RIGHT, FRONT, BACK are signalizing
body.turnHorizontal(-smallTurn);
Thread.sleep(turnSleep);
} else {
// FRONT is signalizint
body.turnHorizontal(smallTurn);
Thread.sleep(turnSleep);
}
}
} else {
if (sensorLeft) {
if (sensorRight) {
// LEFT, RIGHT are signalizing
body.contMove(moveSpeed);
moving = true;
} else {
// LEFT is signalizing
body.turnHorizontal(smallTurn);
Thread.sleep(turnSleep);
}
} else {
if (sensorRight) {
// RIGHT is signalizing
body.turnHorizontal(-smallTurn);
Thread.sleep(turnSleep);
} else {
// no sensor is signalizing
body.contMove(moveSpeed);
moving = true;
}
}
}
} else {
body.contMove(moveSpeed);
moving = true;
}
} catch (Exception e) {
log.severe("Exception ...");
}
----
Reply Link: <https://artemis.ms.mff.cuni.cz/pogamut/tiki-view_forum_thread.php?forumId=6&comments_reply_threadId=171&comments_parentId=118&post_reply=1#form>
More information about the Pogamut-list
mailing list