Hunt the Wumpus: Difference between revisions

Line 3,463:
Red [
Title: "Hunt the Wumpus"
;Date: 25-Jun-2016
Author: "Gregg Irwin"
Version: 1.0.2
Line 3,563 ⟶ 3,562:
 
WARNINGS: WHEN YOU ARE ONE ROOM AWAY FROM A WUMPUS OR HAZARD, THE COMPUTER SAYS:
WUMPUS: 'YOU SMELL ASOMETHING WUMPUSTERRIBLE NEARBY'
BAT : 'YOU HEAR BATSA RUSTLING'
PIT : 'YOU FEEL A DRAFTCOLD WIND BLOWING FROM A NEARBY CAVERN'
}
 
Line 3,572 ⟶ 3,571:
]
 
check-for-hazards: funchas [/local i][
print ""
print ["You are in room " loc/:player]
print ["Tunnels lead to " pick cave loc/:player]
; Look at each of the 3 rooms around the player to see if the contain
; the wumpus, a pit, or bats.
repeat i 3 [
room: pick pick cave loc/:player i
if (room = loc/:wumpus) [print " You smell a wumpus!"]
print "^-You smell something terrible nearby."
]
if any [(room = loc/:pit-1) (room = loc/:pit-2)] [
print " ^-You feel a draft!cold wind blowing from a nearby cavern."
]
if any [(room = loc/:bats-1) (room = loc/:bats-2)] [
print " ^-You hear bats!a rustling."
]
]
Line 3,591 ⟶ 3,592:
]
 
move-or-shoot?: funchas [/local cmd][
cmd: ask "Shoot or move (S/M)? "
; The default case handles bad inputs and prompts the user again.
Line 3,621 ⟶ 3,622:
]
 
shoot: funchas [/local path][
path: load ask "Enter 1 to 5 room numbers for the arrow's path: "
path: compose [(path)] ; ensure it's a block, in case they entered only 1 number
move-arrow loc/:player path
if not finished [
print "^-Your arrow missed"
move-wumpus
]
Line 3,634 ⟶ 3,635:
arrow-count: arrow-count - 1
if (arrow-count <= 0) [
print reduce [newline "^/You ran out of arrows..."]
winner: 'wumpus
finished: true
Line 3,645 ⟶ 3,646:
check-for-arrow-hit: func [room][
if (room = loc/:wumpus) [
print reduce [newline "^/You got the Wumpus!"]
winner: 'player
finished: true
Line 3,651 ⟶ 3,652:
]
if (room = loc/:player) [
print reduce [newline "^/You shot yourself!"]
winner: 'arrow
finished: true
Line 3,681 ⟶ 3,682:
; Call recursively, then bail, if illegal move
if not find pick cave loc/:player new-player-loc [
print "You can't move there, unlessif not you plan to dig a new tunnel."
move-player
exit
Line 3,713 ⟶ 3,714:
; This is ugly, but it works for now and avoids setup collisions.
; Don't really need items for this, but I'd like to improve it and then I might.
init-locations: funchas [/local items avail-rooms result offset][
random/seed now/time/precise
items: [player wumpus pit-1 pit-2 bats-1 bats-2]
Anonymous user