Beispiel #1
0
    def __init__(self):
        super().__init__()

        self.remote = grSimRemote("127.0.0.1", 20011)

        self.framework = Framework(is_team_yellow = True)
        self.framework.start_game(ChallengeStrategy, async=True)
        self.strategie = self.framework.strategy

        loadUi("roboul_main.ui", self)

        self.challenges = load_challenges("challenges.xml")

        self.defis_comboBox.currentIndexChanged.connect(self.change_challenge)
        for challenge in self.challenges:
            self.defis_comboBox.addItem(challenge.name, challenge)

        self.resetButton.clicked.connect(self.reset)
        self.startButton.toggled.connect(self.startstop)

        self.show()
Beispiel #2
0
class CompetitionGUI(QMainWindow):

    def __init__(self):
        super().__init__()

        self.remote = grSimRemote("127.0.0.1", 20011)

        self.framework_player = None
        self.challenge = None
        self.framework_ai = Framework(is_team_yellow=True)
        self.framework_ai.start_game(ChallengeStrategy, async=True)
        self.strategie = self.framework_ai.strategy

        loadUi("roboul_main.ui", self)

        self.challenges = load_challenges("challenges.xml")

        self.defis_comboBox.currentIndexChanged.connect(self.change_challenge_box)
        for challenge in self.challenges:
            self.defis_comboBox.addItem(challenge.name, challenge)

        self.resetButton.clicked.connect(self.reset)
        self.startButton.toggled.connect(self.startstop)

        self.show()

    def reset(self):
        self.change_challenge(self.defis_comboBox.currentIndex())

    def startstop(self, start):
        if isinstance(self.framework_player, Framework):
            self.framework_player.stop_game()

        if start:
            command = "NORMAL_START"
            defis = reload_defis()
            if self.challenge:
                self.framework_player = game_launcher.start_game(defis[self.challenge]())
                self.framework_player.game.referee.command = RefCommand(command)
        else:
            command = "HALT"

        self.framework_ai.game.referee.command = RefCommand(command)

    def change_challenge_box(self, challenge_index):
        self.startstop(False)
        self.startButton.setChecked(False)
        self.change_challenge(challenge_index)

    def change_challenge(self, challenge_index):

        #This does not stop the framework_player

        challenge = self.defis_comboBox.itemData(challenge_index)
        challenge.reload()

        self.remote.start_batch()

        for robot_id, robot in challenge.blue.items():
            self.remote.place_player(robot.id, False,
                                     robot.x, robot.y, robot.theta)

        for robot_id, robot in challenge.yellow.items():
            self.remote.place_player(robot.id, True,
                                     robot.x, robot.y, robot.theta)
        ball = challenge.ball
        self.remote.place_ball(ball.x, ball.y, ball.vx, ball.vy)

        self.remote.end_batch()

        self.description_label.setText(challenge.description)

        self.strategie.set_mode(challenge.strategy)

        self.challenge = challenge.deficlass

    def closeEvent(self,event):
        self.framework_ai.stop_game()
        if isinstance(self.framework_player, Framework):
            self.framework_player.stop_game()
def start_game(main_loop):

    framework = Framework()
    framework.start_game(getStrategy(main_loop))
Beispiel #4
0
from RULEngine.Framework import Framework
from coach import Coach
from config.config_service import ConfigService

__author__ = 'RoboCupULaval'


def set_arg_parser():
    # TODO add mode debug, redirect, pathfinder!
    prog_desc = "Module de l'intelligence artificielle. L'option est de charger un fichier de configuration."
    arg_parser = argparse.ArgumentParser(prog="RobocupULaval's Team ULtron AI", description=prog_desc)

    arg_parser.add_argument('config_file', nargs='?', help="load a configuration file(.ini/cfg style)",
                            default="config/sim_kalman_redirect.cfg")

    return arg_parser

if __name__ == '__main__':
    # parser for command line arguments
    parser = set_arg_parser()
    args = parser.parse_args()

    config_service = ConfigService().load_file(args.config_file)
    # ai init
    ai_coach = Coach()
    # RULEngine init
    framework = Framework()
    # Starting point
    framework.start_game(ai_coach.main_loop, ai_coach.set_reference)
def start_game(main_loop):

    framework = Framework()
    framework.start_game(getStrategy(main_loop), async = True)
    return framework
Beispiel #6
0
def start_game(main_loop):

    framework = Framework()
    framework.start_game(getStrategy(main_loop))
Beispiel #7
0
# Under MIT License, see LICENSE.txt
""" Point d'entrée de l'intelligence artificielle. """
from RULEngine.Framework import Framework
from coach import Coach

__author__ = 'RoboCupULaval'

if __name__ == '__main__':
    ai_coach = Coach()
    Framework().start_game(ai_coach.main_loop, ai_coach.set_team_color)