Agents on Mars Tutorial
This page provides a description of how to start writing an agent program for the 2013 Agents on Mars scenario for the purposes of CSE 431 students at Lehigh University. This is a work in progress!
Setting up the IDE
The folowing instructions assume that you are using Eclipse. Users of other IDE's will have to modify to fit their environment as appropriate.
- Download the full package from http://www.multiagentcontest.org/downloads/Software/MAPC-Package-(All-Editions)/
- Unzip on your harddrive
- Create a new Java project from existing source code. I suggest you use massim-all-versions-2013-1.4/javaagents/src/main/java as your directory.
- Link additional source (using the Build Path->Link Source option) from massim-all-versions-2013-1.4/eismassim/src/main/java to your project. Because you already have a folder called java, I suggest you type javaeis for the folder name.
- Add two external archives (using the Build Path->Add External Achives... option) from massim-all-versions-2013-1.4/javaagents/target/dependency to the project:
- Create a new class that extends massim.javaagents.Agent. Implement the step() and handlePercept() methods. In addition to importing eis.iilang.Action, eis.iilang.Percept, and massim.javaagents.Agent, you may find it helpful to import massim.javaagents.agents.MarsUtil.
- To test your agent, create a Run Configuration:
- Set massim.javagents.App as the Main class
- Put "-ea" under VM arguments
- Set the working directory to the place where your eismassimconfig.xml and javaagentsconfig.xml files are. Alternatively, copy these files into the default working directory of your project.
- Make sure that the class attribute in the agent element of the javaagentsconfig.xml file is set to the name of your class. If you have different Java classes for each type of agent, be sure to include each in the correct order.
Testing your agent
The "full package" does not include any class or JAR files, but since you have no reason to change the server, I recommend that you simply use the "Getting started" package to run the server and the monitor. Assuming you have unzipped this package, here's what to do to run a game:
- In a new terminal window, go to massim-2013-1.4/massim/scripts
- Execute ./startServer.sh
- Choose the option that corresponds to the contest you wish to run
- In a second terminal window, go to massim-2013-1.4/massim/scripts
- Execute ./startMarsMonitor.sh
- From Eclispe, Run the Run Configuration for your class
- Press Enter in the first window (where you executed startServer.sh)
Running your agent without Eclipse
So far, I've been unable to modify the startAgents.sh script to work with custom agents. Assuming I've placed my .class file in the javaagents/target directory, it should be as simple as adding the classpath to the JRE invocation at the end, a la:
java -ea -classpath ../../../target/ -jar ../../$package
but this hasn't worked for me yet. Fortunately, as long as you don't have too many different agents teams you want to try out, you don't need this script.
If you want an agent you can run without having to have Eclipse installed on the target machine, then from Eclipse, simply:
- Right-click on the project and select "Export..."
- Open the "Java" folder and choose "Runnable JAR file"
- Pick the Launch Configuration you created for your agent
- Choose an export destination and JAR file name
- Choose "Extract required libraries into generated JAR"
- Press "Finish"
- Copy your two config files into the same directory as the JAR file
- To run an agent packaged in a JAR named myagent.jar...
java -ei -jar myagent.jar
Configuration for the CSE 431 tournament
Our tournament will consist of pairwise matchups of teams of 10 agents each. For easier visualization, the game will be played on a smaller board than the default. I have also tentatively set the number of steps to 200. If the agents don't spend much time before deciding on their actions, this will actually go too fast. However, if agents take the full 3.5 seconds allowed to choose their actions, games will take over 10 minutes. Below is a sample config file for the server that has two teams named A and B. In the actual competition, I'll use your official teamnames and give each team an individual password. However, for now you can use either team A or B to test your agents.
- server-config.zip: Unzip this file in your \massim\scripts\conf\. When you run the script to start the server, choose 2013-cse431comp (Note, as of 12/5/2013, this zip file was changed to rename cse431comp.xml to 2013-cse431comp.xml. This is because the startServer.sh script only allows you to choose from config files that start with "2013")
I have prepared sample config files for agents that allow you to have teams of 10 dummy agents and/or the team Tagaryen. Here's a zip of the sample files:
- agent-configs.zip: Unzip this file in your javaagents\scripts\conf\ directory. There are four different configurations:
- dummy10a - 10 dummy agents as Team A. Can be used to test your team against dummy agents if you are Team B.
- dummy10b - 10 dummy agents as Team B. Can be used to test your team against dummy agents if you are Team A.
- dummy10ab - Both team A and team B with 10 dummy agents each. Can be used to test playing two dummy teams against each otherr.
- Targaryen10 - 10 Tagaryen agents as Team A. Can be used to test your team against dummy agents if you are Team B.
Evaluating Game Results
There are two useful tools for you to see how your agents did in a game. They are: