snake
view snake.py @ 104:c68b54a43501
Rule.rotate now accepts target direction, not number of times to rotate
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 11:22:26 +0300 |
parents | c5d26c93437c |
children | 7352863453bc 9486211ec334 |
line source
1 """Guts of snakes."""
6 """Remove comments and junk spaces from line of snake definition file."""
13 """Snakes.
15 Attributes:
17 - `cells` -- list of cells belonging to the snake The first of these cells
18 becomes head, the last one becomes tail, the rest ar body. If snake has
19 only one cell, it is tail.
20 - `color` -- color of snake
21 - `rules` -- a list of Rule objects
22 """
30 """Load snake description from file.
32 See program design docs for file syntax.
33 """
36 break
41 break
46 """Mark every cell in `self.cells` as belonging to self."""
53 return
56 """Rule defining possible behaviour of snake."""
65 }
73 """Load rule definition from file.
75 Ignore any leading empty lines.
76 Return self.
77 """
82 continue
89 break
93 """Parse definition of cell in rule file.
95 Cell is defined by one character.
96 """
114 """True if the rule applies in the field at position (x,y)."""
126 """Rotate rule pattern to head in `direction`."""
129 return
134 """Rotate rule pattern one time counterclockwise."""
143 # vim: set ts=4 sts=4 sw=4 et: