Exemple #1
0
    def validMoves(self, position):
        """returns positions of valid moves for a regular black gamepiece on an empty board"""

        moves = []
        if Engine.isOnBottomRow(position):
            moves = []
        elif Engine.isOnRightEdge(position) or Engine.isOnLeftEdge(position):
            # Edges only have one valid move
            moves = [position + 4]
        elif Engine.isOnOddRow(position):
            # diagonals below pieces on odd rows are always 4 and 5 pieces after
            moves = [position + 4, position + 5]
        elif Engine.isOnEvenRow(position):
            # diagonals below pieces on even rows are always 3 and 4 piececs after
            moves = [position + 3, position + 4]
        return moves
Exemple #2
0
 def canBePromoted(self, position): return Engine.isOnBottomRow(position)
 """Black pieces can be promoted when they're on the bottom row"""
Exemple #3
0
 def test_isOnBottomRow_returnsFalse_forNonBottomRows(self, value):
     self.assertFalse(Engine.isOnBottomRow(value))
Exemple #4
0
 def test_isOnBottomRow_returnsTrue_forBottomRows(self, value):
     self.assertTrue(Engine.isOnBottomRow(value))