From 0651d6b71fb087495c174faac376b5c9c60c0bfc Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 2 Feb 2014 21:00:15 +0000 Subject: [PATCH] better msgs --- parse | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/parse b/parse index 7ca1ed6..a1ce9c5 100755 --- a/parse +++ b/parse @@ -154,24 +154,29 @@ sub chremain () { } foreach my $ia (chremain()) { - $defeats->add_vertex($ia); + $defeats->add_vertex($choices[$ia]); foreach my $ib (chremain()) { my $vab = scalar @{ $vab[$ia][$ib] }; my $vba = scalar @{ $vab[$ib][$ia] }; next unless $vab > $vba; print "defeat: $choices[$ia] beats $choices[$ib] ($vab > $vba)\n"; - $defeats->add_vertex($ia,$ib); + $defeats->add_vertex($choices[$ia],$choices[$ib]); } } +sub chvab ($$) { + my ($ca,$cb) = @_; + return $vab[ $choices{$ca}{Index} ][ $choices{$cb}{Index} ]; +} + sub weaker ($$) { # A.6(7)(1) my ($def1,$def2) = @_; - my ($ia,$ix) = @$def1; - my ($ib,$iy) = @$def1; - return 1 if $vab[$ia][$ix] < $vab[$ib][$iy]; - return 1 if $vab[$ia][$ix] == $vab[$ib][$iy] - && $vab[$ix][$ia] > $vab[$iy][$ib]; + my ($ca,$cx) = @$def1; + my ($cb,$cy) = @$def1; + return 1 if chvab($ca, $cx) < chvab($cb, $cy); + return 1 if chvab($ca, $cx) == chvab($cb, $cy) + && chvab($cx, $ca) > chvab($cy, $cb); return 0; } @@ -194,8 +199,8 @@ for (;;) { foreach my $ia (chremain()) { foreach my $ib (chremain()) { - next if $tdefeats->has_edge($ia,$ib); - next if !$tdefeats->has_edge($ib,$ia); + next if $tdefeats->has_edge($choices[$ia],$choices[$ib]); + next if !$tdefeats->has_edge($choices[$ib],$choices[$ia]); print "not in Schwartz set: $choices[$ia] because $choices[$ib]\n"; $schwartz->delete_vertex($ia); last; @@ -229,7 +234,7 @@ for (;;) { foreach my $weakest (@weakest) { my ($ia,$ib) = @$weakest; print "weakest defeat $choices[$ia] > $choices[$ib]\n"; - $defeats->delete_edge($ia,$ib); + $defeats->delete_edge($choices[$ia],$choices[$ib]); } print "defeats within the Schwartz set, round again\n"; @@ -244,7 +249,7 @@ if ($schwartz->vertices() == 1) { print "WINNER IS ONE OF (CASTING VOTE DECIDES):\n"; } -printf " %-5s %s\n", $choices[$_], $ch[$_]{Desc} +printf " %-5s %s\n", $_, $choices{$_}{Desc} foreach ($schwartz->vertices()); print ".\n"; -- 2.30.2