anchor.diff:      ets:insert(Ets, [{Name, Vertex, #vstate{}} ||
                           Vertex = #vertex{name=Name} <- Vertices]),
       ets:insert(Ets, {tpos, 0}),
  -    ets:insert(Ets, {fitness, 0}),
  +    Ets.
  +
  +simulate_run(G) ->
  +    Ets = init_local_ets(G),
       Res = genetica_utils:repeatedly(?NOF_BLOCKS, fun () -> block_run(Ets) end),
  -%    io:format("~p~n", [Res]),
  -%    [{delta, Delta}] = ets:lookup(Ets, delta),
  -%    io:format("Total movement this run: ~p~n", [Delta]),
       ets:delete(Ets),
       Res.
   
  -refit(#ptype{gtype = G, ref = Ref}) ->
  +refit(G) ->
  +    [{simtype, S}] = ets:lookup(genetica_cognitive_ets, simtype),
  +    refit(S, G).
  +
  +refit(random, #ptype{gtype = G, ref = Ref}) ->
       Fitness = gen_fit(G),
  -    {Ref, Fitness}.
  -
  -setup_ets() ->
  +    {Ref, Fitness};
  +refit(brute, #ptype{gtype = G, ref = Ref}) ->
  +    case ets:lookup(genetica_cognitive_ets, Ref) of
  +        [] ->
  +            Fitness = brute_fit(G),
  +            {Ref, Fitness};
  +        [{Ref, Fitness}] ->
  +            {Ref, Fitness}
  +    end.
  +
  +init_global_ets(SimType) ->
       case ets:info(genetica_cognitive_ets) of
           undefined -> ets:new(genetica_cognitive_ets,
                                [set, named_table]);
           _ -> nil
       end,
  +    ets:insert(genetica_cognitive_ets, {simtype, SimType}),
       ok.
   
   
  -genotype_to_phenotype_fn(_) ->
  -    setup_ets(),
  +genotype_to_phenotype_fn([_, _, _, _, SimType | _]) ->
  +    init_global_ets(SimType),
       %% Generate fitness fn here?
       fun (G) ->
               Ref = erlang:make_ref(),
               P = #ptype{gtype = G, ref = Ref},
  -            ets:insert(genetica_cognitive_ets, refit(P)),
  +            ets:insert(genetica_cognitive_ets, refit(SimType, P)),
               P
       end.
   
  
positive.code:     end.
  
  %%% Fitness function stuff
  gen_fit(G) ->
      Res = simulate_run(G),
      Avoids = [Y || {X, Y} <- Res, X =:= avoid],
      ALen = length(Avoids),
      Captures = [Y || {X, Y} <- Res, X =:= capture],
      CLen = length(Captures),
      Avs = lists:sum(Avoids)/ALen * ?NOF_BLOCKS,
      Capts = lists:sum(Captures)/CLen * ?NOF_BLOCKS,
  %    io:format("~p -- ~p~n", [Avs, Capts]),
      ?NOF_BLOCKS - Avs + Capts.
  
  
  new_block(Ets) ->
      ets:insert(Ets, #block{size = random:uniform(?BLOCK_MAX_SIZE),
  
negative.code: 
  reset_tracker(Ets) ->
      ets:insert(Ets,
                 [case ets:lookup(Ets, V)
                      of [{X, Y, _}] ->
                          {X, Y, #vstate{}}
                  end || V <- [a, b, c, d]]).
  