-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started
This page serves as a getting started guide, helping you get your workspace set up for the competition. These steps will guide you through setting up Eclipse, but you can compete using another IDE (like IntelliJ IDEA). Just note that we are less likely to be able to help you if you do not set up your workspace in the way we instruct here.
The Eclipse IDE depends on having a Java Runtime Environment installed. You can download the Java Development Kit from the Oracle website. After that's installed, you can get Eclipse from the Eclipse downloads page.
After everything is installed, you can import your repository into Eclipse. If you signed up for the competition before May 18, you should have gotten an email from GitHub about your repository. Find your repository on the GitHub website, and click the Clone or download dropdown that appears. Make sure that you're getting it over HTTPS, not SSH. Copy the URL that appears in the text box.
With Eclipse open, select File > Import.... Then, under the Maven dropdown, select Check out Maven Projects from SCM and hit the Next button.
In the SCM URL dropdown, select git. In the text box to the right, paste the git URL you copied earlier. If git does not appear as an option in the dropdown, click the m2e Marketplace link and install the m2e-egit plugin. Once git is selected and the URL is entered, hit the Next button.
Then, hit the Finish button.
At this point, the repository should be imported, and it should appear in the Package Explorer (on the left by default).
In your project (in the Package Explorer) there should be a src/main/java source folder, with an org.bitbrawl.foodfighter package inside. In there, there's a SampleController.java file. This class is the entry point of your code. The playAction
method inside determines the action that your controller will play, given the field, the team that the controlled player is on, and the player themselves. Each turn of the game, this method will be called once (for every controller in the game).
You can use information from the field, team, and player to make decisions about what moves to play. For now, let's do a very simple example. Our player will always turn right. In other words, they will do nothing but spin in circles. Modify your playAction
method so that it looks like this:
@Override
public Action playAction(Field field, Team team, Player player) {
return Action.TURN_RIGHT;
}
In the src/test/java source folder, find the DebugTest
class and open it. Run it using the green Run button in the toolbar at the top. You should see a window with your controller spinning on a field, playing against one of the sample players.
Additionally, you may notice the FullTest
class. When run, this class can be used to test your code as it will be tested in tournament settings. That means that it will be running in a separate JVM from the other players (and the game engine), it will be limited in time (60 seconds) and memory (32 MB), and there will be certain classes that you are restricted from using (like File). It's recommended that you test your code at least once with FullTest
before each submission, but it's a bit more involved than DebugTest
.
First, you will have to compile your code into a single jar file. To do this, right click on the project in the Project Explorer and select Run As > Maven install.
Now, in the target folder, there should be a jar file. Copy that file and paste it into the testing/players directory. In the src/test/resources folder, there should be a config.json file. You will need to add your controller to the list. For example, your config.json file might look something like this:
{
"numMatches": 1,
"matchType": "FREE_FOR_ALL",
"controllers": [
{
"name": "dummy",
"jar": "testing/players/sample-players-1.0.0.jar",
"mainClass": "org.bitbrawl.foodfight.sample.DummyController"
},
{
"name": "random",
"jar": "testing/players/sample-players-1.0.0.jar",
"mainClass": "org.bitbrawl.foodfight.sample.RandomController"
},
{
"name": "hiding",
"jar": "testing/players/sample-players-1.0.0.jar",
"mainClass": "org.bitbrawl.foodfight.sample.HidingController"
},
{
"name": "walls",
"jar": "testing/players/sample-players-1.0.0.jar",
"mainClass": "org.bitbrawl.foodfight.sample.WallsController"
},
{
"name": "Finn's Controller",
"jar": "testing/players/foodfighter-finn-1.0.0.jar",
"mainClass": "org.bitbrawl.foodfighter.SampleController"
}
],
"data": "testing/data"
}
Data from the match (and a generated video of the match) will appear in the testing/data directory. Note that the video can take a while to generate.
You probably don't want SampleController
as the name of the controller class, and you may not want its package to be org.bitbrawl.foodfighter
. To change it, you will need to change a few files. To change the package name, right-click on the package in the Package Explorer and select Refactor > Rename..., then choose the new name for the package. You can do the same thing for the class name.
You will also have to change the name in the two config.json files: the one in src/main/resources and the one in src/test/resources. Forgetting to change the config file in src/main/resources will make it so we try to run the wrong class in the competition.
Given all of this setup, the submission should be relatively simple. All you need to do is update the version
in the src/main/java/config.json file, and then commit and push your code to the git repository. You can do this within Eclipse by right-clicking on the project in the Package Explorer, and selecting Team > Commit.... Drag all of the desired changes from the Unstaged Changes area to the Staged Changes area, and then hit the Commit and Push... button.
If you want to resubmit your code after making changes, you will need to commit and push as before. You will most likely want to change the version number first; however, you can choose to leave it if you'd like. If you do change the version number, past versions will not affect the leaderboard, so you're essentially erasing the performance of previous versions.