Create an 8-by-13 gridworld object with "Kings" moves. For more information, see createGridWorld and Create Custom Grid World Environments.
Display the allowed actions.
ans = 8×1 string
"N"
"S"
"E"
"W"
"NE"
"NW"
"SE"
"SW"
Use the action2idx function to obtain the index associated with the "SE" action.
Use the idx2action function to obtain the name of the fifth action.
Use the state2idx function to obtain the index associated with the state "[3,5]".
Use the idx2state function to obtain the name of the twenty-fifth state.
Set two terminal states.
Set the rewards for reaching the terminal states, using state2idx to index the terminal states.
Set to zero the probability of transitioning out from state "[2,4]". Use state2idx to obtain the index associated with the state "[2,4]".
For any action, set to one the probability from transitioning from state "[2,4]" to state "[4,4]".
Use rlMDPEnv to create the grid world environment env from the GridWorld object gw.
To specify a reset function that sets the state to [3,3], first, obtain the index of this state.
Then, create an anonymous function handle that sets the initial state to x0. The value of x0 is saved in the anonymous function workspace at definition time.
Call the environment reset function, (which in turn calls the function specified in env.ResetFcn), and return the initial state.
Display the name of the current state.
Move the agent position in the southeast direction.
Use idx2state to display the name of the next state.