How to represent the actions when setting the reward in GridWorld?

3 views (last 30 days)
I am learning to use the reinforcement learning toolbox. I try to creat a custom grid world environment. But i have some problem with how to set the Rewards . When using "GW.R" , how to represent the actions?
Like this:
GW.R(state2idx(GW,GW.CurrentState),:,state2idx(GW,GW.Actions.NE)) = -14;
GW.R(state2idx(GW,GW.CurrentState),:,'NW') = -14;
GW.R(state2idx(GW,GW.CurrentState),:,GW.Actions.SE) = -14;
GW.R(state2idx(GW,GW.CurrentState),:,GW.Actions.SW) = -14;

Answers (1)

Poorna
Poorna on 30 Aug 2023
Hi,
I understand that you would like to know the right syntax of representing the action while setting the reward for a transition. You could use the function action2idx to specify the action.
You could set the required reward as below:
GW.R(state2idx(GW,GW.CurrentState),:,action2idx(GW,"NW")) = -14;
Hope this helps!

Categories

Find more on Language Support in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!