push @{ $vote->{Log} }, "stage $stage: $m";
}
-sub filterout ($$) {
- my ($cand, $why) = @_;
- foreach my $vote (@allvotes) {
- my $oldprefs = $vote->{Prefs};
- my @prefs = grep { $_ ne $cand } $oldprefs;
- next if @prefs == @$oldprefs;
- votelog $vote, "crossed out candidate $cand: $why";
- }
-}
-
our @elected; # $elected[] = $candidate
our @unsorted = @allvotes;
our @stagerecord; # $stagerecord[]{$candidate} = $total
+sub voteliveprefs ($) {
+ my ($vote) = @_;
+ grep { $continuing{$_} } @{ $vote->{Prefs} };
+}
+
+sub votelogfull ($$) {
+ my ($vote,$m) = @_;
+ votelog $vote, $m;
+ votelog $vote, ("continuing prefs: ". join ' ', voteliveprefs $vote);
+}
+
foreach my $vote (@allvotes) {
$continuing{$_}=1 foreach @{ $vote->{Prefs} };
}
}
while (my $vote = shift @unsorted) {
- my ($firstpref) = grep { $continuing{$_} } @{ $vote->{Prefs} };
+ my ($firstpref) = voteliveprefs $vote;
if (!defined $firstpref) {
votelog $vote, "ballot exhausted";
push @exhausted, $vote;
my $c = $s->{Cand};
printf "%7s %10s %s\n", 'ELIM', $c, '----------';
my $votes = $s->{Votes};
- votelog $_, "failed to stop $c elimination" foreach @$votes;
+ votelogfull $_, "failed to stop $c elimination" foreach @$votes;
$elimvotebefore += $s->{Total};
delete $continuing{$c};
delete $sorted{$c};
my $c = $s->{Cand};
printf "%7s %10s\n", 'xfer', $c;
my $votes = $s->{Votes};
- votelog $_, "surplus transferred" foreach @$votes;
+ votelogfull $_, "surplus transferred" foreach @$votes;
@surpluses = grep { $_->{Cand} ne $c } @surpluses;
push @unsorted, @$votes;
}