snake
view snake.py @ 70:e8eabd9530a1
snake.Rule.load returns self for convenience
author | Danya Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 00:43:36 +0300 |
parents | 2d4b7e24d914 |
children | ae4bbffb80fe 2ca1c6a7561a |
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 """
112 """True if the rule applies in the field at position (x,y)."""
124 """Rotate rule pattern `rot` times counterclockwise."""
129 """Rotate rule pattern one time counterclockwise."""
138 # vim: set ts=4 sts=4 sw=4 et: