Thread history

From Talk:Main Page
Viewing a history listing
Jump to navigation Jump to search
Time User Activity Comment
03:00, 29 August 2012 Voidious (talk | contribs) New reply created (Reply to Modifying the Robocode Game.)
01:46, 29 August 2012 WhatsUp (talk | contribs) New reply created (Reply to Modifying the Robocode Game.)
15:53, 28 August 2012 Voidious (talk | contribs) New reply created (Reply to Modifying the Robocode Game.)
10:38, 28 August 2012 Skilgannon (talk | contribs) New reply created (Reply to Modifying the Robocode Game.)
09:35, 28 August 2012 Wompi (talk | contribs) New reply created (Reply to Modifying the Robocode Game.)
06:25, 28 August 2012 WhatsUp (talk | contribs) New thread created  

Modifying the Robocode Game.

I'm trying to modify the robocode game for a University assignment and I'm currently stuck so if anyone could help me that would be greatly appreciated. To modify the game I decided to create a new robot type that freezes other robots for a certain amount of turns when it runs into them. I have created a new interface for the freeze robot and altered some of the other code. When the game starts up it goes through all the robots that the user can choose from and creates a RobotPeer for them. And for each RobotPeer they all have a RobotType. If I debug the game here I can check the FreezeRobot that I made that implements the interface and it shows that it has both type FreezeRobot and AdvancedRobot. Which is what I want because if it doesn't implement AdvancedRobot then it can't use any of AdvancedRobot methods. So up till here everything is fine.

Though when I select the FreezeRobot and start a game with it then debug to check the RobotPeer, it is now only an AdvancedRobot. Can someone explain why this is?

In case you are wondering, what I am trying to do is to make edit the RobotPeer code in the checkForRobotCollision method. After it creates a new HitRobotEvent and sends that to the robot, I want to check if the otherRobot is a FreezeRobot and in this case it will change some variable that makes the robot frozen. I haven't worked that part out yet but I need to be able to see if the otherRobot is a FreezeRobot first so hence this post.

If anyone has any advice/tips/help it would be greatly appreciated. Thanks

WhatsUp06:25, 28 August 2012

Hi mate. Not sure if someone here can help you with this. Maybe you should ask your question (or just link it to this post) at the help section of SourceForge Forums. I guess Flamming can say something that might help you.

I hope you keep us informed how it is working out :)

Take Care

Wompi09:35, 28 August 2012
 

Yeah, on the wiki we more deal with robot development than with actual Robocode development. You might want to check out the robocode-developers Google group as well.

Good luck!

Skilgannon10:38, 28 August 2012
 

Perhaps it is only declared as AdvancedRobot in RobotPeer, but the instance is a FreezeRobot (and, more specifically, your robot class)? If you were seeing the instantiated type, it would show as your robot class. No matter the declared type, in Java you can do "instanceof" to check whether the actual instantiated object is a certain class (like FreezeRobot, or DrussGT), so maybe give that a shot and see if it works.

But yeah, as these guys said, the robocode-developers group and project forums are better places to get input from people who actually work on Robocode. They don't compulsively check the wiki as often as us Robocode addicted bot authors. ;)

Voidious15:53, 28 August 2012
 

Ok thanks I'll try the developers group.

Also I tried 'instanceof' to check the type but it makes a compile error because RobotPeer cannot be compared to FreezeRobot.

WhatsUp01:46, 29 August 2012
 

Sorry - I meant where ever you're debugging and seeing an AdvancedRobot when you want to see a FreezeRobot, try instanceof on that variable. It's probably true for "instanceof FreezeRobot", which is one way you could test the type of a robot - though probably not the fastest way, so you might want to figure something else in final implementation.

Voidious03:00, 29 August 2012