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


Python Board.adjacent_cells方法代码示例

本文整理汇总了Python中Board.adjacent_cells方法的典型用法代码示例。如果您正苦于以下问题:Python Board.adjacent_cells方法的具体用法?Python Board.adjacent_cells怎么用?Python Board.adjacent_cells使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Board的用法示例。


在下文中一共展示了Board.adjacent_cells方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _approach

# 需要导入模块: import Board [as 别名]
# 或者: from Board import adjacent_cells [as 别名]
    def _approach (self, enemy, faceTorsoEnemy):
        i = 0
        x = 0
        while True:
            x = Board.adjacent_cells(enemy, (faceTorsoEnemy+i)%6, self.board)
            i += 1
            if (not x in self.mechs.enemys_cell()) and x != 0: break
        pf = pathfinder.PathFinder(self.board.successors, self.board.move_cost, self.board.heuristic_to_goal)
        A = Pos(self.playerCell, self.playerFace)
        B = Pos(x, Board.facing_side(x, enemy))
        if A == B: return ([], 3)

        path, can, cost = pf.compute_path_until_PM (A, B, 0, self.player.walk)

        if can == False and self.player.run != 0:
            path2, can2, cost2 = pf.compute_path_until_PM(A, B, 1, self.player.run)

            if can2 == True:
                return (path2, 1)
        if can == False and self.player.jump != 0:
            print "ESTO K ES!: walk then jump"
            print self.player.walk
            print self.player.jump
            path3, can3, cost3 = pf.compute_path_until_PM(A, B, 2, self.player.jump)
            if (can3 == True) or  (self.player.jump >= self.player.walk):
                return (path3,2)
        return (path, 0)
开发者ID:kostspielig,项目名称:smart-player,代码行数:29,代码来源:Movement.py

示例2: posible_positions

# 需要导入模块: import Board [as 别名]
# 或者: from Board import adjacent_cells [as 别名]
    def posible_positions (self,enemyCell, distance2enemy):
        positions = []
        faceEnemy = relative_position (self.playerCell, enemyCell)
        face = faceEnemy
        #if distance2enemy <3:
        #    face = (face+3)%6
        cell = self.playerCell
        newCell = cell
        for i in range(2):
            cell = newCell
            for j in [0,1,-1]:
                newCell = Board.adjacent_cells(cell, face+j, self.board)
                if newCell == 0: continue
                # Miramos si ai algun bosque denso o  ligero
                obj = self.board.map[newCell[0]][newCell[1]].objects
                if obj == 1 or obj == 2:
                    positions.append(newCell)

        return positions, faceEnemy
开发者ID:kostspielig,项目名称:smart-player,代码行数:21,代码来源:Movement.py


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