Spoof game: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(Spoof game in FreeBASIC) |
m (→{{header|Wren}}: Minor tidy) |
||
(One intermediate revision by one other user not shown) | |||
Line 9:
=={{header|C}}==
{{trans|Kotlin}}
<
#include <stdlib.h>
#include <time.h>
Line 147:
}
return 0;
}</
{{output}}
Line 199:
=={{header|FreeBASIC}}==
{{trans|Julia}}
<
Dim As Integer mon
While true
Line 247:
Color 15: Print "Another round? (Press X to exit, or another key to continue)"
Loop Until (Ucase(Input(1)) = "X")
End</
=={{header|Go}}==
{{trans|Kotlin}}
<
import (
Line 393:
}
}
}</
{{out}}
Line 447:
=={{header|Julia}}==
{{trans|Ring}}
<
while true
print("\n", prompt, " (supply an integer) => ")
Line 490:
spoofgamefortwo()
</
<pre>
How many games do you want? (supply an integer) => 2
Line 513:
=={{header|Kotlin}}==
This program has a TEST mode. If you set it to true, the number of coins allocated to each player for each round won't be erased after he/she presses ENTER, which allows you to check it is working out the total for the round correctly.
<
import java.util.Random
Line 601:
round++
}
}</
{{output}}
Line 677:
=={{header|Nim}}==
{{trans|Kotlin}}
<
const Test = true
Line 767:
randomize()
play()</
{{out}}
Line 825:
=={{header|Perl}}==
{{trans|Julia}}
<
use warnings;
use feature 'say';
Line 864:
}
spoof_for_2();</
{{out}}
<pre>How many games do you want? 1
Line 875:
=={{header|Phix}}==
<
if show then prompt &= sprintf(" from %d to %d",{lo,hi}) end if
printf(1,prompt&" : ")
Line 946:
{} = wait_key()
end procedure
main()</
{{out}}
<pre>
Line 980:
(formerly Perl 6)
{{trans|Perl}}
<syntaxhighlight lang="raku"
sub spoof_for_2 {
Line 1,010:
}
spoof_for_2();</
{{out}}
<pre>How many games do you want? 1
Line 1,024:
A little extra code was added to add verbiage for various error conditions.
<
parse arg seed .; if datatype(seed, 'W') then call random ,,seed /*use RANDOM seed? */
__= copies('─', 9) /*literal used in the game's prompting.*/
Line 1,058:
if ?==. & @pot+3>=# then do; say er "illegal input for guess:" #; iterate; end
#= # / 1; return #
end /*forever*/</
{{out|output|text=:}}
<pre>
Line 1,101:
=={{header|Ring}}==
<
# Project : Spoof game
Line 1,147:
ok
next
</syntaxhighlight>
Output:
<pre>
Line 1,181:
{{libheader|Wren-ioutil}}
{{libheader|Wren-math}}
<
import "./ioutil" for Input, Output, Stdin
import "./math" for Nums
var TEST = true // set to 'false' to erase each player's coins
Line 1,256:
first = (index2 < remaining.count - 1) ? remaining[index2 + 1] : remaining[0]
round = round + 1
}</
{{out}}
Line 1,316:
=={{header|zkl}}==
{{trans|Ring}}
<
reg mypot,yourpot,myguess,yourguess;
do{ mypot,myguess = (0).random(4),(0).random(7); // 0..3, 0..6
Line 1,338:
try{ return(ask(msg).strip().toInt()) }
catch{ println("ack"); return(self.fcn(msg)) } // tail recursion
}</
{{out}}
<pre style="height:35ex">
|