Tip:
Highlight text to annotate it
X
Now I want to describe a family of strategies that I'm calling hold at n,
where n is an integer.
For example, hold at 20 is a strategy that keeps on rolling
until the pending score is greater than or equal to 20, and then it holds.
The point of this strategy is you get points by rolling,
but you risk points by rolling as well.
The higher the pending score is, the more you're risking.
So there should be some point at which you're saying that's too much of a risk.
I've accumulated so much pending that I don't want to risk any more,
and then I'm going to hold.
So hold at 10, hold at 20, hold at 30 describes that family of strategies.
I should say there's one subtlety here that we'll build in to hold at,
which is let's say that the goal is 50,
and my score when I start my round is say 40.
Then let's say I roll a 6 and a 4.
According to hold at 20 I should keep on rolling because my pending score is only 10.
I haven't gotten up to 20 yet, but it would be silly for me to keep rolling at that point.
I would risk pigging out and only scoring one point and getting to 41.
Whereas I know if I hold now I have 40 + 6 + 4 is 50.
I've already won the game.
So, hold at 20 will hold when pending is greater than or equal to 20,
or when you win by holding.
So, I want you to go ahead and implement that.
Since hold at x is a whole family of strategy of functions,
hold at x is not going to be a strategy function.
Rather, it's going to return a strategy function.
So I've given you this outline of saying we're going to define a strategy function,
then we're going to fix up it's name a little bit to describe it better.
Then we're going to return it.
You have to write the code within the strategy function.
I should say, we're going to stick with the representations of states,
where state is a four tuple of the player to move, zero one,
me and you score, and the pending score.