Pig the dice game/Player: Difference between revisions
Content added Content deleted
m (→{{header|Sidef}}: modified the code to work with the latest version of Sidef) |
m (→{{header|Sidef}}: minor code simplifications) |
||
Line 2,585: | Line 2,585: | ||
class Player(score=0, ante, rolls, strategy={false}) { |
class Player(score=0, ante, rolls, strategy={false}) { |
||
method turn { |
method turn { |
||
rolls = 0; |
|||
ante = 0; |
|||
loop { |
loop { |
||
rolls++; |
|||
given (var roll = DIE.rand) { |
given (var roll = DIE.rand) { |
||
when (1) { |
when (1) { |
||
ante = 0; |
|||
break; |
break; |
||
} |
} |
||
when (roll > 1) { |
when (roll > 1) { |
||
ante += roll; |
|||
} |
} |
||
} |
} |
||
((score + ante >= GOAL) || strategy) && break; |
((score + ante >= GOAL) || strategy) && break; |
||
} |
} |
||
score += ante; |
|||
} |
} |
||
} |
} |