Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://kodomo.cmm.msu.ru/trac/snake/changeset/186
Äàòà èçìåíåíèÿ: Unknown
Äàòà èíäåêñèðîâàíèÿ: Sun Apr 10 17:49:01 2016
Êîäèðîâêà: IBM-866
Changeset 186:73aed6bf1caf òÀÓ Python Battle

Changeset 186:73aed6bf1caf


Ignore:
Timestamp:
12/28/10 16:47:32 (5 years ago)
Author:
Alex Martynov
Branch:
default
Message:

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()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • engine.py

    r185 r186 ˆà
    246246    ˆà
    247247    def legal_moves(self, snake):ˆà
    248ˆà        """Check for snake legal move directions according to the game rules."""ˆà
    ˆà248        """Check for snake legal move directions according to the game rules.ˆà
    ˆà249        Return:ˆà
    ˆà250        list of legal moves"""ˆà
    249251        snake.legal_dir = []ˆà
    250252        head = snake.cells[0]ˆà
    òÀæ òÀæ ˆà
    254256                snake.legal_dir.append(direction)ˆà
    255257        rnd.shuffle(snake.legal_dir)ˆà
    256ˆà        returnˆà
    257ˆàˆà
    ˆà258        return snake.legal_dirˆà
    ˆà259ˆà
  • main.py

    r185 r186 ˆà
    9999            self.end()ˆà
    100100            returnˆà
    101ˆà        if self.dead_snake_check() == False:ˆà
    ˆà101        if self.snake_dead_check() == False:ˆà
    102102            returnˆà
    103103        self.step_id = self.step_id+1ˆà
    òÀæ òÀæ ˆà
    108108    def step (self):ˆà
    109109        """Do the next game step"""ˆà
    110ˆà        if self.dead_snake_check() == False:ˆà
    ˆà110        if self.snake_dead_check() == False:ˆà
    111111            returnˆà
    112112        if self.step_id == 0:ˆà
    òÀæ òÀæ ˆà
    128128            self.after_id = Noneˆà
    129129    ˆà
    130ˆà    def dead_snake_check(self):ˆà
    ˆà130    def snake_dead_check(self):ˆà
    131131        """Check the number of snakes alive.ˆà
    132132        End the game if alive snake number is less than two."""ˆà
    òÀæ òÀæ ˆà
    156156                    winer.append(snake)    ˆà
    157157        return winer, lengthˆà
    158ˆà        ˆà
    ˆà158ˆà
    ˆà159    def snake_move_check(self):ˆà
    ˆà160        """Get possible movements of the snakes.ˆà
    ˆà161        If all anakes cant move - return False."""ˆà
    ˆà162        passˆà
    159163        ˆà
    160164    def restart(self, survived):ˆà
Note: See TracChangeset for help on using the changeset viewer.