lc_competitive_events (faber_neuroevolution v1.2.4)

View Source

Behavioral event constructors for Competitive Silo.

Events related to Elo ratings, opponent archives, and matchmaking. Competitive Silo operates at timescale τ=15.

Summary

Types

competitive_event/0

-type competitive_event() ::
          #opponent_archived{meta ::
                                 #lc_event_meta{event_id :: binary(),
                                                correlation_id :: binary() | undefined,
                                                causation_id :: binary() | undefined,
                                                timestamp :: timestamp(),
                                                version :: pos_integer(),
                                                emitter :: atom()},
                             opponent_id :: individual_id(),
                             archive_id :: binary(),
                             fitness_at_archive :: float(),
                             elo_at_archive :: float(),
                             generation :: generation(),
                             archive_size_after :: non_neg_integer()} |
          #opponent_retired{meta ::
                                #lc_event_meta{event_id :: binary(),
                                               correlation_id :: binary() | undefined,
                                               causation_id :: binary() | undefined,
                                               timestamp :: timestamp(),
                                               version :: pos_integer(),
                                               emitter :: atom()},
                            opponent_id :: individual_id(),
                            archive_id :: binary(),
                            retirement_reason :: age | performance | diversity,
                            games_played :: non_neg_integer(),
                            final_elo :: float()} |
          #match_completed{meta ::
                               #lc_event_meta{event_id :: binary(),
                                              correlation_id :: binary() | undefined,
                                              causation_id :: binary() | undefined,
                                              timestamp :: timestamp(),
                                              version :: pos_integer(),
                                              emitter :: atom()},
                           match_id :: binary(),
                           player_a_id :: individual_id(),
                           player_b_id :: individual_id(),
                           winner_id :: individual_id() | draw,
                           player_a_elo_before :: float(),
                           player_b_elo_before :: float(),
                           player_a_elo_after :: float(),
                           player_b_elo_after :: float(),
                           match_duration_ms :: non_neg_integer()} |
          #elo_updated{meta ::
                           #lc_event_meta{event_id :: binary(),
                                          correlation_id :: binary() | undefined,
                                          causation_id :: binary() | undefined,
                                          timestamp :: timestamp(),
                                          version :: pos_integer(),
                                          emitter :: atom()},
                       individual_id :: individual_id(),
                       elo_before :: float(),
                       elo_after :: float(),
                       k_factor :: float(),
                       match_result :: win | loss | draw} |
          #strategy_countered{meta ::
                                  #lc_event_meta{event_id :: binary(),
                                                 correlation_id :: binary() | undefined,
                                                 causation_id :: binary() | undefined,
                                                 timestamp :: timestamp(),
                                                 version :: pos_integer(),
                                                 emitter :: atom()},
                              counter_id :: individual_id(),
                              countered_id :: individual_id(),
                              win_rate_against :: float(),
                              strategy_signature :: binary(),
                              generation :: generation()} |
          #arms_race_detected{meta ::
                                  #lc_event_meta{event_id :: binary(),
                                                 correlation_id :: binary() | undefined,
                                                 causation_id :: binary() | undefined,
                                                 timestamp :: timestamp(),
                                                 version :: pos_integer(),
                                                 emitter :: atom()},
                              population_id :: population_id(),
                              cycle_length :: non_neg_integer(),
                              participants :: [individual_id()],
                              intensity :: float(),
                              generation :: generation()} |
          #matchmaking_adjusted{meta ::
                                    #lc_event_meta{event_id :: binary(),
                                                   correlation_id :: binary() | undefined,
                                                   causation_id :: binary() | undefined,
                                                   timestamp :: timestamp(),
                                                   version :: pos_integer(),
                                                   emitter :: atom()},
                                population_id :: population_id(),
                                elo_range_before :: float(),
                                elo_range_after :: float(),
                                self_play_ratio_before :: float(),
                                self_play_ratio_after :: float(),
                                adjustment_reason :: diversity | exploitation | exploration} |
          #dominance_matrix_updated{meta ::
                                        #lc_event_meta{event_id :: binary(),
                                                       correlation_id :: binary() | undefined,
                                                       causation_id :: binary() | undefined,
                                                       timestamp :: timestamp(),
                                                       version :: pos_integer(),
                                                       emitter :: atom()},
                                    population_id :: population_id(),
                                    matrix_size :: non_neg_integer(),
                                    strongest_counter :: {individual_id(), individual_id(), float()},
                                    cycle_detected :: boolean(),
                                    update_generation :: generation()}.

generation/0

-type generation() :: non_neg_integer().

individual_id/0

-type individual_id() :: binary().

population_id/0

-type population_id() :: binary().

timestamp/0

-type timestamp() :: integer().

Functions

arms_race_detected(Data)

-spec arms_race_detected(map()) ->
                            #arms_race_detected{meta ::
                                                    #lc_event_meta{event_id :: binary(),
                                                                   correlation_id ::
                                                                       binary() | undefined,
                                                                   causation_id :: binary() | undefined,
                                                                   timestamp :: timestamp(),
                                                                   version :: pos_integer(),
                                                                   emitter :: atom()},
                                                population_id :: population_id(),
                                                cycle_length :: non_neg_integer(),
                                                participants :: [individual_id()],
                                                intensity :: float(),
                                                generation :: generation()}.

dominance_matrix_updated(Data)

-spec dominance_matrix_updated(map()) ->
                                  #dominance_matrix_updated{meta ::
                                                                #lc_event_meta{event_id :: binary(),
                                                                               correlation_id ::
                                                                                   binary() | undefined,
                                                                               causation_id ::
                                                                                   binary() | undefined,
                                                                               timestamp :: timestamp(),
                                                                               version :: pos_integer(),
                                                                               emitter :: atom()},
                                                            population_id :: population_id(),
                                                            matrix_size :: non_neg_integer(),
                                                            strongest_counter ::
                                                                {individual_id(),
                                                                 individual_id(),
                                                                 float()},
                                                            cycle_detected :: boolean(),
                                                            update_generation :: generation()}.

elo_updated(Data)

-spec elo_updated(map()) ->
                     #elo_updated{meta ::
                                      #lc_event_meta{event_id :: binary(),
                                                     correlation_id :: binary() | undefined,
                                                     causation_id :: binary() | undefined,
                                                     timestamp :: timestamp(),
                                                     version :: pos_integer(),
                                                     emitter :: atom()},
                                  individual_id :: individual_id(),
                                  elo_before :: float(),
                                  elo_after :: float(),
                                  k_factor :: float(),
                                  match_result :: win | loss | draw}.

event_to_map(Event)

-spec event_to_map(competitive_event()) -> map().

make_meta(Emitter)

-spec make_meta(Emitter :: atom()) ->
                   #lc_event_meta{event_id :: binary(),
                                  correlation_id :: binary() | undefined,
                                  causation_id :: binary() | undefined,
                                  timestamp :: timestamp(),
                                  version :: pos_integer(),
                                  emitter :: atom()}.

make_meta(Emitter, Opts)

-spec make_meta(Emitter :: atom(), Opts :: map()) ->
                   #lc_event_meta{event_id :: binary(),
                                  correlation_id :: binary() | undefined,
                                  causation_id :: binary() | undefined,
                                  timestamp :: timestamp(),
                                  version :: pos_integer(),
                                  emitter :: atom()}.

match_completed(Data)

-spec match_completed(map()) ->
                         #match_completed{meta ::
                                              #lc_event_meta{event_id :: binary(),
                                                             correlation_id :: binary() | undefined,
                                                             causation_id :: binary() | undefined,
                                                             timestamp :: timestamp(),
                                                             version :: pos_integer(),
                                                             emitter :: atom()},
                                          match_id :: binary(),
                                          player_a_id :: individual_id(),
                                          player_b_id :: individual_id(),
                                          winner_id :: individual_id() | draw,
                                          player_a_elo_before :: float(),
                                          player_b_elo_before :: float(),
                                          player_a_elo_after :: float(),
                                          player_b_elo_after :: float(),
                                          match_duration_ms :: non_neg_integer()}.

matchmaking_adjusted(Data)

-spec matchmaking_adjusted(map()) ->
                              #matchmaking_adjusted{meta ::
                                                        #lc_event_meta{event_id :: binary(),
                                                                       correlation_id ::
                                                                           binary() | undefined,
                                                                       causation_id ::
                                                                           binary() | undefined,
                                                                       timestamp :: timestamp(),
                                                                       version :: pos_integer(),
                                                                       emitter :: atom()},
                                                    population_id :: population_id(),
                                                    elo_range_before :: float(),
                                                    elo_range_after :: float(),
                                                    self_play_ratio_before :: float(),
                                                    self_play_ratio_after :: float(),
                                                    adjustment_reason ::
                                                        diversity | exploitation | exploration}.

opponent_archived(Data)

-spec opponent_archived(map()) ->
                           #opponent_archived{meta ::
                                                  #lc_event_meta{event_id :: binary(),
                                                                 correlation_id :: binary() | undefined,
                                                                 causation_id :: binary() | undefined,
                                                                 timestamp :: timestamp(),
                                                                 version :: pos_integer(),
                                                                 emitter :: atom()},
                                              opponent_id :: individual_id(),
                                              archive_id :: binary(),
                                              fitness_at_archive :: float(),
                                              elo_at_archive :: float(),
                                              generation :: generation(),
                                              archive_size_after :: non_neg_integer()}.

opponent_retired(Data)

-spec opponent_retired(map()) ->
                          #opponent_retired{meta ::
                                                #lc_event_meta{event_id :: binary(),
                                                               correlation_id :: binary() | undefined,
                                                               causation_id :: binary() | undefined,
                                                               timestamp :: timestamp(),
                                                               version :: pos_integer(),
                                                               emitter :: atom()},
                                            opponent_id :: individual_id(),
                                            archive_id :: binary(),
                                            retirement_reason :: age | performance | diversity,
                                            games_played :: non_neg_integer(),
                                            final_elo :: float()}.

strategy_countered(Data)

-spec strategy_countered(map()) ->
                            #strategy_countered{meta ::
                                                    #lc_event_meta{event_id :: binary(),
                                                                   correlation_id ::
                                                                       binary() | undefined,
                                                                   causation_id :: binary() | undefined,
                                                                   timestamp :: timestamp(),
                                                                   version :: pos_integer(),
                                                                   emitter :: atom()},
                                                counter_id :: individual_id(),
                                                countered_id :: individual_id(),
                                                win_rate_against :: float(),
                                                strategy_signature :: binary(),
                                                generation :: generation()}.