snake
view snake.py @ 184:59c2be771f94
added the color presentation of the winer snake
author | Alex Martynov |
---|---|
date | Sun, 26 Dec 2010 22:35:19 +0300 |
parents | cfe29cb793eb |
children |
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
70 """Mark every cell in `self.cells` as belonging to self."""
74 return
81 """Rule defining possible behaviour of snake."""
90 }
98 """Load rule definition from file.
100 Ignore any leading empty lines.
101 Return self.
102 """
107 continue
114 break
118 """Parse definition of cell in rule file.
120 Cell is defined by one character.
121 """
141 """True if the rule applies in the field at position (x,y)."""
152 """Rotate rule pattern to head in `direction`."""
155 return
160 """Rotate rule pattern one time counterclockwise."""
169 # vim: set ts=4 sts=4 sw=4 et: