예제 #1
0
 def moves(self):
     positions = [
         new_pos(self.pos, up=2, right=1),
         new_pos(self.pos, up=1, right=2),
         new_pos(self.pos, up=2, left=1),
         new_pos(self.pos, up=1, left=2),
         new_pos(self.pos, down=2, right=1),
         new_pos(self.pos, down=1, right=2),
         new_pos(self.pos, down=2, left=1),
         new_pos(self.pos, down=1, left=2),
     ]
     return [Move(self.pos, pos) for pos in positions if self._valid_pos(pos)]
예제 #2
0
    def moves(self):
        valid_positions = []
        pos_in_front = None
        diagonals = None
        if self.colour == Colour.WHITE:
            pos_in_front = new_pos(self.pos, up=1)
            diagonals = [
                new_pos(self.pos, up=1, right=1),
                new_pos(self.pos, up=1, left=1)
            ]
        else:
            pos_in_front = new_pos(self.pos, down=1)
            diagonals = [
                new_pos(self.pos, down=1, right=1),
                new_pos(self.pos, down=1, left=1)
            ]

        if self._front_pos_valid(pos_in_front):
            valid_positions.append(Move(self.pos, pos_in_front))

        valid_positions.extend([
            Move(self.pos, pos) for pos in diagonals
            if self._diagonal_valid(pos)
        ])
        return valid_positions