snake
view snake.py @ 124:bc310be50e73
pattern cell always has snake_type
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 15:48:15 +0300 |
parents | a8549a69f959 |
children | cfe29cb793eb |
line source
1 """Guts of snakes."""
6 """Remove comments and junk spaces from line of snake definition file."""
13 """Wrapper around file that saves the current line number."""
27 """Snakes.
29 Attributes:
31 - `cells` -- list of cells belonging to the snake The first of these cells
32 becomes head, the last one becomes tail, the rest ar body. If snake has
33 only one cell, it is tail.
34 - `color` -- color of snake
35 - `rules` -- a list of Rule objects
36 """
44 """Load snake description from file.
46 See program design docs for file syntax.
47 """
55 """Actually do the loading."""
58 break
63 break
68 """Mark every cell in `self.cells` as belonging to self."""
75 return
78 """Rule defining possible behaviour of snake."""
87 }
95 """Load rule definition from file.
97 Ignore any leading empty lines.
98 Return self.
99 """
104 continue
111 break
115 """Parse definition of cell in rule file.
117 Cell is defined by one character.
118 """
138 """True if the rule applies in the field at position (x,y)."""
149 """Rotate rule pattern to head in `direction`."""
152 return
157 """Rotate rule pattern one time counterclockwise."""
166 # vim: set ts=4 sts=4 sw=4 et: