anchor.diff:      Groups = misc_util:groupBy([{misc_util:behavior(A),A} || A <- Agents ]),
       NewGroups = [evolution:sendToWork(G) || G <- Groups],
       NewAgents = misc_util:shuffle(lists:flatten(NewGroups)),
  -    loop(NewAgents,FDs)
  -  end.+    NewCounters = countGroups(Groups,#counters{}),
  +    loop(NewAgents,FDs,#counters{fight = Counters#counters.fight + NewCounters#counters.fight,
  +                                reproduction = Counters#counters.reproduction + NewCounters#counters.reproduction,
  +                                death = Counters#counters.death + NewCounters#counters.death,
  +                                migration = Counters#counters.migration + NewCounters#counters.migration})
  +  end.
  +
  +-spec countGroups([tuple()],counters()) -> counters().
  +countGroups([],Counter) ->
  +  Counter;
  +countGroups([{death,AgentList}|Groups],Counter) ->
  +  countGroups(Groups,Counter#counters{death = length(AgentList)});
  +countGroups([{migration,AgentList}|Groups],Counter) ->
  +  countGroups(Groups,Counter#counters{migration = length(AgentList)});
  +countGroups([{fight,AgentList}|Groups],Counter) ->
  +  countGroups(Groups,Counter#counters{fight = length(AgentList)});
  +countGroups([{reproduction,AgentList}|Groups],Counter) ->
  +  countGroups(Groups,Counter#counters{reproduction = length(AgentList)}).
positive.code: %% ====================================================================
  %% Internal functions
  %% ====================================================================
  -spec loop([agent()],dict()) -> ok.
  %% @doc Glowna petla procesu. Kazda iteracja powoduje wytworzenie kolejnej generacji.
  loop(Agents,FDs) ->
    receive
      {write,Last} ->
        Fitness = case misc_util:result(Agents) of
  
negative.code: -module(hybrid_island).
  -export([start/3, close/1, sendAgent/2]).
  
  -record(counters,{fight = 0 :: non_neg_integer(),
                    reproduction = 0 :: non_neg_integer(),
                    migration = 0 :: non_neg_integer(),
                    death = 0 :: non_neg_integer()}).
  
  -type agent() :: {Solution::genetic:solution(), Fitness::float(), Energy::pos_integer()}.
  -type counters() :: #counters{}.
  
  %% ====================================================================
  %% API functions
  