BlogShares + Perl

Greg - Boomtime, 38 Bureaucracy 3169 @ 09:45 PM

And this snippet of code is responsible...


foreach (keys %artefact) {
if ( $type1{$_} eq 'collecting' and $type2{$_} eq 'post' ) {
print "$playername1 needs " . (10000 - $held1{$_}) . " " . &fmt_ind($_, 1) . ", $playername2 has $held2{$_}\.\n";
}
if ( $type1{$_} eq 'post' and $type2{$_} eq 'collecting' ) {
print "$playername2 needs " . (10000 - $held2{$_}) . " " . &fmt_ind($_, 2) . ", $playername1 has $held1{$_}\.\n";
}
}

This is the holdup on the idea trade advisor.

It's painfully simple, yet somehow wrong. The second if block is an exact mirror of the first. It should do the converse, but it doesn't. The test never returns true.

Granted, how we get to this point is a little ugly. It's a cobbled together two-pass version of the player data extraction routine from artefact_calculator.cgi. But I've verified that the data is good at this point... By dumping the hashes and manually comparing them, not to mention the fact that the *first* if block works fine. I've also scrupulously checked fmt_ind for unwanted side effects. And done without it, just to be sure.

Oh well, I suppose I'll dump the hashes again and stare at that for a while. And then just rewrite the damned thing from scratch.

The one silver lining is that I'm not up against this sort of hair-puller for a client, on a deadline.





1 Comment


Pungenday, 39 Bureaucracy 3169 @ 12:38 AM

I guess getting it off my chest helped... Turns out I wasn't properly clearing out all the hashes that were reused between passes. Caused the hash dumps I checked to be close enough to pass a cursory examination but wrong everywhere it counts. Sloppy, sloppy.

Anyway, the pre-preview is up at http://testbed.dothanarea.com/advisor_test_2.cgi

Greg


[ Previous entry: "Excessive categorization" ] [ Main Index ] [ Next entry: "Advisor launched" ]


search


browse by category