-
Notifications
You must be signed in to change notification settings - Fork 48
Creating Level Generators
You can create a level generator by creating a class called LevelGenerator.java that inherits from core.generator.AbstractLevelGenerator.java. The class should implement two essential functions:
- public LevelGenerator(GameDescription game, ElapsedCpuTimer elapsedTimer): constructor function to initialize any data that will be used during the level generation.
- public String generateLevel(GameDescription game, ElapsedCpuTimer elapsedTimer): this function is responsible for generating a level for the supplied game. The generated level should be returned in form of string where each character should be from the level mapping section.
Also you can use your own level mapping but you need to implement the following function:
- public HashMap<Character, ArrayList<String>> getLevelMapping(): this function should return a hashmap that helps decode the current generated level.
Both required functions are supplied with the following objects:
- GameDescription game: The GameDescription is a class that allows querying about the current game sprites such as avatar sprites (getAvatar()), movable sprites (getMoving()), ...etc. Also, you can get the interaction between any two sprites (getInteraction(String stype1, String stype2)), available actions for the agent (getAvailableActions()), termination conditions (getTerminationConditions()), level mapping (getLevelMapping()), and forward model to use it to test a certain level (testLevel(String level)).
- ElapsedCpuTimer elapsedTimer: The ElapsedCpuTimer is a class that allows querying for the remaining CPU time the generator has to return a level. You can query for the number of milliseconds passed since the method was called (elapsedMillis()) or the remaining time until the timer runs out (remainingTimeMillis()). Exiting these functions after the timer has finished (when remainingTimeMillis() ≤ 0) would make this generator to be disqualified in the game being played.
The generateLevel function should return a string that describe the generated level. The number of rows describe the height of the level, while the maximum length of the row is considered the width of the level. Each character describes all the objects positioned at this tile position. The characters can be decoded using the level mapping supplied by the GameDescription object. If you want to use your own characters you should supply a getLevelMapping function.
The next pages show some sample level generators that could be found with the framework:
-
GVG Framework
- Tracks Description
- Code Structure
- Creating Controllers
- Creating Multi Player Controllers
- Creating Level Generators
- Running & Testing Level Generators
- Creating Rule Generators
- Running & Testing Rule Generators
-
Forward Model and State Observation
- Advancing and copying the state
- Advancing and copying the state (2 Player)
- Querying the state of the game
- Querying the state of the game (2 Player)
- Information about the state of the Avatar
- Information about the state of the Avatar (2 Player)
- Information about events happened in the game
- Information about other sprites in the game
- Game Description Class
- Constraints
- Game Analyzer Class
- Level Analyzer Class
- Sprite Level Description Class
- Sprite, Termination, and Interaction Data Class
- Level Mapping Class
- Competition Specifications
- VGDL Language