#!/bin/bash # qky.sh ############################################################## # QUACKEY: a somewhat simplified version of Perquackey [TM]. # # # # Author: Mendel Cooper # # version 0.1.02 03 May, 2008 # # License: GPL3 # ############################################################## WLIST=/usr/share/dict/word.lst # ^^^^^^^^ Word list file found here. # ASCII word list, one word per line, UNIX format. # A suggested list is the script author's "yawl" word list package. # http://bash.deta.in/yawl-0.3.2.tar.gz # or # http://ibiblio.org/pub/Linux/libs/yawl-0.3.2.tar.gz NONCONS=0 # Word not constructable from letter set. CONS=1 # Constructable. SUCCESS=0 NG=1 FAILURE='' NULL=0 # Zero out value of letter (if found). MINWLEN=3 # Minimum word length. MAXCAT=5 # Maximum number of words in a given category. PENALTY=200 # General-purpose penalty for unacceptable words. total= E_DUP=70 # Duplicate word error. TIMEOUT=10 # Time for word input. NVLET=10 # 10 letters for non-vulnerable. VULET=13 # 13 letters for vulnerable (not yet implemented!). declare -a Words declare -a Status declare -a Score=( 0 0 0 0 0 0 0 0 0 0 0 ) letters=( a n s r t m l k p r b c i d s i d z e w u e t f e y e r e f e g t g h h i t r s c i t i d i j a t a o l a m n a n o v n w o s e l n o s p a q e e r a b r s a o d s t g t i t l u e u v n e o x y m r k ) # Letter distribution table shamelessly borrowed from "Wordy" game, #+ ca. 1992, written by a certain fine fellow named Mendel Cooper. declare -a LS numelements=${#letters[@]} randseed="$1" instructions () { clear echo "Welcome to QUACKEY, the anagramming word construction game."; echo echo -n "Do you need instructions? (y/n) "; read ans if [ "$ans" = "y" -o "$ans" = "Y" ]; then clear echo -e '\E[31;47m' # Red foreground. '\E[34;47m' for blue. cat <> $savefile echo "Letterset # $randseed (random seed) ">> $savefile echo -n "Letterset: " >> $savefile echo "${LS[@]}" >> $savefile echo "---------" >> $savefile echo "Words constructed:" >> $savefile echo "${Words[@]}" >> $savefile echo >> $savefile echo "Score: $total" >> $savefile echo "Statistics for this round saved in \""$savefile"\"" ######################################################### echo "Score for this round: $total" echo "Words: ${Words[@]}" } # ---------# instructions seed_random get_letset play end_of_game # ---------# exit $? # TODO: # # 1) Clean up code! # 2) Prettify the display_words () function (maybe with widgets?). # 3) Improve the time-out ... maybe change to untimed entry, #+ but with a time limit for the overall round. # 4) An on-screen countdown timer would be nice. # 5) Implement "vulnerable" mode of play for compatibility with classic #+ version of the game. # 6) Improve save-to-file capability (and maybe make it optional). # 7) Fix bugs!!! # For more info, reference: # http://bash.deta.in/qky.README.html