snake
view snake.py @ 109:7352863453bc
snake.*.load now reports the line number of error
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Mon, 20 Dec 2010 12:50:42 +0300 |
parents | c68b54a43501 |
children | 2d048c0ed5e3 4cafedd51b69 |
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."""
24 """Snakes.
26 Attributes:
28 - `cells` -- list of cells belonging to the snake The first of these cells
29 becomes head, the last one becomes tail, the rest ar body. If snake has
30 only one cell, it is tail.
31 - `color` -- color of snake
32 - `rules` -- a list of Rule objects
33 """
41 """Load snake description from file.
43 See program design docs for file syntax.
44 """
52 """Actually do the loading."""
55 break
60 break
65 """Mark every cell in `self.cells` as belonging to self."""
72 return
75 """Rule defining possible behaviour of snake."""
84 }
92 """Load rule definition from file.
94 Ignore any leading empty lines.
95 Return self.
96 """
101 continue
108 break
112 """Parse definition of cell in rule file.
114 Cell is defined by one character.
115 """
133 """True if the rule applies in the field at position (x,y)."""
145 """Rotate rule pattern to head in `direction`."""
148 return
153 """Rotate rule pattern one time counterclockwise."""
162 # vim: set ts=4 sts=4 sw=4 et: