Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
Alexandru Dan edited this page Aug 30, 2017 · 23 revisions

This part of the code has not yet been merged, but is fully supported by the AIMMO Unity project. The relevant pull requests are(in order) #220 and #224.

Extensible Level Generation Architecture

The intention of the level generation is to be as separate as possible from the rest of the AI:MMO implementation. The reason behind is that level requirements might change a lot on the way, so we want a as loosely as possible coupled module as part of the game logic.

Base Generator

The main class that gets exposed to the Django application is the JSONLevelGenerator, which implements the interface exposed by the BaseGenerator.

The BaseGenerator has the following template:

  • contructor(setting)
    • a set of basic settings that the map uses at generation
    • see DEFAULT_LEVEL_SETTINGS in simulation.world_map
  • get_game_state(avatar_manager)
    • exposes a game state used by the turn manager daemon
    • for details see Game State
  • check_complete(game_state)
    • returns false by default, should be overrided when inheriting
    • function to check if a map is "complete"
    • the turn manager runs the action for each avatar, then runs check_complete afterwards
  • get_map (@abstract)
    • returns the generated map

EmptyMapGenerator

Generates a centered empty map by the width and height. Can also generate an empty map by given corners.

JSONLevelGenerator

The JSON level generators generates a map in stages, receiving a JSON input map and a list of decoders that can modify the exposed map to the internal game classes. A complete reference of how the internals work can be found in World Map and Game Objects wikis.

Workflow:

  • setup the metadata: map dimensions, etc.
  • register the JSON that represents the map
  • register the decoders that transform the JSONs into WorldMap objects
  • decode the map applying the decoder to each of the JSONs

To register a level extend this class, this class is extended. All the levels described in the .txt and .json formats found in the levels folder are automatically imported.

Level Formats

Back-end levels (in folders maps and models)

Unity levels (in folder json)

Level Exposure to the map generator

Clone this wiki locally