forked from DarthJDG/NumGuess
-
Notifications
You must be signed in to change notification settings - Fork 1
/
numguess.fal
59 lines (49 loc) · 1.17 KB
/
numguess.fal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
> "Welcome to NumGuess Falcon version!\n"
>> "Enter your name: "
name = input()
if name == "": name = "Player"
>> "\nWelcome ", name, ", enter upper limit: "
limit = 10
try: limit = int(input())
if limit < 10: limit = 10
max_tries = int(log(limit) / log(2)) + 1
loop
> "\nGuess my number between 1 and ", limit, "!\n"
num = random(limit - 1) + 1
tries = 0
guess = 0
loop
>> "Guess: "
guess = nil
try: guess = int(input())
if guess == nil
> "That's just plain wrong."
elif guess < 1 or guess > limit
> "Out of range."
else
tries += 1
if guess < num
> "Too low!"
elif guess > num
> "Too high!"
end
end
end guess == num
tries_word = tries == 1 ? "try" : "tries"
> "\nWell done ", name, ", you guessed my number from ", tries, " ", tries_word, "!"
if tries == 1
> "You're one lucky bastard!"
elif tries < max_tries
> "You are the master of this game!"
elif tries == max_tries
> "You are a machine!"
elif tries <= max_tries * 1.1
> "Very good result!"
elif tries <= limit
> "Try harder, you can do better!"
else
> "I find your lack of skill disturbing!"
end
>> "Play again [y/N]? "
end input().upper() != "Y"
> "\nOkay, bye."