Discussion:
execute() doesn't return
Jeff Van Epps
2014-03-12 20:03:46 UTC
Permalink
I've started working on an AdvancedRobot, and I find that sometimes the
call to execute() just doesn't return. I've got an out.println() right
after that which never prints. So far I haven't found a way to trigger it
to happen. Other robots in the battle continue executing. onSkippedTurn()
isn't being called. What I've asked it to do on the turn when it hangs is
sometimes as simple as just a setTurnGunRight(20). Sometimes, when the next
round begins, I see this printed:

java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:758)
at
net.sf.robocode.host.security.RobotThreadManager.stop(RobotThreadManager.java:189)
at
net.sf.robocode.host.security.RobotThreadManager.stopSteps(RobotThreadManager.java:171)
at
net.sf.robocode.host.security.RobotThreadManager.forceStop(RobotThreadManager.java:142)
at
net.sf.robocode.host.security.RobotThreadManager.waitForStop(RobotThreadManager.java:127)
at
net.sf.robocode.host.proxies.HostingRobotProxy.waitForStopThread(HostingRobotProxy.java:151)
at
net.sf.robocode.host.proxies.BasicRobotProxy.waitForStopThread(BasicRobotProxy.java:43)
at net.sf.robocode.battle.peer.RobotPeer.waitForStop(RobotPeer.java:1670)
at net.sf.robocode.battle.Battle.finalizeRound(Battle.java:386)
at net.sf.robocode.battle.BaseBattle.run(BaseBattle.java:206)
at java.lang.Thread.run(Thread.java:662)
SYSTEM: This robot has been stopped. No score will be generated.

I'm not starting any threads of my own, or doing any file/network I/O.
Really it's nothing but some trig, not that complicated.

Any notions?

Version 1.9.0.0 Running on *Java 1.6.0_26 (64-bit)* by Sun Microsystems Inc.
on Ubuntu 13.10 64-bit
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
fnl
2014-03-12 22:03:07 UTC
Permalink
It seems like your robot is running into an infinite loop somehow. This
could be due to e.g. an event handler being called, that calls some method,
that triggers the exact same event handler or something else.
The onSkippedTurn() is not called this will only happen if one execute() is
executed at time X and another execute() is executed at time Y, and the
delta time between X and Y is too big. Then you receive onSkippedTurn() as
a notification that you have a serious issue with your robot. When
execute() never returns due to an infinite loop, the SkippedTurnEvent never
happens.

I recommend that you add some out.println (e.g. out.print("#") ) statements
in your run method - especially in loops. You could also add a
out.println("onScannedRobot") as the first line for your onScannedRobot()
handler and do this for every event handler you have.
If you are lucky you should be able to see which out.print statements that
are called too many times. :-)

As alternative, you can send the robot (source file) to me at fnl (at)
users.sourceforge.net. Then I will have a look. I will not share the source
code with anybody and only keep it temporarily while debugging it.

Cheers,
- Flemming
Post by Jeff Van Epps
I've started working on an AdvancedRobot, and I find that sometimes the
call to execute() just doesn't return. I've got an out.println() right
after that which never prints. So far I haven't found a way to trigger it
to happen. Other robots in the battle continue executing. onSkippedTurn()
isn't being called. What I've asked it to do on the turn when it hangs is
sometimes as simple as just a setTurnGunRight(20). Sometimes, when the next
java.lang.ThreadDeath
at java.lang.Thread.stop(Thread.java:758)
at
net.sf.robocode.host.security.RobotThreadManager.stop(RobotThreadManager.java:189)
at
net.sf.robocode.host.security.RobotThreadManager.stopSteps(RobotThreadManager.java:171)
at
net.sf.robocode.host.security.RobotThreadManager.forceStop(RobotThreadManager.java:142)
at
net.sf.robocode.host.security.RobotThreadManager.waitForStop(RobotThreadManager.java:127)
at
net.sf.robocode.host.proxies.HostingRobotProxy.waitForStopThread(HostingRobotProxy.java:151)
at
net.sf.robocode.host.proxies.BasicRobotProxy.waitForStopThread(BasicRobotProxy.java:43)
at net.sf.robocode.battle.peer.RobotPeer.waitForStop(RobotPeer.java:1670)
at net.sf.robocode.battle.Battle.finalizeRound(Battle.java:386)
at net.sf.robocode.battle.BaseBattle.run(BaseBattle.java:206)
at java.lang.Thread.run(Thread.java:662)
SYSTEM: This robot has been stopped. No score will be generated.
I'm not starting any threads of my own, or doing any file/network I/O.
Really it's nothing but some trig, not that complicated.
Any notions?
Version 1.9.0.0 Running on *Java 1.6.0_26 (64-bit)* by Sun Microsystems Inc.
on Ubuntu 13.10 64-bit
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jeff Van Epps
2014-03-12 22:51:21 UTC
Permalink
Good thought. There is already a println as first statement in
onScannedRobot() (and the last, so I know when it is getting called it is
managing to exit). The only other event handler implemented is
onRobotDeath() and there is no loop in it. The only thing it calls is
e.getName() to find out who died.

I will email.
--
You received this message because you are subscribed to the Google Groups "robocode" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robocode+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...