summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Ward <peteraward@gmail.com>2012-07-19 20:10:40 +1000
committerPeter Ward <peteraward@gmail.com>2012-07-19 20:10:40 +1000
commit3288b71967a6baf2ae77faeb244bc2332484e8d4 (patch)
treedc351d7c766f73b6e43798b477cfb8970bdb6108
parent93ba106c94b7a2d2109842432fed3dbe920c3558 (diff)
Add packaging.
-rw-r--r--README86
-rw-r--r--setup.py11
-rw-r--r--snakegame/__init__.py0
3 files changed, 97 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..97e7b5b
--- /dev/null
+++ b/README
@@ -0,0 +1,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]
+ ]
+ }
+ }
+}
+
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..9c07911
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,11 @@
+from setuptools import setup
+
+setup(
+ name='SnakeGame',
+ version='1.0',
+ description='The game of Snake, for beginner AI bot writers.',
+ author='Peter Ward',
+ author_email='peteraward@gmail.com',
+ packages=['snakegame'],
+ scripts=[],
+)
diff --git a/snakegame/__init__.py b/snakegame/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/snakegame/__init__.py