Hunt the Wumpus: Difference between revisions
Content added Content deleted
Line 183: | Line 183: | ||
""" |
""" |
||
function queryprompt(query, choices) |
function queryprompt(query, choices, choicetxt="") |
||
carr = map(x -> uppercase(strip(string(x))), collect(choices)) |
carr = map(x -> uppercase(strip(string(x))), collect(choices)) |
||
while true |
while true |
||
print(query, " ", carr, ": ") |
print(query, " ", choicetxt == "" ? carr : choicetxt, ": ") |
||
choice = uppercase(strip(readline(stdin))) |
choice = uppercase(strip(readline(stdin))) |
||
if choice in carr |
if choice in carr |
||
Line 283: | Line 283: | ||
arrowroom = playerroom |
arrowroom = playerroom |
||
for i in 1:distance |
for i in 1:distance |
||
choices[i] = parse(Int, queryprompt("ROOM #", |
choices[i] = parse(Int, queryprompt("ROOM #", 1:20, "1-20")) |
||
while i > 2 && choices[i] == choices[i-2] |
while i > 2 && choices[i] == choices[i-2] |
||
println("ARROWS AREN'T THAT CROOKED - TRY ANOTHER ROOM") |
println("ARROWS AREN'T THAT CROOKED - TRY ANOTHER ROOM") |
||
choices[i] = parse(Int, queryprompt("ROOM #", |
choices[i] = parse(Int, queryprompt("ROOM #", 1:20, "1-20")) |
||
end |
end |
||
arrowroom = choices[i] |
arrowroom = choices[i] |