当前位置: 首页>>代码示例>>Python>>正文


Python Piece.getState方法代码示例

本文整理汇总了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
开发者ID:cddude229,项目名称:Gaveldor,代码行数:35,代码来源:cavalry.py

示例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
开发者ID:cddude229,项目名称:Gaveldor,代码行数:16,代码来源:infantry.py

示例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
开发者ID:cddude229,项目名称:Gaveldor,代码行数:51,代码来源:archer.py

示例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
开发者ID:cddude229,项目名称:Gaveldor,代码行数:25,代码来源:cavalry.py


注:本文中的piece.Piece.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。