Exemple #1
0
    def generate_start_state(cls):
        point_range = ((MiniSoccerEnvironment.MIN_X - 1, MiniSoccerEnvironment.MIN_Y),
                       (MiniSoccerEnvironment.MAX_X + 1, MiniSoccerEnvironment.MAX_Y))
        
#        if role == cls.ROLE_ATTACK:
#            PLAYER_X_START = MiniSoccerEnvironment.FIELD_WIDTH / 4
#            PLAYER_Y_START = MiniSoccerEnvironment.MIN_GOAL_Y
#            OPPONENT_X_START = MiniSoccerEnvironment.FIELD_WIDTH * 3 / 4
#            OPPONENT_Y_START = MiniSoccerEnvironment.MAX_GOAL_Y
#            player_has_ball = True
#        else:
#            PLAYER_X_START = MiniSoccerEnvironment.FIELD_WIDTH * 3 / 4
#            PLAYER_Y_START = MiniSoccerEnvironment.MAX_GOAL_Y
#            OPPONENT_X_START = MiniSoccerEnvironment.FIELD_WIDTH / 4
#            OPPONENT_Y_START = MiniSoccerEnvironment.MIN_GOAL_Y
#            player_has_ball = False
        
        ball_with_player = random.choice((True, False))
#        ball_with_player = True
#        ball_with_player = False

        player = rl.StateVarPoint2D("player", cls.PLAYER_X_START, cls.PLAYER_Y_START,
                point_range, is_dynamic=True, is_continuous=True)
        opponent = rl.StateVarPoint2D("opponent", cls.OPPONENT_X_START, cls.OPPONENT_Y_START,
                point_range, is_dynamic=True, is_continuous=True)
        player_has_ball = rl.StateVarFlag("player_has_ball", ball_with_player, 
                                          is_dynamic=True) 
#        role = rl.StateVarFlag("player_on_left", (role == cls.ROLE_ATTACK),
#                                is_dynamic=False)
        
#        state_vars = [player, opponent, player_has_ball, role]
        state_vars = [player, opponent, player_has_ball]
        
        state = MiniSoccerState(state_vars)
        return state
Exemple #2
0
    def generate_start_state(cls):
        point_range = ((0, 0), (KeepAwayEnvironment.FIELD_SIZE,
                                KeepAwayEnvironment.FIELD_SIZE))

        keeper1_x = 2
        keeper1_y = 2
        keeper2_x = KeepAwayEnvironment.FIELD_SIZE - 2
        keeper2_y = 2
        keeper3_x = 2
        keeper3_y = KeepAwayEnvironment.FIELD_SIZE - 2
        taker1_x = KeepAwayEnvironment.FIELD_SIZE / 2 + 2
        taker1_y = KeepAwayEnvironment.FIELD_SIZE / 2 - 2
        taker2_x = KeepAwayEnvironment.FIELD_SIZE / 2 - 2
        taker2_y = KeepAwayEnvironment.FIELD_SIZE / 2 + 2

        keeper1_var = rl.StateVarPoint2D("keeper1",
                                         keeper1_x,
                                         keeper1_y,
                                         point_range,
                                         is_dynamic=True,
                                         is_continuous=True)
        keeper2_var = rl.StateVarPoint2D("keeper2",
                                         keeper2_x,
                                         keeper2_y,
                                         point_range,
                                         is_dynamic=True,
                                         is_continuous=True)
        keeper3_var = rl.StateVarPoint2D("keeper3",
                                         keeper3_x,
                                         keeper3_y,
                                         point_range,
                                         is_dynamic=True,
                                         is_continuous=True)
        taker1_var = rl.StateVarPoint2D("taker1",
                                        taker1_x,
                                        taker1_y,
                                        point_range,
                                        is_dynamic=True,
                                        is_continuous=True)
        taker2_var = rl.StateVarPoint2D("taker2",
                                        taker2_x,
                                        taker2_y,
                                        point_range,
                                        is_dynamic=True,
                                        is_continuous=True)

        state_vars = [
            keeper1_var, keeper2_var, keeper3_var, taker1_var, taker2_var
        ]

        state = KeepAwayState(state_vars)
        return state
Exemple #3
0
    def get_environment_vars(cls):
        point_range = ((0, 0), (KeepAwayEnvironment.FIELD_SIZE,
                                KeepAwayEnvironment.FIELD_SIZE))

        lower_left_corner_x = 0
        lower_left_corner_y = 0
        lower_right_corner_x = KeepAwayEnvironment.FIELD_SIZE
        lower_right_corner_y = 0
        upper_left_corner_x = 0
        upper_left_corner_y = KeepAwayEnvironment.FIELD_SIZE
        upper_right_corner_x = KeepAwayEnvironment.FIELD_SIZE
        upper_right_corner_y = KeepAwayEnvironment.FIELD_SIZE
        center_x = KeepAwayEnvironment.FIELD_SIZE / 2
        center_y = KeepAwayEnvironment.FIELD_SIZE / 2

        lower_left_corner_state_var = rl.StateVarPoint2D("lowerleft",
                                                         lower_left_corner_x,
                                                         lower_left_corner_y,
                                                         point_range,
                                                         is_dynamic=False,
                                                         is_continuous=True)
        lower_right_corner_state_var = rl.StateVarPoint2D("lowerright",
                                                          lower_right_corner_x,
                                                          lower_right_corner_y,
                                                          point_range,
                                                          is_dynamic=False,
                                                          is_continuous=True)
        upper_left_corner_state_var = rl.StateVarPoint2D("upperleft",
                                                         upper_left_corner_x,
                                                         upper_left_corner_y,
                                                         point_range,
                                                         is_dynamic=False,
                                                         is_continuous=True)
        upper_right_corner_state_var = rl.StateVarPoint2D("upperright",
                                                          upper_right_corner_x,
                                                          upper_right_corner_y,
                                                          point_range,
                                                          is_dynamic=False,
                                                          is_continuous=True)
        center_state_var = rl.StateVarPoint2D("center",
                                              center_x,
                                              center_y,
                                              point_range,
                                              is_dynamic=False,
                                              is_continuous=True)

        return [
            lower_left_corner_state_var, lower_right_corner_state_var,
            upper_left_corner_state_var, upper_right_corner_state_var,
            center_state_var
        ]
Exemple #4
0
    def get_environment_vars(cls):
        point_range = ((cls.MIN_X - 1, cls.MIN_Y),
                       (cls.MAX_X + 1, cls.MAX_Y))
        
        lower_left_corner_var = rl.StateVarPoint2D("lowerleft",
                cls.MIN_X, cls.MIN_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        lower_right_corner_var = rl.StateVarPoint2D("lowerright",
                cls.MAX_X, cls.MIN_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        upper_left_corner_var = rl.StateVarPoint2D("upperleft",
                cls.MIN_X, cls.MAX_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        upper_right_corner_var = rl.StateVarPoint2D("upperright",
                cls.MAX_X, cls.MAX_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        
        center_var = rl.StateVarPoint2D("center",
                cls.FIELD_WIDTH / 2, cls.FIELD_HEIGHT / 2, 
                point_range, is_dynamic=False, is_continuous=True)

        left_goal_bottom_var = rl.StateVarPoint2D("leftgoalbottom",
                cls.MIN_X, cls.MIN_GOAL_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        left_goal_top_var = rl.StateVarPoint2D("leftgoaltop",
                cls.MIN_X, cls.MAX_GOAL_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        left_goal_center_var = rl.StateVarPoint2D("leftgoalcenter",
                cls.MIN_X - 1, (cls.MIN_GOAL_Y + cls.MAX_GOAL_Y) / 2,
                point_range, is_dynamic=False, is_continuous=True)
        right_goal_bottom_var = rl.StateVarPoint2D("rightgoalbottom",
                cls.MAX_X, cls.MIN_GOAL_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        right_goal_top_var = rl.StateVarPoint2D("rightgoaltop",
                cls.MAX_X, cls.MAX_GOAL_Y, 
                point_range, is_dynamic=False, is_continuous=True)
        right_goal_center_var = rl.StateVarPoint2D("rightgoalcenter",
                cls.MAX_X + 1, (cls.MIN_GOAL_Y + cls.MAX_GOAL_Y) / 2,
                point_range, is_dynamic=False, is_continuous=True)

        return [lower_left_corner_var, lower_right_corner_var,
                upper_left_corner_var, upper_right_corner_var,
                center_var,
                left_goal_bottom_var, left_goal_top_var, left_goal_center_var,
                right_goal_bottom_var, right_goal_top_var, right_goal_center_var]