edbeeching / godot_rl_agents

An Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents
MIT License
942 stars 69 forks source link

Help me: a doubt about action_space #98

Closed yizhangliu closed 1 year ago

yizhangliu commented 1 year ago

Server: gdrl --trainer sb3 --env_path=debug Godot example: Racer from https://github.com/edbeeching/godot_rl_agents_examples

func get_action_space():
    return {
        "turn" : {
            "size": 1,
            "action_type": "continuous"
        },        
        "accelerate" : {
            "size": 2,
            "action_type": "discrete"
        },
        "brake" : {
            "size": 2,
            "action_type": "discrete"
        },
    }

func set_action(action):    
    if action["accelerate"] != action["brake"]:
        print(action)
    turn_action = action["turn"][0]
    acc_action = action["accelerate"] == 1
    brake_action = action["brake"] == 1

During the debugging process,the returned action is always : action["accelerate"] == action["brake"].

Is there something wrong?

yizhangliu commented 1 year ago

@edbeeching

I got it.

https://github.com/edbeeching/godot_rl_agents/blob/16deecac4a178fbba437fac9d63a86358bc8f1f7/godot_rl/core/utils.py#L88

after this line, should add : counter += 1

edbeeching commented 1 year ago

@yizhangliu , nice spot! Would you be able to make a PR with the fix?

edbeeching commented 1 year ago

Fixed in #99, thanks.