chiark
/
gitweb
/
~ian
/
appendix-a6.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0651d6b
)
wip, graph vertex name fixes, etc.
author
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 2 Feb 2014 21:32:53 +0000
(21:32 +0000)
committer
Ian Jackson
<ijackson@chiark.greenend.org.uk>
Sun, 2 Feb 2014 21:32:53 +0000
(21:32 +0000)
parse
patch
|
blob
|
history
diff --git
a/parse
b/parse
index a1ce9c587747aa906135ea656f98b04ccb3257fe..f629457c42a04bc11ad9b6196152de80cdaa0dca 100755
(executable)
--- a/
parse
+++ b/
parse
@@
-27,6
+27,7
@@
while (<>) {
s/\s+$//;
next if m/^\s*\#/;
next unless m/\S/;
s/\s+$//;
next if m/^\s*\#/;
next unless m/\S/;
+ next if m/^\s/;
if (m/^([A-Z]+)\s*\=\s*(\S.*)$/) {
my ($choname, $desc) = ($1,$2);
my $cho = addchoice($choname, Desc => $desc);
if (m/^([A-Z]+)\s*\=\s*(\S.*)$/) {
my ($choname, $desc) = ($1,$2);
my $cho = addchoice($choname, Desc => $desc);
@@
-159,14
+160,17
@@
foreach my $ia (chremain()) {
my $vab = scalar @{ $vab[$ia][$ib] };
my $vba = scalar @{ $vab[$ib][$ia] };
next unless $vab > $vba;
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($choices[$ia],$choices[$ib]);
+ my $diff = $vab - $vba;
+ print "defeat: $choices[$ia] beats $choices[$ib]",
+ " ($vab > $vba: $diff)\n";
+ $defeats->add_edge($choices[$ia],$choices[$ib]);
}
}
sub chvab ($$) {
my ($ca,$cb) = @_;
}
}
sub chvab ($$) {
my ($ca,$cb) = @_;
- return $vab[ $choices{$ca}{Index} ][ $choices{$cb}{Index} ];
+ my $v = $vab[ $choices{$ca}{Index} ][ $choices{$cb}{Index} ];
+ return scalar @$v;
}
sub weaker ($$) {
}
sub weaker ($$) {
@@
-202,7
+206,7
@@
for (;;) {
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";
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
);
+ $schwartz->delete_vertex($
choices[$ia]
);
last;
}
}
last;
}
}
@@
-212,6
+216,7
@@
for (;;) {
our @weakest = ();
foreach my $edge ($schwartz->edges()) {
our @weakest = ();
foreach my $edge ($schwartz->edges()) {
+# print " considering @$edge\n";
if (!@weakest) {
# no weakest edges yet
} elsif (weaker($edge, $weakest[0])) {
if (!@weakest) {
# no weakest edges yet
} elsif (weaker($edge, $weakest[0])) {
@@
-227,14
+232,15
@@
for (;;) {
}
last unless @weakest;
}
last unless @weakest;
-
- printf "weakest defeats %d > %d",
- (scalar @{ $vab[$_->[0]][$_->[1]] }),
- (scalar @{ $vab[$_->[1]][$_->[0]] });
+
+ my $w = $weakest[0];
+ printf "weakest defeats %d > %d\n",
+ chvab($w->[0], $w->[1]),
+ chvab($w->[1], $w->[0]);
foreach my $weakest (@weakest) {
foreach my $weakest (@weakest) {
- my ($
ia,$i
b) = @$weakest;
- print "weakest defeat $c
hoices[$ia] > $choices[$ib]
\n";
- $defeats->delete_edge($c
hoices[$ia],$choices[$ib]
);
+ my ($
ca,$c
b) = @$weakest;
+ print "weakest defeat $c
a > $cb
\n";
+ $defeats->delete_edge($c
a,$cb
);
}
print "defeats within the Schwartz set, round again\n";
}
print "defeats within the Schwartz set, round again\n";