anchor.diff:  set_vision() -> 
   set_frame_skip() ->
   % checkers
  +has_nuke() -> 
  +in_replay() -> 
   is_game_paused() ->  
   is_being_gathered() -> 
   is_carrying_gas() -> 
  
positive.code: %% bwapi environment
  active_tile_array() -> 
  mini_tile_flags() -> 
  tile_set_map() -> 
  map_tile_array() -> 
  trigger_vectors() -> 
  save_game_file() -> 
  current_map_file() -> 
  screen_x() -> 
  screen_y() -> 
  move_to_x() -> 
  move_to_y() -> 
  replay_header() -> 
  net_mode() -> 
  in_replay() -> 
  game_type() -> 
  vissible_units() ->  
  hidden_units() -> 
  frame_skip() -> 
  latency_frames() -> 
  resource_count() -> 
  gather_queue_count() -> 
  next_gatherer() -> 
  has_nuke() -> 
  hit_points() -> 
  move_target() -> 
  current_direction() -> 
  
negative.code: get_hatchery() -> 
  get_kill_count() -> 
  get_last_attacking_player() -> 
  get_training_queue() -> 
  
  lua_do(Unit, Command) ->             % "do" any Lua command
      call(Unit, {lua_do, Command}).
  
  gc(Unit) ->
      call(Unit, gc).
  
  %% Main loop.
  
  init(X, Y, State0) ->
      region:add_sector(X, Y, self()),       % Put us in some region
      {_,State1} = luerl:call_function([this_unit,start], [], State0),
      {_,State2} = luerl:call_function([this_unit,set_position], [X,Y], State1),
      {_,State3} = luerl:call_function([this_unit,set_speed], [0,0], State2),
      proc_lib:init_ack({ok,self()}),
      loop(State3, infinity, make_ref(), 0). % Start with dummy tick ref
  
  %% loop(LuerlState, Tick, TickRef, TickCount) -> no_return().
  
  loop(State0, Tick, Tref, Tc) ->
      receive
      {call,From,get_position} ->
          {[X,Y],State1} = luerl:call_function([this_unit,get_position], [], State0),
          reply(From, {X,Y}),
          loop(State1, Tick, Tref, Tc);
      {cast,From,{set_position,X,Y}} ->
          %%  logging unused variable!
          lager:warning("set_position From? ~p \n", [From]),
          {_,State1} = luerl:call_function([this_unit,set_position],
                        [float(X),float(Y)], State0),
          loop(State1, Tick, Tref, Tc);
      {call,From,get_speed} ->
          {[Dx,Dy],State1} = luerl:call_function([this_unit,get_speed], [], State0),
          reply(From, {Dx,Dy}),
          loop(State1, Tick, Tref, Tc);
      {cast,From,{set_speed,Dx,Dy}} ->
          %%  logging unused variable!
          lager:warning("set_speed From? ~p \n", [From]),
          {_,State1} = luerl:call_function([this_unit,set_speed],
                        [float(Dx),float(Dy)], State0),
          loop(State1, Tick, Tref, Tc);
      {call,From,{lua_do,Command}} ->     %"do" any Lua command
          {Rs,State1} = luerl:do(Command, State0),
          reply(From, {ok,Rs}),
          loop(State1, Tick, Tref, Tc);
      {call,From,gc} ->           %Gc the luerl state
          State1 = luerl:gc(State0),
          reply(From, ok),
          loop(State1, Tick, Tref, Tc)
      end.
  
  