Discussion:
Debugging a Robot
icyjj10
2010-09-19 11:52:52 UTC
Permalink
Hello
I have been building a robot, but have found that it freezes a few seconds after it runs. I am pretty sure that this is because of a runtime error in the javavm, but I don't know how I can see the error output. How would I go about debugging the robot and seeing the runtime error? I'm pretty sure the error comes from a division by zero somewhere, but I would really like to know the line it occurs on.

I am not using eclipse by the way, so I might need to do it the manual way, using System.out.println to print to the robot window. Is there a better way?



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
Robocode-***@yahoogroups.com
Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Julian Kent
2010-09-19 13:11:23 UTC
Permalink
My guess is that you have an infinite loop somewhere that is freezing
your bot. Try putting System.out.println("loop 1") in each loop and when
it freezes you can see which one it displays over and over again. You
can see the output console by clicking on the robot's name on the right
of th battle field.
Regards
Julian (AKA Skilgannon on Robowiki)
Post by icyjj10
Hello
I have been building a robot, but have found that it freezes a few
seconds after it runs. I am pretty sure that this is because of a runtime
error in the javavm, but I don't know how I can see the error output. How
would I go about debugging the robot and seeing the runtime error? I'm
pretty sure the error comes from a division by zero somewhere, but I
would really like to know the line it occurs on.
I am not using eclipse by the way, so I might need to do it the manual
way, using System.out.println to print to the robot window. Is there a
better way?
------------------------------------
Yahoo! Groups Links
--
Julian Kent
***@fastmail.net
--
http://www.fastmail.fm - The professional email service



------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
Robocode-***@yahoogroups.com
Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2010-09-19 20:44:05 UTC
Permalink
If you got a runtime error from the JavaVM, it would show up in the main console running the game. If so, please tell me what it writes.

If your robot freezes, it could be that you are developing on an AdvancedRobot, and have not called execute() during your main loop.

E.g.:

public void run() {
// perform initialization
...

while (true) {
setAhead(some value);
setTurnLeft(some value);
...
// execute() is not called
}
}
Post by icyjj10
Hello
I have been building a robot, but have found that it freezes a few seconds after it runs. I am pretty sure that this is because of a runtime error in the javavm, but I don't know how I can see the error output. How would I go about debugging the robot and seeing the runtime error? I'm pretty sure the error comes from a division by zero somewhere, but I would really like to know the line it occurs on.
I am not using eclipse by the way, so I might need to do it the manual way, using System.out.println to print to the robot window. Is there a better way?
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
Robocode-***@yahoogroups.com
Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
icyjj10
2010-09-19 22:26:33 UTC
Permalink
I managed to fix it, I had copied one of my formulas for the tracking wrong, so a NaN had probably come into most of the calculations. I put a purposeful runtime error, and can see that they do indeed get put into the player console.

Your second point is interesting, becuase I am currently using an AdvancedRobot but don't call execute(). It might be because I am still using, for example, ahead instead of setAhead and turnRightRadians instead of setTurnRightRadians.
Post by flemmingnlarsen
If you got a runtime error from the JavaVM, it would show up in the main console running the game. If so, please tell me what it writes.
If your robot freezes, it could be that you are developing on an AdvancedRobot, and have not called execute() during your main loop.
public void run() {
// perform initialization
...
while (true) {
setAhead(some value);
setTurnLeft(some value);
...
// execute() is not called
}
}
Post by icyjj10
Hello
I have been building a robot, but have found that it freezes a few seconds after it runs. I am pretty sure that this is because of a runtime error in the javavm, but I don't know how I can see the error output. How would I go about debugging the robot and seeing the runtime error? I'm pretty sure the error comes from a division by zero somewhere, but I would really like to know the line it occurs on.
I am not using eclipse by the way, so I might need to do it the manual way, using System.out.println to print to the robot window. Is there a better way?
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
Robocode-***@yahoogroups.com
Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2010-09-20 22:13:28 UTC
Permalink
You are right. You just have to call a command that executes immediately
like e.g. ahead(), turnLeft() etc. If you are only calling set methods
like setAhead(), setTurnLeft() etc., you need to call execute() in order
to execute all pending commands. :-)
Post by icyjj10
I managed to fix it, I had copied one of my formulas for the tracking
wrong, so a NaN had probably come into most of the calculations. I put a
purposeful runtime error, and can see that they do indeed get put into
the player console.
Post by icyjj10
Your second point is interesting, becuase I am currently using an
AdvancedRobot but don't call execute(). It might be because I am still
using, for example, ahead instead of setAhead and turnRightRadians
instead of setTurnRightRadians.
Post by icyjj10
Post by flemmingnlarsen
If you got a runtime error from the JavaVM, it would show up in the
main console running the game. If so, please tell me what it writes.
Post by icyjj10
Post by flemmingnlarsen
If your robot freezes, it could be that you are developing on an
AdvancedRobot, and have not called execute() during your main loop.
Post by icyjj10
Post by flemmingnlarsen
public void run() {
// perform initialization
...
while (true) {
setAhead(some value);
setTurnLeft(some value);
...
// execute() is not called
}
}
Post by icyjj10
Hello
I have been building a robot, but have found that it freezes a few
seconds after it runs. I am pretty sure that this is because of a
runtime error in the javavm, but I don't know how I can see the error
output. How would I go about debugging the robot and seeing the runtime
error? I'm pretty sure the error comes from a division by zero
somewhere, but I would really like to know the line it occurs on.
Post by icyjj10
Post by flemmingnlarsen
Post by icyjj10
I am not using eclipse by the way, so I might need to do it the
manual way, using System.out.println to print to the robot window. Is
there a better way?
Loading...