本文整理汇总了Python中piece.Piece.getState方法的典型用法代码示例。如果您正苦于以下问题:Python Piece.getState方法的具体用法?Python Piece.getState怎么用?Python Piece.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类piece.Piece
的用法示例。
在下文中一共展示了Piece.getState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getValidMoves
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import getState [as 别名]
def getValidMoves(self):
ret = [
# One space away
(self.x, self.y+2),
(self.x, self.y-2),
(self.x-1, self.y-1),
(self.x-1, self.y+1),
(self.x+1, self.y-1),
(self.x+1, self.y+1),
# Two spaces away
(self.x, self.y+4),
(self.x, self.y-4),
(self.x+1, self.y+3),
(self.x+1, self.y-3),
(self.x-1, self.y+3),
(self.x-1, self.y-3),
(self.x-2, self.y),
(self.x+2, self.y),
(self.x+2, self.y-2),
(self.x+2, self.y+2),
(self.x-2, self.y-2),
(self.x-2, self.y+2)
]
ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
ret = filterBlockedSpots(ret, Piece.getState())
ret.append((self.x, self.y))
return ret
示例2: getValidMoves
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import getState [as 别名]
def getValidMoves(self):
ret = [ # Static list is easy
(self.x, self.y+2),
(self.x, self.y-2),
(self.x-1, self.y-1),
(self.x-1, self.y+1),
(self.x+1, self.y-1),
(self.x+1, self.y+1)
]
ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
ret = filterBlockedSpots(ret, Piece.getState())
ret.append((self.x, self.y))
return ret
示例3: getValidAttacks
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import getState [as 别名]
def getValidAttacks(self):
ret = [ # Static list is easy. Keep this sorted in order by direction
(self.x, self.y-2), # 0
(self.x+1, self.y-1), # 1
(self.x+1, self.y+1), # 2
(self.x, self.y+2), # 3
(self.x-1, self.y+1), # 4
(self.x-1, self.y-1) # 5
]
ret2 = [
# Two spaces away
(self.x, self.y-4), # 0
(self.x+1, self.y-3), # 0.5
(self.x+2, self.y-2), # 1
(self.x+2, self.y), # 1.5
(self.x+2, self.y+2), # 2
(self.x+1, self.y+3), # 2.5
(self.x, self.y+4), # 3
(self.x-1, self.y+3), # 3.5
(self.x-2, self.y+2), # 4
(self.x-2, self.y), # 4.5
(self.x-2, self.y-2), # 5
(self.x-1, self.y-3) # 5.5
]
# Get current dir + other two adjacent ones
ret = [
# One square away
ret[self.direction],
ret[(self.direction+1)%6],
ret[(self.direction-1)%6],
# Two squares away
ret2[self.direction*2],
ret2[(self.direction*2+1)%12],
ret2[(self.direction*2+2)%12],
ret2[(self.direction*2-1)%12],
ret2[(self.direction*2-2)%12],
]
# Filter to only spots on board and that are blocked
ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
ret = filterUnblockedSpots(ret, Piece.getState())
ret = filterMyPieces(ret, Piece.getState(), self.player)
# NOTE: Currently possible to attack your own troops
return ret
示例4: getValidAttacks
# 需要导入模块: from piece import Piece [as 别名]
# 或者: from piece.Piece import getState [as 别名]
def getValidAttacks(self):
ret = [ # Static list is easy. Keep this sorted in order by direction
(self.x, self.y-2), # 0
(self.x+1, self.y-1), # 1
(self.x+1, self.y+1), # 2
(self.x, self.y+2), # 3
(self.x-1, self.y+1), # 4
(self.x-1, self.y-1) # 5
]
# Get current dir + other two adjacent ones
ret = [ret[self.direction],
ret[(self.direction+1)%6],
ret[(self.direction-1)%6]]
# Filter to only spots on board and that are blocked
ret = filterValidSpots(ret, Piece.getState().getWidth(), Piece.getState().getHeight())
ret = filterUnblockedSpots(ret, Piece.getState())
ret = filterMyPieces(ret, Piece.getState(), self.player)
# NOTE: Currently possible to attack your own troops
return ret