% APRENDIZAJE AUTOMÁTICO (G. Pajares y J. M. de la Cruz, Eds.)
% Editorial: RA-MA
% Capítulo 12: Aprendizaje por Refuerzo
% Autores: Jose Antonio Martin H y Matilde Santos
function [ r,f ] = GetReward( s )
% r: the returned reward.
% f: true if the car reached the goal, otherwise f is false

global kind_reward
global reward_equilibrium
global reward_fall

x         = s(1);
x_dot     = s(3);
theta     = s(3);
theta_dot = s(4);



r = reward_equilibrium;

f = false;



fourtyfive_degrees = deg2rad(45); % 45º
if (x < -4.0 || x > 4.0  || theta < -fourtyfive_degrees || theta > fourtyfive_degrees)  
    
    r= reward_fall;    
    f = true;
end

    
   


    
