p=t r=r j=echo Z=npoemfsgnohtksblbtpckdpljqnriogelfhkbqrcaiadjhagimsmjtqecrdf q(){ $j ${Z:RANDOM%19*3:1};} C(){ [[ ${!1} =~ ${!2} ]];} d(){ s=${Z:30#$1*3-30:3};} w=`q` h=`q` for((;;));{ b=$p d $p u=u${s#*$r}$s C w p&&$j D&&exitThe wumpus ate you&&exit C h p&&$j F&&exitYou fell in the pit&&exit C u w&&$j WYou smell the wumpus C u h&&$j PYou feel a breeze from a pit read i F=5 y=${u:i/10:1};C i F&&p=$y&&r=$b||{ d $w;C y w&&$j I&&exit;$jYou A;w=$killed the wumpus&&exit;$j You missed;w=${s:RANDOM%3:1};};} - Initial release, 698 chars
- Fixed bug where "You feel a breeze" and "You smell the wumpus" can't display at the same time; saved 39 chars by making the random number generation a function.
- Remembered that the wumpus moves if you shoot and miss. 726 chars.
- Made
grep -oEa variable. Saved 5 chars. - Made
[a-z]{3}a variable. Saved 3 chars. - Made
echoa variable. Saved 5 chars. - Acted on most of @Dennis 's suggestions. Saved 72 chars.
- Added all remaining suggestions. Saved 68 chars.
- Saved 2 chars from @DigitalTrauma 's suggestion.
- Fixed a major bug where you can only shoot the wumpus if it is on the right. Same character count.
- Used parameter expansion to shave off 2 chars using
$m. - Shaved off a lot of chars by ditching
grepand being slightly more sensible. - Defined
Cas a regexp search function to use in if statements, andEas a function printing "You killed the wumpus" and exiting. - Saved 1 char by "if statement" rearrangement.
- Saved a lot of chars by getting rid of
d, and removed unnecessary brackets. - Fixed bugs. Added lots of chars :(
- MOARR SAVINGS (http://xkcd.com/1296/)
- Another of @Dennis 's ideas (saving a few chars), and my crafty (ab)use of indirection (saving 1 char).
- Style fix for q().
- re-added proper output