home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
games
/
volume15
/
xbomb
/
part03
/
statistics
< prev
next >
Wrap
Text File
|
1993-01-27
|
1KB
|
59 lines
#!/usr/local/bin/perl
#
# output statistics about map
# @(#)statistics 1.4 (UCLA) 10/15/92
#
# statistics is Copyright (C) 1992 by John Heidemann, Los Angeles, CA.
# All rights reserved. Permission is granted to freely distribute
# this as long as this copyright message is retained intact.
# Permission to distribute this as part of a commerical product
# requires explicit permission of the author.
#
#
$| = 1; # no output buffering
#
# loop reading boards
#
for (;!eof(STDIN);) {
# read in data
while (<STDIN>) {
chop;
if (/^numbombs (\d+)/) {
$numbombs = $1;
};
last if (/map/);
};
@map = ();
while (<STDIN>) {
last if (/^$/);
chop;
push (@map, $_);
};
$bombsfound = $unknownfound = 0;
# figure stats
foreach (@map) {
$bombsfound += tr/X/X/;
$unknownfound += tr/././;
};
# report stats
print STDERR "Bombs found: $bombsfound\n";
print STDERR "Unkowns found: $unknownfound\n";
printf STDERR "Guess chance: %.5f\n", ($numbombs-$bombsfound) / $unknownfound;
print STDERR "\n";
# we draw no conclusions
print "\n";
};
exit (0);