function state = init_state(id, varargin)
% state must be associated with a entity id
% actional arguments: x, v, ey, yaw

% this is the entity id
state.id = id;

% time
state.t = 0;

% physical states
if nargin > 1
  state.x = varargin{1};
else
  state.x = 0;
end

if nargin > 2
  state.v = varargin{2};
else
  state.v = 0;
end

if nargin > 3
  state.ey = varargin{3};
else
  state.ey = 0;
end

if nargin > 4
  state.yaw = varargin{4};
else
  state.yaw = 0;
end


% logical states
state.at_intersection = 0;
state.in_intersection = 0;
state.stopped = 0;
state.at_stop = 0;
state.after_stop = 0;
state.time_stopped_at_stop = nan;
state.yield = 0;

state.committed_turn = 0;

state.turned_to_road_id = 0;

% road-network states
state.road_id = 1;
state.lane_id = 1;

% currently relevant symbols
state.symbols = [];

