Exemplo n.º 1
0
    def validMoves(self, position):
        """returns positions of valid moves for a regular red gamepiece on an empty board"""

        moves = []
        if Engine.isOnTopRow(position):
            moves = []
        elif Engine.isOnRightEdge(position) or Engine.isOnLeftEdge(position):
            # Edges only have one valid move
            moves = [position - 4]
        elif Engine.isOnOddRow(position):
            # diagonals above pieces on odd rows are always 4 and 5 pieces after
            moves = [position - 4, position - 3]
        elif Engine.isOnEvenRow(position):
            # diagonals below pieces on even rows are always 3 and 4 piececs after
            moves = [position - 5, position - 4]
        return moves
Exemplo n.º 2
0
 def canBePromoted(self, position): return Engine.isOnTopRow(position)
 """Red Pieces can be promoted when they're on the top row"""
Exemplo n.º 3
0
 def test_isOnTopRow_returnsFalse_forNonTopsRows(self, value):
     self.assertFalse(Engine.isOnTopRow(value))
Exemplo n.º 4
0
 def test_isOnTopRow_returnsTrue_forTopRow(self, value):
     self.assertTrue(Engine.isOnTopRow(value))