Pig the dice game/Player: Difference between revisions
Content added Content deleted
m (→{{header|Sidef}}: modified the code to work with Sidef 2.30) |
|||
Line 2,348: | Line 2,348: | ||
;; (n-runs 1000 (n-rounds 5) (n-random 2)) |
;; (n-runs 1000 (n-rounds 5) (n-random 2)) |
||
</lang> |
</lang> |
||
The following example run demonstrates the output from |
|||
<lang Racket>(pig-the-dice #:print? #t (n-points 12) (n-rounds 4))</lang> |
|||
Where <code>n-points</code> is a strategy where the user continues to roll until the specified number of points is gained and <code>n-rounds</code> is a strategy where the users rolls the specified number of times each round. |
|||
<pre> |
|||
Status: Player 1, 0 points; Player 2, 0 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 4 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 9 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 11 points |
|||
Player 1, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 16 points |
|||
Player 1, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 16 points; Player 2, 0 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 6 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 12 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 15 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 20 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 16 points; Player 2, 20 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 2 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 4 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 10 points |
|||
Player 1, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 16 points |
|||
Player 1, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 32 points; Player 2, 20 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 5 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 7 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 9 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 12 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 32 points; Player 2, 32 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 6 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 11 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 13 points |
|||
Player 1, round #4, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 32 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 3 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 32 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 2 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 6 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 32 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 5 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 7 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 13 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 15 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 47 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 47 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 47 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 2 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 7 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 47 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 5 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 11 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 17 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 20 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 67 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 4 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 67 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 3 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 6 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 8 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 11 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 78 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 3 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 7 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 11 points |
|||
Player 1, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 78 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 2 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 7 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 78 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 3 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 78 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 45 points; Player 2, 78 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 5 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 9 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 11 points |
|||
Player 1, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 16 points |
|||
Player 1, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 61 points; Player 2, 78 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 4 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 6 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 9 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 15 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 61 points; Player 2, 93 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 5 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 8 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 10 points |
|||
Player 1, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 12 points |
|||
Player 1, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 73 points; Player 2, 93 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 6 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 10 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 14 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 1 => turn lost |
|||
-------------------- |
|||
Status: Player 1, 73 points; Player 2, 93 points. |
|||
Player 1, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 3 => 3 points |
|||
Player 1, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 7 points |
|||
Player 1, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 13 points |
|||
Player 1, round #4, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Status: Player 1, 86 points; Player 2, 93 points. |
|||
Player 2, round #1, [R]oll or [P]ass? R |
|||
Dice roll: 2 => 2 points |
|||
Player 2, round #2, [R]oll or [P]ass? R |
|||
Dice roll: 6 => 8 points |
|||
Player 2, round #3, [R]oll or [P]ass? R |
|||
Dice roll: 4 => 12 points |
|||
Player 2, round #4, [R]oll or [P]ass? R |
|||
Dice roll: 5 => 17 points |
|||
Player 2, round #5, [R]oll or [P]ass? P |
|||
-------------------- |
|||
Player 2 wins! |
|||
2 |
|||
</pre> |
|||
=={{header|REXX}}== |
=={{header|REXX}}== |