Objective: To create a production system to play a dice game
Task: To write a Python module to make decisions in playing the dice game
Dice Combinations | Points |
Five-in-a-row | Sum of dice + 70 |
Straight (1-2-3-4-5, 2-3-4-5-6) | Sum of dice + 60 |
Full house (Three + Two of a kind) | Sum of dice + 50 |
Four-of-a-kind (Four + One) | Sum of dice + 40 |
Three-of-a-kind (Three + one + One) | Sum of dice + 30 |
Other combinations | Sum of dice |
class Player :
def __init__ ( self , . . . ) :
. . .
def play ( self , dice_face , available_rerolls ):
. . .
return [ . . . ] #indices of dice to be rerolled
class Player :
create a class with the name Player
def play ( self , dice_face , available_rerolls ):
1. create a method called play for the class
2. inputs:
return [ . . . ] #indices of dice to be rerolled
1. return a list from the function play
2. the list contains the indices of dice (in dice_face) to be rerolled
3. an empty list implies the player would like to stop rerolling for the current game
1. At the beginning of a game, the dice will be rolled. For example, the result of the initial roll is 6,6,5,3,1
dice_face = [6,6,5,3,1]
available_rerolls = 5
2. If the player decides to keep the two sixes, i.e. the dice with index 0 and 1, the return value of the play function is [2,3,4] as the dice with index 2, 3, and 4 are to be rerolled.