mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-25 04:02:37 +01:00
Improve quickest-streak algorithm for setting new records
Use the following formula to set personal records for quickest-streak relative to an existing personal current record. (ranked_streak + ranked_streak) / ranked_answers > (current_streak + ranked_streak) / current_answers E.g., given a current record of 8 correct answers in a row in 1 minute and 20 seconds, to beat that record you'd need: 6 answers in 40 seconds, 7 in 1 minute, 9 in 1 minute 40 seconds, 10 in 2 minutes, etc.
This commit is contained in:
parent
b0b74cd6ea
commit
04a308a59e
@ -214,22 +214,26 @@ foreach my $answer (@valid_answers) {
|
|||||||
|
|
||||||
my $dont_print_streak = 0;
|
my $dont_print_streak = 0;
|
||||||
|
|
||||||
if (($player_data->{correct_streak} > $player_data->{highest_quick_correct_streak})
|
my $t1 = $player_data->{lifetime_quickest_correct_streak} ? $player_data->{lifetime_quickest_correct_streak} : 32767;
|
||||||
or ($player_data->{correct_streak} == $player_data->{highest_quick_correct_streak}
|
my $t2 = gettimeofday - $player_data->{correct_streak_timestamp};
|
||||||
and (gettimeofday - $player_data->{correct_streak_timestamp} < $player_data->{quickest_correct_streak}))) {
|
my $a1 = $player_data->{lifetime_highest_quick_correct_streak} ? $player_data->{lifetime_highest_quick_correct_streak} : 1;
|
||||||
|
my $a2 = $player_data->{correct_streak} ? $player_data->{correct_streak} : 1;
|
||||||
|
|
||||||
|
my $ratio1 = ($t1 + $t1) / $a1;
|
||||||
|
my $ratio2 = ($t2 + $t1) / $a2;
|
||||||
|
|
||||||
|
print STDERR "nick: $nick, t1 = $t1, t2 = $t2, a1 = $a1, a2 = $a2, ratio1 = $ratio1, ratio2 = $ratio2\n";
|
||||||
|
|
||||||
|
if ($ratio2 < $ratio1 and $player_data->{correct_streak} >= 3) {
|
||||||
$player_data->{highest_quick_correct_streak} = $player_data->{correct_streak};
|
$player_data->{highest_quick_correct_streak} = $player_data->{correct_streak};
|
||||||
$player_data->{quickest_correct_streak} = gettimeofday - $player_data->{correct_streak_timestamp};
|
$player_data->{quickest_correct_streak} = gettimeofday - $player_data->{correct_streak_timestamp};
|
||||||
|
|
||||||
if ($player_data->{highest_quick_correct_streak} > $player_data->{lifetime_highest_quick_correct_streak}) {
|
|
||||||
$player_data->{lifetime_highest_quick_correct_streak} = $player_data->{highest_quick_correct_streak};
|
$player_data->{lifetime_highest_quick_correct_streak} = $player_data->{highest_quick_correct_streak};
|
||||||
$player_data->{lifetime_quickest_correct_streak} = $player_data->{quickest_correct_streak};
|
$player_data->{lifetime_quickest_correct_streak} = $player_data->{quickest_correct_streak};
|
||||||
}
|
|
||||||
|
|
||||||
if ($player_data->{highest_quick_correct_streak} >= 3) {
|
|
||||||
print "$color{orange}$nick$color{cyan} just set a new personal quickest correct answer streak of $color{orange}$player_data->{highest_quick_correct_streak} $color{cyan}correct answers in $color{orange}", duration($player_data->{quickest_correct_streak}), "$color{cyan}!$color{reset}\n";
|
print "$color{orange}$nick$color{cyan} just set a new personal quickest correct answer streak of $color{orange}$player_data->{highest_quick_correct_streak} $color{cyan}correct answers in $color{orange}", duration($player_data->{quickest_correct_streak}), "$color{cyan}!$color{reset}\n";
|
||||||
$dont_print_streak = 1;
|
$dont_print_streak = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
unless ($dont_print_streak) {
|
unless ($dont_print_streak) {
|
||||||
my %streaks = (
|
my %streaks = (
|
||||||
|
Loading…
Reference in New Issue
Block a user