%% Create a SARSA Agent
% Create or load an environment interface. For this example load the Basic Grid World environment interface.

env = rlPredefinedEnv("BasicGridWorld");

%
% Create a critic value function representation using a Q table derived from the environment observation and action specifications.

qTable = rlTable(getObservationInfo(env),getActionInfo(env));
critic = rlQValueRepresentation(qTable,getObservationInfo(env),getActionInfo(env));

%
% Create a SARSA agent using the specified critic value function and an epsilon value of 0.05.

opt = rlSARSAAgentOptions;
opt.EpsilonGreedyExploration.Epsilon = 0.05;

agent = rlSARSAAgent(critic,opt)

%
% To check your agent, use getAction to return the action from a random observation.

getAction(agent,{randi(25)})

% You can now test and train the agent against the environment.
% Copyright 2019 The MathWorks, Inc.