Pig the dice game: Difference between revisions

no edit summary
m (→‎{{header|REXX}}: added whitespace.)
No edit summary
Line 2,204:
end
</lang>
=={{header|M2000 Interpreter}}==
 
<lang M2000 Interpreter>
Module GamePig {
Print "Game of Pig"
dice=-1
res$=""
Player1points=0
Player1sum=0
Player2points=0
Player2sum=0
HaveWin=False
score()
while res$<>"Q" {
Print "Player 1 turn"
PlayerTurn(&Player1points, &player1sum)
if res$="Q" then exit
Player1sum+=Player1points
Score()
Print "Player 2 turn"
PlayerTurn(&Player2points,&player2sum)
if res$="Q" then exit
Player2sum+=Player2points
Score()
}
If HaveWin then {
If Player1Sum>Player2sum then {
Print "Player 1 Win"
} Else Print "Player 2 Win"
}
Sub Rolling()
dice=random(1,6)
Print "dice=";dice
End Sub
Sub PlayOrQuit()
Print "R -Roling Q-Quit"
Repeat {
res$=Ucase$(Key$)
} Until Instr("RQ", res$)>0
End Sub
Sub PlayAgain()
Print "R -Roling H -Hold Q-Quit"
Repeat {
res$=Ucase$(Key$)
} Until Instr("RHQ", res$)>0
End Sub
Sub PlayerTurn(&playerpoints, &sum)
PlayOrQuit()
If res$="Q" then Exit Sub
playerpoints=0
Rolling()
While dice<>1 and res$="R" {
playerpoints+=dice
if dice>1 and playerpoints+sum>100 then {
sum+=playerpoints
HaveWin=True
res$="Q"
} Else {
PlayAgain()
if res$="R" then Rolling()
}
}
if dice=1 then playerpoints=0
End Sub
Sub Score()
Print "Player1 points="; Player1sum
Print "Player2 points="; Player2sum
End Sub
}
GamePig
</lang>
=={{header|Maple}}==
<lang maple>pig := proc()
Anonymous user