mirror of
https://github.com/pragma-/pbot.git
synced 2025-01-23 02:24:25 +01:00
Spinach: Reduce state logging verbosity
This commit is contained in:
parent
4c38f279f7
commit
55a7fb7db9
@ -23,7 +23,7 @@ use Lingua::EN::ABC qw/b2a/;
|
|||||||
use Time::Duration qw/concise duration/;
|
use Time::Duration qw/concise duration/;
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$Data::Dumper::Sortkeys = 1;
|
$Data::Dumper::Sortkeys = sub { my ($h) = @_; my @a = sort grep { not /^(?:seen_questions|alternativeSpellings)$/ } keys %$h; \@a };
|
||||||
$Data::Dumper::Useqq = 1;
|
$Data::Dumper::Useqq = 1;
|
||||||
|
|
||||||
sub new {
|
sub new {
|
||||||
@ -809,7 +809,7 @@ sub add_new_suggestions {
|
|||||||
|
|
||||||
foreach my $player (@{$state->{players}}) {
|
foreach my $player (@{$state->{players}}) {
|
||||||
if ($player->{deceived}) {
|
if ($player->{deceived}) {
|
||||||
$self->{pbot}->{logger}->log("Adding new suggestion for $state->{current_question}->{id}: $player->{deceived}\n");
|
$self->{pbot}->{logger}->log("Adding new suggestion for $state->{current_question}->{id}: $state->{current_question}->{question}: $player->{deceived}\n");
|
||||||
|
|
||||||
if (not grep { lc $_ eq lc $player->{deceived} } @{$state->{current_question}->{suggestions}}) {
|
if (not grep { lc $_ eq lc $player->{deceived} } @{$state->{current_question}->{suggestions}}) {
|
||||||
if (not defined $question) {
|
if (not defined $question) {
|
||||||
@ -842,6 +842,7 @@ sub add_new_suggestions {
|
|||||||
sub run_one_state {
|
sub run_one_state {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
# check for naughty or missing players
|
||||||
if ($self->{current_state} =~ /r\dq\d/) {
|
if ($self->{current_state} =~ /r\dq\d/) {
|
||||||
my $removed = 0;
|
my $removed = 0;
|
||||||
for (my $i = 0; $i < @{$self->{state_data}->{players}}; $i++) {
|
for (my $i = 0; $i < @{$self->{state_data}->{players}}; $i++) {
|
||||||
@ -866,12 +867,14 @@ sub run_one_state {
|
|||||||
|
|
||||||
my $state_data = $self->{state_data};
|
my $state_data = $self->{state_data};
|
||||||
|
|
||||||
|
# this shouldn't happen
|
||||||
if (not defined $self->{current_state}) {
|
if (not defined $self->{current_state}) {
|
||||||
$self->{pbot}->{logger}->log("Spinach state broke.\n");
|
$self->{pbot}->{logger}->log("Spinach state broke.\n");
|
||||||
$self->{current_state} = 'nogame';
|
$self->{current_state} = 'nogame';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# transistioned to a brand new state; prepare first tock
|
||||||
if ($self->{previous_state} ne $self->{current_state}) {
|
if ($self->{previous_state} ne $self->{current_state}) {
|
||||||
$state_data->{newstate} = 1;
|
$state_data->{newstate} = 1;
|
||||||
$state_data->{ticks} = 1;
|
$state_data->{ticks} = 1;
|
||||||
@ -886,10 +889,9 @@ sub run_one_state {
|
|||||||
$state_data->{newstate} = 0;
|
$state_data->{newstate} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# dump new state data for logging/debugging
|
||||||
if ($state_data->{newstate}) {
|
if ($state_data->{newstate}) {
|
||||||
$self->{pbot}->{logger}->log("Spinach: New state: $self->{current_state}\n" . Dumper $state_data);
|
$self->{pbot}->{logger}->log("Spinach: New state: $self->{current_state}\n" . Dumper $state_data);
|
||||||
} elsif ($self->{current_state} ne 'nogame') {
|
|
||||||
$self->{pbot}->{logger}->log("Spinach: $self->{current_state} - Tick $state_data->{ticks}\n" . Dumper $state_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# run one state/tick
|
# run one state/tick
|
||||||
@ -901,8 +903,6 @@ sub run_one_state {
|
|||||||
$state_data->{ticks} = 0;
|
$state_data->{ticks} = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$self->{pbot}->{logger}->log("Spinach: result: $state_data->{previous_result} => $state_data->{result}\n") if $self->{current_state} ne 'nogame';
|
|
||||||
|
|
||||||
# transform to next state
|
# transform to next state
|
||||||
$state_data->{previous_result} = $state_data->{result};
|
$state_data->{previous_result} = $state_data->{result};
|
||||||
$self->{previous_state} = $self->{current_state};
|
$self->{previous_state} = $self->{current_state};
|
||||||
|
Loading…
Reference in New Issue
Block a user