Final Project (CS 4731): Mario Level Generation

Procedural Content Generation is the use of algorithm (procedures) to create novel, and sometimes customized, game content from scratch. Examples of PCG include generation of levels, maps, tree, cityscapes, weapons, monsters, and quests. PCG is often used as a design-time tool to roughly sketch out level content to be refined by human designers. PCG can also be done at run-time to incorporate individual player differences such as skills or preferences. In this project, we look at run-time PCG to create Mario Bros. game levels customized to individual players’ play styles. This includes (a) learning a model of the player’s play style, and (b) using the model to create a custom level. Fortunately, the first part is already done for you. You must focus on designing and implementing algorithms that use the player information to create something that will evaluate well.

This project will be using the 2011 IEEE Super Mario Bros. Competition infrastructure (Level Generation Track). The description of the competition and some documentation can be found there.

You will write a procedural content generator in the provided Mario Bros. game engine that will read in a player profile and customize a level to the profile. A player profile contains data about a player, such as number of coins collected, number of deaths, etc. The data is in raw format, so the level generator will need to make sense of the data and then use it accordingly. You will implement an optimization algorithms (simulated annealing, genetic algorithm, etc.) to tune the layout of the Mario Bros. level to data given about a specific player.


What you need to know

The Mario Bros. engine is written in Java. You will find the source code in the src/ directory.

dk.itu.mario.level.generator.MyLevelGenerator:

The generateLevel() function receives player data (as a GamePlay object called playerMetrics) and instantiates a new Level object. The actual level generation is done in MyLevel.

You may change MyLevelGenerator as necessary.

dk.itu.mario.level.MyLevel:

A Level object. The creat() function is responsible for the actual layout of the level terrain through calls to setBlock(). A Mario level is a grid where each location either contains a block (of a certain type) or empty space. MyLevel creates a repeating pattern of straight, straight with hill, pit, straight with tubes, straight with cannons. It is provided as an example of how a level can be generated somewhat randomly, and should be altered to use the player data. MyLevel also contains a number of example helper functions that create terrain features such as hills and instantiate monsters.

MyLevel does not natively use the player data (the GamePlay object). You will need to completely rewrite MyLevel to use the player data.

dk.itu.mario.MarioInterface.GamePlay:

This is a class that holds the player profile. It stores data about the player such as the player's last completion time, number of jumps, number of ducks, coins collected, etc. The GamePlay object is created from the player.txt file, which is a binary serialization of a GamePlay object.

dk.itu.mario.level.RandomLevel:

A random level generator.

dk.itu.mario.level.CustomizedLevel:

An example level generator that uses some simple statistics on the player profile to make level design choices. CustomizedLevel biases the randomization.


Instructions

You must implement an optimization algorithm such as simulated annealing, genetic algorithm, etc. that reads in data from a player profile and designs a level customized to that player.

Step 1: Acquire and install apache ant (http://ant.apache.org/).

Step 2: Unzip MarioLevelComp2011_cs4731.zip. In the MarioLevelComp2011_cs4731 directory, build the game engine:

Step 3: Modify the following files: MarioLevelComp2011_cs4731/src/dk/itu/mario/level/MyLevel.java and MarioLevelComp2011_cs4731/src/dk/itu/mario/level/generator/MyLevelGenerator.java.

Step 4: Run your level generator from the MarioLevelComp2011_cs4731 directory:

Step 5: Write a short document explaining:

The document should be at least three pages (1-inch margins, 12-point font).


Hints

You can look at RandomLevel.java and CustomizedLevel.java for examples on how to produce simple level generators for Mario Bros. Since neither technique uses optimization, do not take the examples too literally.

The player profile is stored in player.txt. To create a new player profile: java -cp bin dk.itu.mario.engine.Play. The player.txt file will be updated when Mario reaches the end of the level. You can create different profiles by jumping a lot, dying a lot, collecting a lot of coins, etc. Test your level generator by creating different profiles and verifying that the levels that are generated make sense based on the data.

In most cases, you can take player data such as times jumped as an indication that the level should be built to encourage more (or less) jumping. For some data points, such as deaths, you will want to make design decisions that reduce the number of deaths if the number of deaths is high or increase the number of deaths if the number is low.

Consider trying to identify baselines for certain data points. For example, what is an average number of deaths? Compare the player profile to the average to determine if the player dies too often or not often enough. This can apply to other data points too.


Grading

Submissions will be graded by hand by the instructor and teaching assistants. We will input a number of player profiles into your level generator and play the game to verify that there are changes to the levels and that the levels make sense.

Grading will rely heavily on the written document to indicate what to look for for different data points. The extent to which the document is thorough and clear will result in less guess-work by the graders.


Submission

To submit your solution, upload your modified MyLevel.java and MyLevelGenerator.java, and write-up.

DO NOT upload the entire game engine.