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


Python Brain.angle_decision方法代码示例

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


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

示例1: Robot

# 需要导入模块: from brain import Brain [as 别名]
# 或者: from brain.Brain import angle_decision [as 别名]
class Robot(Player):
    def __init__(
        self, controller, color, k_right, k_backward, k_left, k_forward, k_weapon1, k_weapon2, x, y, rotation=0
    ):
        self.controller = controller
        self.screen = self.controller.screen
        self.name = "Agent"
        self.type = 0
        self.x, self.y = x, y
        self.health = 100
        self.max_speed = TANK_SPEED
        self.max_speed_back = TANK_SPEED_BACK
        self.acceleration = TANK_ACCELERATION
        self.rotation_speed = TANK_ROTATION_SPEED
        self.speed = 0
        self.rotation = rotation
        self.direction = None
        self.moving = False
        self.rotating = False
        self.solid = 100
        self.current_collisions = []
        self.dead = False

        """Gives the player static ammo object, these objects are copied in their fire() function.
        These variables can be seen as weapons, so fiddle with these variables when adding/changing it"""
        self.ammo1, self.ammo2 = NormalShot(self), StickyBomb(self)

        if TANK_WIDTH > TANK_HEIGHT:
            self.radius = int(TANK_WIDTH * 0.55)
        else:
            self.radius = int(TANK_HEIGHT * 0.55)

        # Load and resize tank img with right color
        if color == "green":
            self.MasterSprites = [
                pygame.transform.scale(pygame.image.load("images/tankgreen1.png"), (TANK_WIDTH, TANK_HEIGHT)),
                pygame.transform.scale(pygame.image.load("images/tankgreen2.png"), (TANK_WIDTH, TANK_HEIGHT)),
                pygame.transform.scale(pygame.image.load("images/tankgreen3.png"), (TANK_WIDTH, TANK_HEIGHT)),
            ]
        else:
            self.MasterSprites = [
                pygame.transform.scale(pygame.image.load("images/tankpurple1.png"), (TANK_WIDTH, TANK_HEIGHT)),
                pygame.transform.scale(pygame.image.load("images/tankpurple2.png"), (TANK_WIDTH, TANK_HEIGHT)),
                pygame.transform.scale(pygame.image.load("images/tankpurple3.png"), (TANK_WIDTH, TANK_HEIGHT)),
            ]

        self.sprite = self.MasterSprites[0]

        self.animationindex = 0

        self.brain = Brain(self)

    def update(self):
        """ 90 down, 0 left, 270 up, 180 right """
        for agent in self.controller.agents:
            if agent.name == self.name:
                continue
            else:
                self.brain.angle_decision(agent)

        super(Robot, self).update()
开发者ID:braingineer,项目名称:AI-games,代码行数:63,代码来源:ai.py


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