BWEM-community icon indicating copy to clipboard operation
BWEM-community copied to clipboard

Use CSV files for string test data

Open kant2002 opened this issue 6 years ago • 3 comments

As I state in Discord, CSV files allow other developer use dataset as baseline for testing their implementation on multiple maps. Currently verification data lives in the code itself, if place it in the CSV data files our work could be reused by others.

kant2002 avatar May 21 '18 07:05 kant2002

Instead of CSV, what about something more INI- or JSON-like?

For example, spitballing:

[general]
name = (2)Showdown.scx
tile_dimensions = 64, 192
walk_dimensions = 1024, 3072
center_position = 1024, 3072
altitude_limits = 0, 426

[resources]
number_geysers = 6
number_minerals = 46

[base 1]
starting_location = true
tile_location = 5, 10   ; making up numbers now
pixel_location = 150, 300
minerals = [7, 12, 1500], [7, 13, 1500], [8, 13, 1500], ...  ; tile position x, y, amount
geysers = ...
blocking_minerals = ...

[base 2]
tile_position = 60, 80
...

In a couple cases I have to shoehorn stuff into strings and section names that should maybe not be there. So with JSON:

{
    "tile_dimensions": [64, 192],
    "walk_dimensions": [1024, 3072],
    "center_position": [1024, 3072],
    "altitude_limits": [0, 426],

    "resources" : {
        "number_geysers": 6,
        "number_minerals": 46,
    },

    "bases": [
        {
            "starting_location": true,
            "tile_location": [5, 10],   // making up numbers now
            "pixel_location": [150, 300],
            "minerals": [
                { "tile_position": [7, 12], "amount": 1500},
                { "tile_position": [7, 13], "amount": 1500},
                { "tile_position": [8, 13], "amount": 1500},
            ],
            "geysers": [ ... ],
            "blocking_minerals": [ ... ];
        },
        {
                ...
        }
    ]
}

How does this sound as a general idea? Any preference to which of these options you like more? If you like the idea, any feedback on specific schemas?

EvanED avatar May 21 '18 16:05 EvanED

I do like approach with JSON. It relatively easy to author with shallow structure. I think every field which you write in JSON make sense. For bases this should be enough. /cc @n00byedge

kant2002 avatar May 21 '18 17:05 kant2002

The downside of the JSON format is it's more heavyweight to parse, probably requiring a third-party library (unless there's something already in BWAPI or BWEM I don't know about). I'd probably recommend nlohmann/json for that.

EvanED avatar May 21 '18 18:05 EvanED