Here we'll be maintaining a list of common issues and questions that people have with the client and the solutions and answers to these problems. This page is still a work in progress and we'll be updating it throughout the competition.
Also - we update the client and other software throughout the competition. Your scaffold is set up to automatically download these updates, and many of these updates will fix bugs and improve the client in general. At any point, check the Specs & Software page for details on the most recent patches.
If you downloaded your Battlecode files Monday night (1/9) or earlier, we've updated a few things. Redownload your scaffold on the website. See the git repository for when it was last updated: https://github.com/battlecode/battlecode-scaffold-2017. In addition, the latest version of the README will also be there and we might make clarity updates over time.
If you get errors related to 'unpackClient' or 'copying' not working, try closing the client. It might be trying to unpack over files that are running, which doesn't work on Windows or some Linuxes.
General solutions to a lot of problems:
1. Refresh dependencies to make sure you have the latest version of all the libraries. Your scaffold should automatically download new updates when you run any gradle command (build, for example). If it's not working, this is how you'd force it to update: From command line, run
gradle --refresh-dependencies build or
./gradlew --refresh-dependencies build or
gradlew.bat --refresh-dependencies build. Run this from the root directory of your Battlecode project. For Eclipse, you can also right click the project in the Package Explorer and select "Refresh Dependencies" in the "Gradle" menu. On IntelliJ, above the list of gradle tasks there is an icon with two blue arrows in a circle that will "Refresh All Gradle Projects."
2. If your build isn't working, try cleaning and rebuilding. There should be relevant gradle tasks for this (build->clean in Eclipse). Alternatively, you can just delete your build folder.
3. Re-download and set the scaffold up from scratch. This has fixed problems for people.
4. Make sure your gradle version on your computer is up to date if you are using command line / terminal. It should be version 3.3.
5. Rerun the gradle
If your Javadocs are out of date on your IDE or if your IDE doesn't seem to recognize the latest update: For Eclipse, you can right click the project in the Package Explorer and select "Refresh Dependencies" in the "Gradle" menu. On IntelliJ, above the list of gradle tasks there is an icon with two blue arrows in a circle that will "Refresh All Gradle Projects."
First thing to try for any client issue: press F12. This opens the debug console and will give you more information. If you see a gradle failure, your code probably doesn't compile.
If your client dropdown shows no players: press F12 when running the client to see the debug console, and report the bug to us. Here are some resolutions:
- There's also a chance one of your players has a compile error (use the gradle build command to test this).
- Rebuild the client using gradle build (the same one you ran at the beginning). This might only fix the client once (and then it'll break if you close and reopen). We're looking into this right now.
- If pressing F12 complains about JAVA_HOME, you need to set this variable. There are a good number of articles on Google about this that describe this process well (and for every operating system).
If running a match does nothing: your robots are probably crashing before the game even starts, or they don't compile. Check the error console.
If you see a complaint about compileScala having to do with zincClassPath: your version of gradle is probably out of date. Install version 3.3.
If you see "Execution failed for task ':compileScala'. > java.io.IOException: Cannot run program (something javac)" on Eclipse: in the battlecode->build task, right click build and open the run configurations. Set the JAVA_HOME to where your JDK is.
If you see other errors about :compileScala: there is a good chance your code doesn't compile. Run the gradle
build command to figure out if that's the case. (This is a misleading error message, since it happens even if you are not using Scala. For example, this error happens if you have a Java compile error.)
If you get
Exception in thread "WebsocketSelector##" (with a NullPointerException) or your client keeps playing an old match: read through this thread in the meantime for a temporary solution: http://battlecodeforum.org/t/resolved-client-runs-previously-runned-game-on-startup/436.
If you can't find a client: you probably didn't build. Make sure to run the gradle
build task, as described in the README.
If a gradle task is taking forever on your IDE: close your IDE and run gradle
build from command line.
General Eclipse problems: make sure you have Eclipse neon2 and not an older version. Make sure you read the Caveats in the battlecode scaffold README as well.
If Eclipse doesn't list any gradle tasks: you can either set up your project again from scratch or follow the tips here: http://stackoverflow.com/questions/14751276/eclipse-not-recognizing-project-as-gradle-project
If you're wondering where your System.out.println output goes: the output should show up in the console. If it's not working for you, run the matches from command line in headless mode (use
gradle run, as described below). Afterwards, upload the match file and view it from the client. Also, remember that you can click on a unit to see that specific unit's output. You may have to adjust the number of rounds to be something larger.
How do I run a match from headless mode (from command line)? If you are using command line / terminal, enter your battlecode scaffold directory and execute
gradle run -PteamA=examplefuncsplayer -PteamB=examplefuncsplayer -Pmaps=shrine,SparseForest to run a match. If the gradle command doesn't exist, use
./gradlew instead or
gradlew.bat on Windows. This will produce a .bc17 match file in the matches/ folder, which you can open using the client.
How can I run use terminal / command line from my IDE?
If you are using IntelliJ, you can open the built-in Terminal. View -> Tool Windows -> Terminal should work. If you can't find it, follow the instructions here: https://www.jetbrains.com/help/idea/2016.3/working-with-embedded-local-terminal.html.
For Eclipse, you might have to install a plugin. This is one example: http://marketplace.eclipse.org/content/tcf-terminals
**"battlecode.instrumenter.InstrumentationException: ILLEGAL Illegal class: battlecode/instrumenter/inject/System
this class cannot be referenced by player code"**: sometimes your IDE will automatically import battlecode.instrumenter.inject.System when you are just trying to use Java's System class. Delete that unnecessary import statement.
If you have an issue with Gradle using an incorrect JDK, you can explicitly set it in
gradle/wrapper/gradle-wrapper.properties with a line like
org.gradle.java.home="C:\\Program Files (x86)\\Java\\jdk1.8.0_101" (replacing the last path with wherever your JDK was installed).
IntelliJ: If you've installed the latest version of the JDK but the option does not appear among the Gradle JVM choices: check these replies http://www.battlecodeforum.org/t/battlecode-2017-troubleshooting-faq/161/3.
If you get this error:
javac: invalid target release: 1.8 or if you see a complaint about not being able to find
javac: you need to install JDK 8. Instructions to do so are linked on the specs and software page. In addition, you also need to make sure that JDK 8 is on your computers PATH (or CLASSPATH). More detailed instructions are here https://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html, and pay especially careful attention to anything about setting the PATH / CLASSPATH.
If you're using Intellij, verify all these under File->Project Structure:
- Project -> Project SDK should be 1.8.
- Project Language Level should be 8 as well.
- Modules should have "java version 1.8" in the list
- SDKs should have an entry with the name 1.8 with JDK home path set to where your JDK installation is.
- Not in File->Project Structure, but Preferences -> Build, Execution, Deployment -> Build Tools -> Gradle should have Gradle JVM version 1.8.
For Eclipse, verify these:
- Preferences -> Java -> Compiler should say 1.8 everywhere.
- Preferences -> Java -> Installed JREs should have Java SE 8 checked.
If you're using terminal, make sure
java -version and
javac -version both output 1.8.something.
If you're on Linux Mint, you might have to follow these instructions to install JDK 8: http://community.linuxmint.com/tutorial/view/1372
If you get an error about
Unsupported major.minor version: it means that the version of Java you are compiling with is different from the version you are building with. Make sure that these versions are set properly on your IDE. Then, delete your build folder and rebuild everything.
If you see anything about unindexed remote maven repositories: that's okay. Just continue along with the instructions.
If you get something like "Windows cannot access the specified device, path, or file" when opening your client: read here: https://support.microsoft.com/en-us/kb/2669244 .
How do I get Javadocs linked with Eclipse? Right click the project in the Package Explorer and select "Refresh Dependencies" in the "Gradle" menu.
My robot explodes unexpectedly (possibly on round 1 or 2). Why? A robot will die if an uncaught exception is thrown, or if its run method returns. Make sure to always keep your code within a while loop. Make sure you wrap your code in a
catch, like how examplefuncsplayer does it. Then, if there are exceptions, you can catch them and use
e.printStackTrace() to see where the error is coming from.
If your player doesn't show up in the dropdown menu: make sure your source code is in a file called RobotPlayer.java and that it's in the src directory somewhere.
If you get
Could not find or load main class org.gradle.wrapper.GradleWrapperMain: check the gradle/wrapper folder in your scaffold. It should have two files in it (gradle-wrapper.jar and gradle-wrapper.properties). If not, you need to redownload these files from the scaffold.
If everything still doesn't work: post on this forum, or come to the Battlecode IRC (#battlecode on the irc.freenode.net server). An easy way to join is through here: http://irc.lc/freenode/battlecode. This is another client you can use: https://kiwiirc.com/client. On the IRC channel the devs will try their best to help you resolve your problem.
Check the issues and pull requests within our Github repositories.
If you are using our website and getting something like "CSRF verification failed: try switching to Google Chrome or another browser. It might also be a firewall issue.
How can you tell if a scrimmage is ranked or not? Ranked matches have a little gear icon on the left.
ABOUT THE GAME
How do you find the size of the map? You can't do this using any command. However, you could send out units (like scouts) to explore the map and figure out its size.
What maps will be used for tournaments? Those maps are not revealed until the tournament starts.
What does the boolean value in MethodCosts.txt do? You can safely ignore it. If you're curious, dig into the battlecode-server code.
How do I access parameters of different robot types (such as stride radius)? Look at the Javadocs for RobotType. As an example, you can get a Scout's stride radius using
Can I use multiple files for my player? Yes! In fact, this is encouraged. It'll make your code much cleaner.
Can I put my player code across multiple packages? Yes. your code can reside in different packages. This allows you to share code among multiple players. Just make sure to specify the correct package name for your RobotPlayer.java when you submit your bot.
Can I use global variables in my player? Yes, you can. However, global variables are not shared between robots. (Essentially, each robot is running in a completely isolated environment.) The only way for two robots to communicate is via broadcasts.