Robocode/Eclipse/Running from Eclipse

From Robowiki
< Robocode‎ | Eclipse
Revision as of 22:21, 3 October 2023 by Coisale13 (talk | contribs) (Added page to explain how to setup Intellij with Robocode)
Jump to navigation Jump to search

Wondering how to run your robot in Robocode from Intellij? Well this is possible! And that is what this page is all about.

Make sure Robocode is installed and can run before continuing.

Create a new Intellij project

Create a new Java project in Intellij. Nothing special about it. I am using JDK 1.8, I don't think this matters.

Add Robocode's library + javadocs to Intellij

Right click your top level module/folder in intellij. Select "Open Module Settings" (or press F4). Go to libraries, and add a Java library. Navigate to where you installed Robocode and select both the "libs" and "javadoc" folder. Apply, Okay, exit.

Create Your Package + Robot

Right click the src folder on the right. Add a package. In the package, add a java class.

import robocode.Robot, and write a class that extends Robot. Intellij should be autocompleting for you at this point.

Build and use your robot

Build your file. You should see a new folder appear in your project. out > production > projectName > packageName > robotClassName

Load up Robocode, go to Options > Preferences > Development Options Add the path to your intellij build output. Specifically /path/to/intellijProjectName/out/production/projectName If you don't add this exact path, it won't work.

When you start a battle, in the robot selector, you should see your robot appear under your package name!

Running your robot from Intellij

Edit your run configurations. Create a new run configuration of type "Application".

Hit the blue "Modify Options" text on the right, select "Add VM options". Make sure you fill out the following: java version: java 8 SDK main Class: robocode.Robocode VM options: -Xmx512M -Dsun.io.useCanonCaches=false -Ddebug=true Working directory: path/where/you/installed/robocode

Save this.

Now add some breakpoints, hit the debug icon in intellij. It should load up robocode. When you start a battle with your bot, it will stop on the debug points!

See also

Robot API

Tutorials

News and Releases

Home pages