rewardFunction = -3*ones(nStates,nActions);
%%
position = 450;
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(1,:));
for i = 3: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 = [2329 2332 2396 2400 2526];
for i=1:length(change)
    rewardFunction(change(i),:)=rewardFunction(2460,:);
end

%%
[e,f]=hist(state,unique(state))
[d,indice] = maxk(e,30)
    
if isempty(find(state==38))==1
    counts=1;
end

figure
plot(x(550000:600000-1),y(550000:600000-1))