1 | |
---|
2 | classˆàSnake(object): |
---|
3 | ˆà ˆà defˆà__init__ˆà(self,ˆàcells,ˆàcolor): |
---|
4 | ˆà ˆà ˆà ˆà self.cells =ˆàcells |
---|
5 | ˆà ˆà ˆà ˆà self.color =ˆàcolor |
---|
6 | ˆà ˆà ˆà ˆà self.rules =ˆà[] |
---|
7 | ˆà ˆà ˆà ˆà pass |
---|
8 | ˆà ˆà defˆàloadˆà(self,ˆàfile_name): |
---|
9 | ˆà ˆà ˆà ˆà snake_file =ˆàopen(file_name,ˆà"r") |
---|
10 | ˆà ˆà ˆà ˆà line =ˆàsnake_file.readline() |
---|
11 | ˆà ˆà ˆà ˆà ifˆàline.partition(' ')[0]ˆà==ˆà'snake': |
---|
12 | ˆà ˆà ˆà ˆà ˆà ˆà self.name =ˆàline.partition(' ')[2] |
---|
13 | ˆà ˆà ˆà ˆà ˆà ˆà forˆàline inˆàsnake_file: |
---|
14 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàline.partition('\\')[0]ˆà==ˆà(''ˆàorˆà'\n'): |
---|
15 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà continue |
---|
16 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà else: |
---|
17 | ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ˆà ifˆàline.partition(';')[0]ˆà!=ˆà'' |
---|
18 | ˆà ˆà ˆà ˆà |
---|
19 | ˆà ˆà ˆà ˆà pass |
---|
20 | ˆà ˆà defˆàfillˆà(self): |
---|
21 | ˆà ˆà ˆà ˆà forˆàcell inˆàself.cells: |
---|
22 | ˆà ˆà ˆà ˆà ˆà ˆà cell.snake =ˆàself |
---|
23 | ˆà ˆà ˆà ˆà snake.cells[0].type =ˆà'head' |
---|
24 | ˆà ˆà ˆà ˆà snake.cells[-1].type =ˆà'tail' |
---|
25 | ˆà ˆà ˆà ˆà snake.cells[1:-1].type =ˆà'body' |
---|
26 | ˆà ˆà ˆà ˆà return |
---|
27 | ˆà ˆà defˆàerrorˆà(self): |
---|
28 | ˆà ˆà ˆà ˆà pass |
---|
29 | |
---|
30 | |
---|
31 | classˆàRule(object): |
---|
32 | ˆà ˆà defˆà__init__ˆà(self,ˆàsnake): |
---|
33 | ˆà ˆà ˆà ˆà self.snake =ˆàsnake |
---|
34 | ˆà ˆà ˆà ˆà self.direction =ˆà(1,ˆà-1) |
---|
35 | ˆà ˆà ˆà ˆà pass |
---|
36 | ˆà ˆà defˆàloadˆà(self,ˆàfile,ˆàline): |
---|
37 | ˆà ˆà ˆà ˆà |
---|
38 | ˆà ˆà ˆà ˆà pass |
---|
39 | ˆà ˆà defˆàappliesˆà(self,ˆàfield,ˆàx,ˆày): |
---|
40 | ˆà ˆà ˆà ˆà |
---|
41 | ˆà ˆà ˆà ˆà pass |
---|
42 | ˆà ˆà defˆàrotateˆà(self,ˆàrot): |
---|
43 | ˆà ˆà ˆà ˆà pass |
---|