Assignment 1: Super Mario Bros.

You can download our Java implementation of this game from the Git repository MarioAI. When you visit that page on GitHub, be sure to read the entire page – it has lots of useful information about the game, including a link to the API documentation.

You can load the Java sources into any major Java IDE. Especially if you are new to Java, I recommend Visual Studio Code. It is a lightweight IDE that works well with Java and many other languages, and I find it especially easy to use. Of course, if you prefer Eclipse or IntelliJ, they will work well too.

Quick start with Visual Studio Code

Here is the easiest way to get started on this assignment using Visual Studio Code:

1. Install the Java Development Kit (JDK). On Linux, you should get this from for your package manager. For example, on Ubuntu all you need to do is to install the default-jdk package. On macOS or Windows, go to Oracle's Java downloads page and download an installer from there.

2. Visit the Visual Studio Code page and download and install it.

3. Clone the MarioAI repository:

$ git clone git@github.com:medovina/MarioAI.git

4. Start Visual Studio Code.

5. Choose the File/Open Folder menu command. Navigate to the MarioAI directory generated by git clone and click OK.

6. In the Explorer area on the left, navigate to MarioAI4J/src/ch/idsia/RunMario.java. Double click the filename to open it.

7. In the lower right, you'll see a message

The 'Java' extension pack is recommended for this file type.

Click the Install button below this message. Wait a few moments for the install to complete.

8. Go back to RunMario.java. Above the line "public static void main" you will see

Run | Debug

Click Run. The game will launch, and you will be able to play it from the keyboard.

9. In the Explorer on the left, navigate to MarioAI4J-Playground/src/mario/MarioAgent.java and open it. This is the source file where you will write your agent code. Find the line "public static void main" and click the Run command above it. The dummy agent implementation will run.

If you run into problems or have questions, just let me know.

Quick start with IntelliJ IDEA

1. Install the Java Development Kit (JDK) and IntelliJ.

2. Clone the MarioAI repository:

$ git clone git@github.com:medovina/MarioAI.git

3. Start IntelliJ IDEA.

4. Choose Import Project.

5. Navigate to the MarioAI directory generated by git clone and click OK.

6. You will see a dialog "Import Project". At this point you have two choices: either (a) Create project from existing sources, or (b) Import project from external model (Eclipse). Both of these seem to generate a working project, so it may not matter which you choose. (Still, I suspect it might be best for this and future projects in this course to import from the Eclipse model, to be sure that IntelliJ will use the information in the Eclipse project files included in all these projects.)

7. Once the project import is complete, navigate in the sidebar on the left to MarioAI4J/src/ch.idsia/RunMario.

8. Right click it and choose 'Run RunMario.main()'. The game will launch, and you will be able to play it from the keyboard.

9. In the sidebar on the left, navigate to MarioAI4J-Playground/src/mario/MarioAgent and open it. This is the source file where you will write your agent code.

Earning points for this assignment

The game generates each level randomly, so your agent might succeed on some randomly generated levels and fail on others. I will evaluate your agent on a series of levels generated in several configurations:

Your agent succeeds if it makes it to the end of each level, and fails otherwise. Its success rate is the fraction of randomly generated levels on which it succeeds.

To see your agent once on any of the above levels, simply uncomment the level in main() in MarioAgent.java. To evaluate your agent's success rate, run the main() method in Evaluate.java, which will run your agent automatically (without a graphical interface) on many levels in succession.

This assignment is worth a total of 10 points. You can earn them as follows:

Do not forget that Mario can both jump and shoot! :)

For the tournament for this assignment we will use LEVEL_4_SPIKIES, which has hills, Goombas, pipes and Spikies. The winner will be the agent with the highest success rate on this level.

Note that none of these levels (even the tournament level) have Koopas (turtles), so you don't need to worry about them for this assignment.

By the way, last year the Mario tournament winner had a 78.0% success rate on LEVEL_4_SPIKIES. If you can beat that number (which is not easy), you should have excellent chances in this tournament!