Jump to content

Pig the dice game/Player: Difference between revisions

Line 2,009:
=={{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.
 
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>
Module GamePig (games, strategy1, strategy2) {
Print "Game of Pig"
games=100
win1=0
win2=0
Line 2,033 ⟶ 2,037:
while res$<>"Q" {
Print "Player 1 turn"
PlayerTurn(&Player1points, &player1sum, player2sum, 8,! 10strategy1)
if res$="Q" then exit
Player1sum+=Player1points
Score()
Print "Player 2 turn"
PlayerTurn(&Player2points,&player2sum, player1sum, 12,! 20strategy2)
if res$="Q" then exit
Player2sum+=Player2points
Line 2,051 ⟶ 2,055:
}
}
\\ use stack as FIFO
If win1>win2 Then {
PrintData "StrategyPlayer 1 Win", win1;">";,win2, array(strategy1,0), array(strategy1,1)
} Else Print "Strategy 2 Win", win2;">";win1{
Data "Player 2 Win", win2,win1, array(strategy2,0), array(strategy2,1)
}
Sub Rolling()
Line 2,095 ⟶ 2,102:
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>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.