function f = reward(world_state, id, P)

car = P.cars(id);
state = world_state.car_states(id);
control = world_state.car_controls(id);
lane = P.roads(state.road_id).lanes(state.lane_id);

goal_state = P.cars(id).goal_state;
if isnan(goal_state.lane_id)
  goal_lane = lane;
else
  goal_lane = P.roads(goal_state.road_id).lanes(goal_state.lane_id);
end

dey = state.ey - goal_lane.ey;

f = -1*(car.v_nominal - state.v)^2 ...
    - .5*control.acc^2 ... 
    - 1*(state.v^2*tan(control.steering_angle)/car.wheel_base)^2 ...
    - 10*dey^2;

% this is not necessary since collision is also enforced as a constraint
%if ~isempty(in_collision(world_state, id, P))
%  f = f - 10000;
%end
