Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/snake/annotate/17f615088ed6/snake.py
Дата изменения: Unknown
Дата индексирования: Fri Feb 28 20:49:02 2014
Кодировка:
snake: snake.py annotate

snake

annotate snake.py @ 33:17f615088ed6

half of snake.Snake.load()
author Alex Martynov <martiran@kodomo.fbb.msu.ru>
date Sun, 19 Dec 2010 21:55:52 +0300
parents b2eaeeb74d87
children 8f8af9ef99e6
rev   line source
martiran@30 1 class Snake(object):
martiran@30 2 def __init__ (self, cells, color):
martiran@32 3 self.cells = cells
martiran@32 4 self.color = color
martiran@32 5 self.rules = []
martiran@32 6 pass
martiran@30 7 def load (self, file_name):
martiran@33 8 snake_file = open(file_name, "r")
martiran@33 9 line = snake_file.readline()
martiran@33 10 if line.partition(' ')[0] == 'snake':
martiran@33 11 self.name = line.partition(' ')[2]
martiran@33 12 for line in snake_file:
martiran@33 13 if line.partition('\\')[0] == ('' or '\n'):
martiran@33 14 continue
martiran@33 15 else:
martiran@33 16 if line.partition(';')[0] != ''
martiran@33 17
martiran@32 18 pass
martiran@30 19 def fill (self):
martiran@30 20 for cell in self.cells:
martiran@32 21 cell.snake = self
martiran@32 22 snake.cells[0].type = 'head'
martiran@31 23 snake.cells[-1].type = 'tail'
martiran@31 24 snake.cells[1:-1].type = 'body'
martiran@31 25 return
martiran@31 26 def error (self):
martiran@33 27 pass
martiran@33 28
martiran@30 29
martiran@30 30 class Rule(object):
martiran@30 31 def __init__ (self, snake):
martiran@32 32 self.snake = snake
martiran@32 33 self.direction = (1, -1)
martiran@32 34 pass
martiran@30 35 def load (self, file, line):
martiran@33 36
martiran@32 37 pass
martiran@30 38 def applies (self, field, x, y):
martiran@32 39
martiran@32 40 pass
martiran@30 41 def rotate (self, rot):
martiran@32 42 pass
martiran@30 43