rewardFunction = -3*ones(nStates,nActions);
%%
position = 19;
GraphicalAnimation(A,B,...                          % Maze layout
                       [x(position) y(position)],fi(position),...         % Robot location
                       IPoint_IR_sensor(:,:,position),t)  % IR sensor data
                   
%%
aux1 = 1;
v = 0;
c = unique(state);
for i = 1:length(c)
    if rewardFunction(c(i),:) == rewardFunction(1,:)
        v(aux1) = c(i);
        aux1 = aux1 +1;
    end
end
for i = 1:length(v)
    v(i)
    position = find(state==v(i));
    GraphicalAnimation(A,B,...                          % Maze layout
                       [x(position(1)) y(position(1))],fi(position(1)),...         % Robot location
                       IPoint_IR_sensor(:,:,position(1)),t)  % IR sensor data
    pause
end
%%
change = [494];
for i=1:length(change)
    rewardFunction(change(i),:)=rewardFunction(501,:);
end