diff options
Diffstat (limited to 'games/pks.awk')
-rw-r--r-- | games/pks.awk | 80 |
1 files changed, 6 insertions, 74 deletions
diff --git a/games/pks.awk b/games/pks.awk index 2219872b..06aad75f 100644 --- a/games/pks.awk +++ b/games/pks.awk @@ -3,27 +3,8 @@ # Process arguments BEGIN { - # Look for options; keep a count of non-option args - ac = ARGC - for (i = 1; i <= ARGC; i++) { - - # Show a pic of Phil - if (ARGV[i] == "--phil") { - pic = 1 - ARGV[i] = "" - ac-- - } - - # End-of-options - if (ARGV[i] == "--") { - break - ARGV[i] = "" - ac-- - } - } - # If no arguments left, assume a dictionary file - if (ac == 1) { + if (ARGC == 1) { ARGC = 2 if ("DICT" in ENVIRON) ARGV[1] = ENVIRON["DICT"] @@ -40,10 +21,11 @@ BEGIN { } # Iterate over the lines, randomly assigning the first field of each one with a -# decreasing probability; this method +# decreasing probability; this method allows a single pass over the input, +# though it requires a lot of random numbers $1 ~ /[[:alpha:]]/ && rand() * ++n < 1 { wr = $1 } -# Ha, ha, ha! Incompetent! +# Ha, ha! Conclusion! END { # Check that we processed at least one line @@ -61,56 +43,6 @@ END { # Capitalise the word wr = toupper(substr(wr,1,1)) substr(wr,2) - # Return the laughter and the word - if (pic) - dopic(ha, wr) - else - printf "%s! %s!\n", ha, wr -} - -# Ha, ha! Low-res! -function dopic(ha, wr) { - print "" - print " " ha "! " wr "!" - print " \\" - print " .''''''''''''''''''''''.." - print " .'''''''''''''''''''''''''''" - print " .'''''''''''''''''''''''''''''" - print " ,'''''''''''''''''''''''''''''''" - print " '''''''''''''''''''''''''''''''':" - print " ,'''''''''''##`'''''''''''''''.'''`" - print " ;''''''''.###########,'''''',###'''" - print " ;'''''';#################:'#####.''" - print " `:''''''#########################'." - print " ::` ,'+########################';" - print " ''''''': .#####################''" - print " ''''''''.####` `;#############;##'" - print " ;''''''',####,###: +############." - print " ,###''''''#############` ;##:#######" - print " ,#:##''';+#####+ :###### +##+ +" - print " ,'#;#,''#####',+###` ;####`+ " - print " ,#'#,#';############++. ,`## " - print " :#####+:#######,@,``@@,#####' " - print " ;#+#+#############++++##.#+## +" - print " ###+################'####'## " - print " #######+###################.# :." - print " ######'########################'" - print " ,+#####;#######################" - print " ,#######;############'####+###:" - print " ,#######################+#####'" - print " ,###############' ` #'# +'#" - print " #,##.###########'##+##'###'####" - print " ``@.############## `+#@@@@@######" - print " +```@@################ ,,. . ####." - print " ;````@@,##.##############':..:######" - print " ;`````@@@########.##################" - print " +````````@@@@#####;####################:" - print " +`````.`````@@@@######`###################```+" - print " +````````,`````'@@@@@##'#####################`````." - print "+ ``````````.``````@@@@@@##'###'################```````` +" - print "```````````````````@@@@@@@'#####;##########,##'`````````````.+" - print "```````````````````@@@@@@@@@+#####':####+:+'````````````````````," - print "```````````````````,@@@@@@@@@#:#########'@@@``````````````````````" - print "```````````.````````@@@@@@@@@@@@#'#####@@@@@```````````````````````" - print "```````````.````````@@@@@@@@@@@@@@' @@@@@@@.``````````````````````" + # Print the laughter and the word + printf "%s! %s!\n", ha, wr } |