Created
May 9, 2013 18:01
-
-
Save gulnara/5549279 to your computer and use it in GitHub Desktop.
guessing game in Unicorn
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
show "What's your name?" | |
name <- string_prompt | |
show "Hello ", name | |
show "Let's play a game! Pick any number between 1 and 20." | |
show "You have 5 tries!" | |
number <- randomize using 1 to 20 | |
loop guessing: | |
starting with | |
guess <- 0 | |
end | |
guess <- guess + 1 | |
usernumber <- number_prompt | |
is usernumber < number ? then: | |
show 'The number is too low. Try again.' | |
end | |
or usernumber > number ? then: | |
show 'The number is too high. Try again.' | |
end | |
otherwise: | |
show 'You guessed it! Great job! You found my number!' | |
stop guessing | |
show "You guessed the number with this many tries: ", guess | |
end | |
is guess = 5 ? then: | |
stop guessing | |
show "That was your last guess." | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment