Discussion:
ScannedRobot Issue
mbesney
2012-06-05 22:23:57 UTC
Permalink
Hello All,

I doubt if there is a solution to my problem but I thought I might as well ask so here goes. I am running the Robocode engine from an Eclipse based external Java application.

The security manager is disabled so that my robot can send robot events (e.g. ScannedRobot)through the clipboard to the Java application. There is no problem there, the events do get through. The problem is that when the Java application puts command in the clipboard for the robot to execute in response to the ScannedRobot event the robot is too busy to get them.

It boils down to a sychronization problem. The ScannedRobot event fires so rapidly that it keeps my robot stuck in its onScannedRobot event handler where it sends the event to the Java application. The robot never gets back to the main loop in order to check the clipboard until the event has passed by which time it is too late.

I hope I have made the problem clear, any suggestions would be more than welcome...

Regards,

Mike



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

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
2012-06-06 07:39:31 UTC
Permalink
Hi Mike,

One thing you could try is to add the -Ddebug=true property when starting your application, i.e. options for 'java' when starting the JVM. You can also set it runtime before starting the RobocodeEngine.

Normally I advise Robocoders you just register the information sent with the onXXX event, but not take any real action that takes a long time. For example, you could just add the ScannedRobotEvent to a list, which you then process later. That is, just store the received information from the onXXX handlers, and then take action later in the run() loop.

Another method would be to read the events without using the onScannedRobotEven(), by using getScannedRobotEvents:

http://robocode.sourceforge.net/docs/robocode/robocode/AdvancedRobot.html#getScannedRobotEvents()

You read these out for each turn in the run loop.

I hope this will lead you in the right direction. :-)

Cheers,
- Flemming N. Larsen
Post by mbesney
Hello All,
I doubt if there is a solution to my problem but I thought I might as well ask so here goes. I am running the Robocode engine from an Eclipse based external Java application.
The security manager is disabled so that my robot can send robot events (e.g. ScannedRobot)through the clipboard to the Java application. There is no problem there, the events do get through. The problem is that when the Java application puts command in the clipboard for the robot to execute in response to the ScannedRobot event the robot is too busy to get them.
It boils down to a sychronization problem. The ScannedRobot event fires so rapidly that it keeps my robot stuck in its onScannedRobot event handler where it sends the event to the Java application. The robot never gets back to the main loop in order to check the clipboard until the event has passed by which time it is too late.
I hope I have made the problem clear, any suggestions would be more than welcome...
Regards,
Mike
------------------------------------

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/
mbesney
2012-06-06 20:33:11 UTC
Permalink
Thanks for the ideas Flemming.
Post by flemmingnlarsen
Hi Mike,
One thing you could try is to add the -Ddebug=true property when starting your application, i.e. options for 'java' when starting the JVM. You can also set it runtime before starting the RobocodeEngine.
Normally I advise Robocoders you just register the information sent with the onXXX event, but not take any real action that takes a long time. For example, you could just add the ScannedRobotEvent to a list, which you then process later. That is, just store the received information from the onXXX handlers, and then take action later in the run() loop.
http://robocode.sourceforge.net/docs/robocode/robocode/AdvancedRobot.html#getScannedRobotEvents()
You read these out for each turn in the run loop.
I hope this will lead you in the right direction. :-)
Cheers,
- Flemming N. Larsen
Post by mbesney
Hello All,
I doubt if there is a solution to my problem but I thought I might as well ask so here goes. I am running the Robocode engine from an Eclipse based external Java application.
The security manager is disabled so that my robot can send robot events (e.g. ScannedRobot)through the clipboard to the Java application. There is no problem there, the events do get through. The problem is that when the Java application puts command in the clipboard for the robot to execute in response to the ScannedRobot event the robot is too busy to get them.
It boils down to a sychronization problem. The ScannedRobot event fires so rapidly that it keeps my robot stuck in its onScannedRobot event handler where it sends the event to the Java application. The robot never gets back to the main loop in order to check the clipboard until the event has passed by which time it is too late.
I hope I have made the problem clear, any suggestions would be more than welcome...
Regards,
Mike
------------------------------------

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/

Loading...