snake
view snake.py @ 134:8e75e931bfd2
example.snake: better rules for chasing enemy tail
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 17:01:39 +0300 |
parents | bc310be50e73 |
children | cd7658cb90eb |
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."""
72 return
79 """Rule defining possible behaviour of snake."""
88 }
96 """Load rule definition from file.
98 Ignore any leading empty lines.
99 Return self.
100 """
105 continue
112 break
116 """Parse definition of cell in rule file.
118 Cell is defined by one character.
119 """
139 """True if the rule applies in the field at position (x,y)."""
150 """Rotate rule pattern to head in `direction`."""
153 return
158 """Rotate rule pattern one time counterclockwise."""
167 # vim: set ts=4 sts=4 sw=4 et: