本文整理汇总了Python中Engine.isOnOddRow方法的典型用法代码示例。如果您正苦于以下问题:Python Engine.isOnOddRow方法的具体用法?Python Engine.isOnOddRow怎么用?Python Engine.isOnOddRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Engine
的用法示例。
在下文中一共展示了Engine.isOnOddRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getJumpPosition
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import isOnOddRow [as 别名]
def getJumpPosition(self, position, middlePosition):
# On odd rows, the square on the right is not at position - 4
# On even rows, the square on the right is at position - 4
isSkippingRight = Engine.isOnOddRow(position) != (position - middlePosition == 4)
distanceToNextPosition = 7 if isSkippingRight else 9
finalPosition = position - distanceToNextPosition
return finalPosition
示例2: validMoves
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import isOnOddRow [as 别名]
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
示例3: test_isOnOddRow_returnsFalse_forEvenRows
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import isOnOddRow [as 别名]
def test_isOnOddRow_returnsFalse_forEvenRows(self, value):
self.assertFalse(Engine.isOnOddRow(value))
示例4: test_isOnOddRow_returnsTrue_forOddRows
# 需要导入模块: import Engine [as 别名]
# 或者: from Engine import isOnOddRow [as 别名]
def test_isOnOddRow_returnsTrue_forOddRows(self, value):
self.assertTrue(Engine.isOnOddRow(value))