Spoof game: Difference between revisions
Content added Content deleted
(Created page with "{{Spoof game}} Create Spoof game. See details: [https://en.wikipedia.org/wiki/Spoof_(game) Spoof game] =={{header|Ring}}== <lang ring> # Project : Spoof game # Date : 201...") |
|||
Line 15: | Line 15: | ||
for n = 1 to games |
for n = 1 to games |
||
while true |
|||
mypot = random(3) |
|||
myguess = random(6) |
|||
if mypot + 3 > myguess |
|||
loop |
|||
else |
|||
exit |
|||
ok |
|||
end |
|||
see "I have put my pot and guess" + nl |
|||
while true |
|||
see "Your pot? " |
|||
give yourpot |
|||
see "Your guess? " |
|||
give yourguess |
|||
if ascii(yourpot) < 48 or ascii(yourpot) > 54 or ascii(yourguess) < 48 or ascii(yourguess) > 54 |
|||
loop |
|||
ok |
|||
if yourpot + 3 > yourguess |
|||
exit |
|||
else |
|||
see "Bad input! Try again" + nl |
|||
loop |
|||
ok |
|||
end |
|||
see "My put is: " + mypot + nl |
|||
see "My guess is: " + myguess + nl |
|||
pot = mypot + yourpot |
|||
if myguess = pot and yourguess = pot |
|||
see "Draw!" + nl |
|||
elseif myguess = pot |
|||
see "I won!" + nl |
|||
elseif yourguess = pot |
|||
see "You won!" + nl |
|||
else |
|||
see "No winner!" + nl |
|||
ok |
|||
next |
next |
||
</lang> |
</lang> |
Revision as of 09:37, 22 April 2018
Create Spoof game. See details: Spoof game
Ring
<lang ring>
- Project : Spoof game
- Date : 2018/04/22
- Author : Gal Zsolt (~ CalmoSoft ~)
- Email : <calmosoft@gmail.com>
spoof = 0:6 see "How many games you want? " give games
for n = 1 to games
while true mypot = random(3) myguess = random(6) if mypot + 3 > myguess loop else exit ok end see "I have put my pot and guess" + nl while true see "Your pot? " give yourpot see "Your guess? " give yourguess if ascii(yourpot) < 48 or ascii(yourpot) > 54 or ascii(yourguess) < 48 or ascii(yourguess) > 54 loop ok if yourpot + 3 > yourguess exit else see "Bad input! Try again" + nl loop ok end see "My put is: " + mypot + nl see "My guess is: " + myguess + nl pot = mypot + yourpot if myguess = pot and yourguess = pot see "Draw!" + nl elseif myguess = pot see "I won!" + nl elseif yourguess = pot see "You won!" + nl else see "No winner!" + nl ok
next </lang> Output:
How many games you want? 4 I have put my pot and guess Your pot? 1 Your guess? 3 My put is: 2 My guess is: 6 You won! I have put my pot and guess Your pot? 1 Your guess? 4 My put is: 2 My guess is: 5 No winner! I have put my pot and guess Your pot? 3 Your guess? 6 My put is: 3 My guess is: 6 Draw! I have put my pot and guess Your pot? 2 Your guess? 4 My put is: 0 My guess is: 5 No winner!