snake
diff main.py @ 186:73aed6bf1caf
engine.legal_moves() now return list of legal moves
added UI.snake_move_check() - "passed"
changed name for UI.dead_snake_check() -> UI.snake_dead_check()
author | Alex Martynov |
---|---|
date | Tue, 28 Dec 2010 16:47:32 +0300 |
parents | 0cf4e42c75a1 |
children | 954cc2774637 |
line diff
1.1 --- a/main.py Tue Dec 28 16:36:23 2010 +0300 1.2 +++ b/main.py Tue Dec 28 16:47:32 2010 +0300 1.3 @@ -98,7 +98,7 @@ 1.4 if self.step_id > self.game_length: 1.5 self.end() 1.6 return 1.7 - if self.dead_snake_check() == False: 1.8 + if self.snake_dead_check() == False: 1.9 return 1.10 self.step_id = self.step_id+1 1.11 self.engine.step() 1.12 @@ -107,7 +107,7 @@ 1.13 1.14 def step (self): 1.15 """Do the next game step""" 1.16 - if self.dead_snake_check() == False: 1.17 + if self.snake_dead_check() == False: 1.18 return 1.19 if self.step_id == 0: 1.20 self.engine.psnakes = self.engine.snakes[:] 1.21 @@ -127,7 +127,7 @@ 1.22 self.canvas.after_cancel(self.after_id) 1.23 self.after_id = None 1.24 1.25 - def dead_snake_check(self): 1.26 + def snake_dead_check(self): 1.27 """Check the number of snakes alive. 1.28 End the game if alive snake number is less than two.""" 1.29 dead_snakes = 0 1.30 @@ -155,7 +155,11 @@ 1.31 elif len(snake.cells) == length: 1.32 winer.append(snake) 1.33 return winer, length 1.34 - 1.35 + 1.36 + def snake_move_check(self): 1.37 + """Get possible movements of the snakes. 1.38 + If all anakes cant move - return False.""" 1.39 + pass 1.40 1.41 def restart(self, survived): 1.42 """"Restarts snakes positions after the end of the game