Configuration Files

Using Existing Configuration Files

System configuration files are located at conf/sys/. The metadata of the system configureations will be introduced here.

Detection Area Configuration

  • area : It defines the detection areas for perception module.

    • id: For each area we define a unique id.

    • description : The area's description.

    • offset : The position in the upper left corner of the detection area.

    • size : The height and width of the detection area.

The areas' information is shown as the follow figure:(TODO: The figure.)

{
    "ver": "08",
    "area": [
        {
            "id": "0",
            "description": "Main Game Area",
            "offset": [0, 0],
            "size": [640, 480]
        }
    ]
}

Game Information Configuration

  • windowTitle: The window's title of the game.

  • windowSize: A list that contains all of the allowed window size.

  • mode: It defines the initial information (see the example below) of different mode. Plan to support custom practice such as thprac.

{
    "ver": "08",
    "windowTitle": "東方永夜抄 ~ Imperishable Night.",
    "windowSize": [
        [640, 480]
    ],
    "mode": [
        {
            "id": "0",
            "description": "Story Mode",
            "initInfo": {
                "stage": 1,
                "lives": 3,
                "bombs": 2,
                "power": 0,
                "score": 0
            }
        }
    ]
}

Resource Configuration

  • resource: The resource information.

    • For each item, dir is the directory of the resource. TODO: type's discription.

{
    "ver": "08",
    "resource": {
        "character": [
            {
                "dir": "xxx",
                "type": "PLAYER",
                "id": "0",
                "description": "Reimu"
            }
        ],
        "bullet": [
            {
                "dir": "xxx",
                "type": "ENEMY",
                "id": "0",
                "description": "Red Bullet"
            }
        ]
    }
}

Creating Your Own Configuration File

Create your configuration files in the conf/ directory. It contains various configurations in JSON format. We suggest you name your file as _<config_name>.json with the following structure:

{
    "thxx": {
        "ver": "xx",
        "other_data": "value"
    }
}

Then you can use the configuration file by decorating your class with @config_loader(<config_file>) and @register_config(<config_name>):

from src.config.config import BaseConfig, config_loader, register_config

@config_loader("your_config_file")
@register_config("your_config_name")
class YourConfig(BaseConfig):
   pass # You don't need to implement anything here, just inherit from BaseConfig

Check the Config section for more details on how to use the configuration files.

Last updated