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
def canBePromoted(self, position): return Engine.isOnBottomRow(position) """Black pieces can be promoted when they're on the bottom row"""
def test_isOnBottomRow_returnsFalse_forNonBottomRows(self, value): self.assertFalse(Engine.isOnBottomRow(value))
def test_isOnBottomRow_returnsTrue_forBottomRows(self, value): self.assertTrue(Engine.isOnBottomRow(value))