From: erm1001@tcm16.phy.cam.ac.uk (Eva R. Myers) Subject: Re: CONTRIB: stat your logfile Date: 28 Feb 2000 11:24:03 +0000 erm1001@tcm16.phy.cam.ac.uk (Eva R. Myers) writes: > I was inspired by this to update the "nhk" script that tabulates which > causes of death are the most common or responsible for the most > aggregate score. Here's my current version; it works fine on my high > score table but may have problems with unusual causes of death. > "Killed by an X of Y" is a particularly hard one to get right - "a > blast of disintegration" and "the wrath of Odin" are OK as they are > [maybe "divine wrath" would be better??] and ghosts and priests are > allowed for specially in the code, but "an incubus of Loki" should be > converted to "incubus" and isn't. Here's my latest version of nhk. I've updated it to deal with divine wrath and minions, and tried to categorise deaths by choking, drowning and poisoning of various sorts in a sensible way. I also modified the sort routine slightly, so that it sorts by aggregate score then number of kills, or number of kills then aggregate score. Could somebody please point me to an up-to-date spoiler on ways to die so that I can see what obscure causes of death nhk falls down on? Boudewijn, is there any chance that you could put a pointer to my updated nhk on http://www.win.tue.nl/games/roguelike/nethack/ ? Eva. #!/usr/bin/perl # nhk - nethack monster high scores (version 1.0) # # Copyright (C) 1993 by John J. Chew, III # Heavily edited by Boudewijn Wayers # # Eva Myers updated it for 3.3.0 and made a few # changes - 23 Feb 2000 # # DESCRIPTION # # This program lists high scores for monsters, either by the number of # players that they have managed to kill, or by the total score of # their victims. # # BUGS # # - nhk has been tested only on our local files and may not correctly # format unusual killers. Please report bugs to the address above. # - nhk stands, for historical reasons, for NetHack Killers. It does # not stand for Nihon Housou Kyoku. # # The output looks like: # # 15 1218362 corpse # 2 229752 starvation # 2 189090 cockatrice # 3 164639 magic bolt # 1 134738 vampire lord # 2 73613 black pudding # 10 46236 rothe # 1 34126 death ray # 2 11243 Woodland-elf # 1 6460 giant beetle # 1 2529 burning book # 1 1454 iguana # configuration variables $CV_DEFAULT_DIRECTORY = '/usr/lib/games/nethackdir'; $CV_LOGFILE_NAME = 'logfile'; $CV_RECORD_NAME = 'record'; sub usage { warn "Usage: $0 [ -f file | -l | -r ] [ -n | -s ]\n\n"; warn " -f use indicated file\n"; warn " -l use logfile\n"; warn " -r use record (high score file) [default]\n"; warn " -n sort by number of kills\n"; warn " -s sort by aggregate victim score [default]\n"; exit 1; } require 'getopts.pl'; &Getopts('f:lnrs') || &usage; (defined $opt_f) && $opt_l && $opt_r && &usage; $opt_n && $opt_s && &usage; $opt_n || $opt_s || ($opt_s = 1); $FILE = (defined $opt_f) ? $opt_f : $CV_DEFAULT_DIRECTORY . '/' . ($opt_l ? $CV_LOGFILE_NAME : $CV_RECORD_NAME); (defined $opt_f) || $opt_l || ($opt_r = 1); open(FILE, "<$FILE") || die "$0: cannot open $FILE"; @file = ; close(FILE); $killlen = 1; $scorelen = 1; for $_ (@file) { chop; # version points deathwhere deathlev maxlvl hp maxhp deathdnum enddate # startdate bar class race gender alignment name,death split(/ /, $_, 16); $_ = $_[15]; s/ \(with the Amulet\)//; s/[^\,]*,//; # "choked on a foo" - choking # "poisoned by a rotted foo corpse" - food poisoning # "poisoned by a killer bee/quasit/..." - deadly poison # "poisoned by Demogorgon/Pestilence/Juiblex" - Demogorgon/Pestilence/Juiblex # "drowned ... by a foo" - foo # "drowned ..." - drowned [removed ring of levitation above water?] s/choked on .*/choking/; if (/poisoned by/) { s/poisoned by( an?)? //; if (/corpse/) { $_ = "food poisoning"; } elsif ($_ ne "Demogorgon" && $_ ne "Pestilence" && $_ ne "Juiblex") { $_ = "deadly poison"; } } s/drowned in .* by an? //; s/drowned .*/drowned/; s/(killed by|crushed to death by|petrified by)( an?)? //; # see topten.c s/hallucinogen-distorted |invisible //; s/ called .*//; # This would work better if the logfile included "while paralysed by a # floating eye", "while praying unsuccessfully",... s/.*, while helpless/helplessness/; s/priest(ess)?.*/priest(ess)/; s/.*, the shopkeeper/shopkeeper/; s/ghost of .*/ghost/; s/slipped while mounting .*/slipped while mounting a steed/; s/bolt of .*/magic bolt/; s/fall onto //; # Gods and their minions s/the wrath of .*/divine wrath/; s/ of [A-Z].*//; $count{$_}++; $killlen = length($count{$_}) if length($count{$_}) > $killlen; $score{$_} += $_[1]; $scorelen = length($score{$_}) if length($score{$_}) > $scorelen; } sub mysort { ($A = $a) =~ tr/A-Z/a-z/; ($B = $b) =~ tr/A-Z/a-z/; if ($opt_n) { $count{$b} <=> $count{$a} || $score{$b} <=> $score{$a} || $A cmp $B; } else { $score{$b} <=> $score{$a} || $count{$b} <=> $count{$a} || $A cmp $B; } } for $key (sort mysort keys %count) { printf "%${killlen}d %${scorelen}d %${scorelen}d %s\n", $count{$key}, $score{$key}, $score{$key}/$count{$key}, $key; } exit 0; __END__ -- Eva Myers, Computer Officer, Statistical | Ignorance and deception can't Laboratory, University of Cambridge | save anybody. *Knowing* saves Email: erm1001@cam.ac.uk | them.