Re: Using NetBeans
"flemmingnlarsen" <[email protected]>
| Newsgroups | gmane.comp.java.robocode |
|---|---|
| Message-ID | <[email protected]> |
Hi Ed, I still haven't forgot your question about how to debug a robot within NetBeans. So here I give you the description. [:)] Run/debug Robocode from NetBeansFirst of all, you need to add a development path that points to your robots classes in your NetBeans project.In Robocode, select this from the menu: Options -> Preferences ->Development Options.Press the Add button to browse to your development path in NetBeans. It could be something like this: R:\NetBeansProjects\MyRobots\build\classes Note, that you should point at the 'classes' folder to get it right. Secondly, you need to set your project configuration regarding running your robot. You do this within your project in NetBeans from the menu: Run -> Set Project Configuration ->Customize...Under the Run category, you first create a new configuration, which you could name Robocode.Next you field out the following fields and values: Main Class: RobocodeWorking Directory: C:\robocodeVM Options: -Xmx512M -Dsun.io.useCanonCaches=false -Ddebug=true Note: It is very important to set Robocode to run your robots in debug mode. In this mode your robot is allowed to use lots of time between rounds, while debug your robots. Otherwise your robot will be stopped almost immediately with an error telling you that your robot skipped too many turns. The debug mode is set with the 'VM Options' above. Note, your working directory should point to where you have installed Robocode.The VM options must refelect the options specified in the robocode.bat, robocode.sh and robocode.cmd file (they are set to the same options in all these startup scripts). Now you can press Ctrl + F5 or select Debug -> Run Main Project from the menu, and Robocode will start up. Create a battle fileYou need to start up a new battle, and here your robot(s) should show up, if you have added the development path into where your robot(s) reside in the NetBeans project. If (or rather when) you get tired of starting a new battle all the time, then create a new battle with the opponent robots and battle field configuration you need, and save the battle, e.g. with the name test.battle. Next, you return to the project configuration (menu: Debug -> Set Project Configuration ->Customize... under the Run configuration), and set this additional parameter: Arguments: -battle test.battle This will tell Robocode to start up with your battle automatically. You can now set breakpoints in your robot, and start debugging your robot. Important!When you are debugging your robots, the battle will continue in the speed specified by your TPS slider in the bottom of your battle screen. This is annoying, as the battle will probably end before you reach the breakpoints you set in the NetBeans within your source file. Hence, you need to active the Pause/Debug mode of Robocode, which is the button named 'Pause/Debug' in the bottom left corner of the battle view. Whenever you need to step to the next turn in the game, you must press the 'Next Turn' button beside the 'Pause/Debug' button. Take a look at the title bar, which displays the current turn. You should see that it is incremented by one turn each time you press the button. [;)] I hope this helps? Regards,- Flemming--- In [email protected], "Ed" <eberne@...> wrote: > > Greetings all, > > I am trying to develop a robot using NetBeans. I have two questions: > > --Is it possible to run robocode from within NetBeans? If so, how is it done? I want to be able to do this so I can debug my robot. I see instructions for running and debugging robots with Eclipse, but I am hoping to avoid learning yet another IDE. > > --(really more of an annoyance) I changed the name of my robot by changing the name of the class and file in NetBeans. Now both the old (no longer valid) and new names appear in the list of available robots to start a battle. Ctlr-R doesn't seem to do anything. How do I remove the old name? > > Thanks in advance, > Ed >