Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / strategy0:  The strategy function for Player 0, who plays first

strategy0:  The strategy function for Player 0, who plays first

Computer Science

strategy0:  The strategy function for Player 0, who plays first.

    strategy1:  The strategy function for Player 1, who plays second.

    score0:     Starting score for Player 0

    score1:     Starting score for Player 1

    dice:       A function of zero arguments that simulates a dice roll.

    goal:       The game ends and someone wins when this score is reached.

    say:        The commentary function to call at the end of the first turn.

 

>>> def echo(s0, s1):

...   print(s0, s1)

...   return echo

>>> strat0 = lambda score, opponent: 1 - opponent // 10

>>> strat1 = always_roll(3)

 

>>> s0, s1 = play(strat0, strat1, dice=make_test_dice(4, 2, 6), goal=15, say=echo)

 

The following function simulates a game and returns certain results. I do not understand the SAY=ECHO part of the function and what it does.

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Related Questions