Robocode/Intellij/Running from Intellij
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
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!
- System Requirements for Robocode
- How to download and install Robocode
- The anatomy of a robot
- Getting started with Robocode
- My First Robot Tutorial
- Robocode Game Physics
- Scoring in Robocode
- Using the robot console
- Downloading other robots
- Learning from other robots
- Package your robot
- Frequently Asked Questions (FAQ)
- Articles about Robocode
- Starting Robocode from the command line
- Graphical debugging