summaryrefslogtreecommitdiff
path: root/README
blob: 97e7b5bd7a45948e791888fef002514bb06a2dd6 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
How to write a bot
==================

guarantee code indicates something you can run which will execute without errors
if "input" refers to a valid board.

input = {
    # the object you control

    # guarantee code:
    # me = input["whoami"]
    # my = input["objects"][me]
    # assert my["type"] == "snake"
    # (see below for more guarantees)

    "whoami": "a",

    # the board is by a torus by default (wraps around horiz & vert),
    # but maps will have walls on all the edges to disable this.

    # guarantee code:
    # for row in input["board"]:
    #     for item in row:
    #         assert item in input["objects"]

    "board": [
        ["W", "W", "W", "W", "W", "W"],
        ["W", " ", "*", " ", " ", "W"],
        ["W", "a", " ", "b", "b", "W"],
        ["W", " ", " ", " ", " ", "W"],
        ["W", "W", "W", "W", "W", "W"]
    ],

    # each object refers to a type of "thing" which can be in the board.

    # guarantee code:
    # for key, thing in input["objects"].items():
    #     if thing["type"] == "snake":
    #         assert "valid_moves" in thing
    #         x, y = thing["head"]
    #         assert input["board"][y][x] == key
    #     elif thing["type"] == "special":
    #         for effect in thing["effects"]:
    #             assert effect[0] in ("die", "grow")
    #     else:
    #         raise TypeError("invalid thing type")

    "objects": {
        "a": {
            "type": "snake",
            "head": [1, 2],
            "valid_moves": {
                "L": [0, 2],
                "R": [2, 2],
                "U": [1, 1],
                "D": [1, 3]
            }
        },

        "b": {
            "type": "snake",
            "head": [4, 2],
            "valid_moves": {
                "L": [3, 2],
                "R": [5, 2],
                "U": [4, 1],
                "D": [4, 3]
            }
        },

        "W": {
            "type": "special",
            "effects": [
                ["die"]
            ]
        },

        "*": { # represents an apple
            "type": "special",
            "effects": [
                ["grow", 1]
            ]
        }
    }
}