Example #1
0
    def perform(self, comms):
        # get robot
        robots = filter(lambda r: not r.is_missing(), self.world.their_robots)
        robots.sort(key=lambda r: math.hypot(r.x - self.robot.x, r.y - self.robot.y))
        if len(robots) == 0:
            logging.error("There is no enemy here. Gimme someone to destroy!")
            return 1
        robot = robots[0]

        # Find our goal
        goal = Vector(0, 225, 0, 0)
        if self.robot.x > 300:
            goal = Vector(600, 225, 0, 0)

        # get the point
        robots = self.world.their_robots
        y_diff = goal.y - robot.y
        x_diff = goal.x - robot.x
        ratio = (self.world.our_defender.x - robot.x) / x_diff

        y_mean = robot.y + (y_diff * ratio)

        distance = utils.defender_distance_on_y(self.world.our_defender.vector, y_mean)

        print("DISTANCE: " + str(distance))
        logging.info("Wants to move by: " + str(distance))
        comms.move(distance)

        return utils.defender_move_delay(distance)
Example #2
0
    def perform(self, comms):
        robots = self.world.their_robots
        y_diff = robots[1].y - robots[0].y
        x_diff = robots[1].x - robots[0].x
        ratio = (self.world.our_defender.x - robots[0].x) / x_diff

        y_mean = robots[0].y + (y_diff * ratio)

        distance = utils.defender_distance_on_y(self.world.our_defender.vector, y_mean)

        print("DISTANCE: " + str(distance))
        logging.info("Wants to move by: " + str(distance))
        comms.move(distance)
        return utils.defender_move_delay(distance)