snake
view snake.py @ 127:8b332ca44e25
save changes
author | Alex Martynov <martiran@kodomo.fbb.msu.ru> |
---|---|
date | Mon, 20 Dec 2010 15:50:05 +0300 |
parents | 10d32d7755ff |
children | bc310be50e73 |
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 """
137 """True if the rule applies in the field at position (x,y)."""
148 """Rotate rule pattern to head in `direction`."""
151 return
156 """Rotate rule pattern one time counterclockwise."""
165 # vim: set ts=4 sts=4 sw=4 et: