function actions = simple_actions(world_state, id, goal_state, P)
% Generate feasible actions for a given world_state
%
% We consider these macro-actions (actions)
%
% -------------------------------------------------
% Name               |  Function           |  Parameters
%--------------------------------------------------
% LaneChange         | lane-changing       | lane = {left_lane, right_lane}
% ConstAcceleration  | const acceleration  | acc = {-a_nominal, 0, a_nominal} 

state = world_state.car_states(id);
road = P.roads(state.road_id);
lane = road.lanes(state.lane_id);

car = P.cars(id);

actions(1) = init_action(P.kSpeed.Coast, @(world_state, P)const_acceleration_policy(world_state, id, 0, P));

if state.v < P.cars(id).v_nominal - P.v_tol
  actions(end+1) = init_action(P.kSpeed.Nominal, @(world_state, P)const_acceleration_policy(world_state, id, car.acc_nominal, P));
end

% 4) AccPolicy(zero_velocity)
if state.v > P.v_tol
  actions(end+1) = init_action(P.kSpeed.Zero, @(world_state, P)const_acceleration_policy(world_state, id, -car.acc_nominal, P));
end

% we could also have an extreme speed-up action
%if state.v < P.cars(id).v_nominal - P.v_tol
%  actions(end+1) = init_action(P.kSpeed.Nominal, @(world_state, P)const_acceleration_policy(world_state, id, car.acc_max, P));
%end

% we could also have an extreme breaking action
%if state.v > P.v_tol
  % create a goal state with desired nominal velocity
%  actions(end+1) = init_action(P.kSpeed.Zero, @(world_state, P)const_acceleration_policy(world_state, id, car.acc_min, P));
%end

% 2) LangeChange(right)
% if there is room to move toward first lane
if state.lane_id > 1
  lane_id = state.lane_id - 1;
  actions(end+1) = init_action(P.kLane.Right, @(world_state, P)lane_change_policy(world_state, id, lane_id, P), ...
                               @(world_state, P)lane_change_termination(world_state, id, lane_id, P));
end   

% 3) LangeChange(left)
% if there is room to move toward last lane
if state.lane_id < length(road.lanes)
  lane_id = state.lane_id + 1;
  actions(end+1) = init_action(P.kLane.Left, @(world_state, P)lane_change_policy(world_state, id, lane_id, P), ...
                               @(world_state, P)lane_change_termination(world_state, id, lane_id, P));
end

