Pig the dice game/Player: Difference between revisions
Content added Content deleted
Line 2,009: | Line 2,009: | ||
=={{header|M2000 Interpreter}}== |
=={{header|M2000 Interpreter}}== |
||
Strategy like ADA, look if get 8 or more points and then look if other sum is lower from 100 from a min difference, and if it is true the choose Hold, else continue until win or dice=1. |
Strategy like ADA, look if get 8 or more points and then look if other sum is lower from 100 from a min difference, and if it is true the choose Hold, else continue until win or dice=1. |
||
This is version 2. |
|||
We play the same strategy pair two times, second in reverse |
|||
Even for 20+20 games strategy 12, 20 wins 8, 10 |
|||
<lang M2000 Interpreter> |
<lang M2000 Interpreter> |
||
Module GamePig { |
Module GamePig (games, strategy1, strategy2) { |
||
Print "Game of Pig" |
Print "Game of Pig" |
||
games=100 |
|||
win1=0 |
win1=0 |
||
win2=0 |
win2=0 |
||
Line 2,033: | Line 2,037: | ||
while res$<>"Q" { |
while res$<>"Q" { |
||
Print "Player 1 turn" |
Print "Player 1 turn" |
||
PlayerTurn(&Player1points, &player1sum, player2sum, |
PlayerTurn(&Player1points, &player1sum, player2sum, ! strategy1) |
||
if res$="Q" then exit |
if res$="Q" then exit |
||
Player1sum+=Player1points |
Player1sum+=Player1points |
||
Score() |
Score() |
||
Print "Player 2 turn" |
Print "Player 2 turn" |
||
PlayerTurn(&Player2points,&player2sum, player1sum, |
PlayerTurn(&Player2points,&player2sum, player1sum, ! strategy2) |
||
if res$="Q" then exit |
if res$="Q" then exit |
||
Player2sum+=Player2points |
Player2sum+=Player2points |
||
Line 2,051: | Line 2,055: | ||
} |
} |
||
} |
} |
||
\\ use stack as FIFO |
|||
If win1>win2 Then { |
If win1>win2 Then { |
||
Data "Player 1 Win", win1,win2, array(strategy1,0), array(strategy1,1) |
|||
} Else |
} Else { |
||
Data "Player 2 Win", win2,win1, array(strategy2,0), array(strategy2,1) |
|||
} |
|||
Sub Rolling() |
Sub Rolling() |
||
Line 2,095: | Line 2,102: | ||
End Sub |
End Sub |
||
} |
} |
||
Flush |
|||
GamePig |
|||
GamePig 20, (8,10), (12, 20) |
|||
GamePig 20, (12, 20), (8,10) |
|||
Print "Results" |
|||
While not Empty { |
|||
Read WhoWin$, winA,winb, Max_Points, Min_difference |
|||
Print WhoWin$, winA;">";winb, Max_Points, Min_difference |
|||
} |
|||
</lang> |
</lang> |