snake
view snake.py @ 57:2f62804e21fc
Added example snake
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 00:03:35 +0300 |
parents | eb11f45839ee |
children | 27a43636ab6e |
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 """
39 break
44 """Mark every cell in `self.cells` as belonging to self."""
51 return
54 """Rule defining possible behaviour of snake."""
63 }
71 """Load rule definition from file. Ignore any leading empty lines."""
76 continue
78 break
86 """Parse definition of cell in rule file.
88 Cell is defined by one character.
89 """
105 """True if the rule applies in the field at position (x,y)."""
117 """Rotate rule pattern `rot` times counterclockwise."""
122 """Rotate rule pattern one time counterclockwise."""
131 # vim: set ts=4 sts=4 sw=4 et: