## ← 05-36 Using Tools

• 1 Follower
• 95 Lines

dummy description

### Get Embed Code x Embed video Use the following code to embed this video. See our usage guide for more details on embedding. Paste this in your document somewhere (closest to the closing body tag is preferable): ```<script type="text/javascript" src='https://amara.org/embedder-iframe'></script> ``` Paste this inside your HTML body, where you want to include the widget: ```<div class="amara-embed" data-url="http://www.youtube.com/watch?v=5vNE938l6JA" data-team="udacity"></div> ``` 1 Language

Showing Revision 1 created 05/13/2012 by Amara Bot.

1. So now let's go back and analyze this maximize differential strategy
2. versus the maximizing probability of winning strategy.
3. The question is, how do these 2 compare?
4. When are they different, and when are they the same?
5. If you're trying to impress the scouts, you're not going to be making some crazy moves,
6. so probably most of the time, you'd expect the 2 strategies to agree,
7. but some of the time, maybe 1 of them is going to be more aggressive
8. or taking more chances than the other.
9. Let's see if we can analyze that.
10. So I start off by defining a bunch of states, and I'm just going to look
11. from 1 player's point of view.
12. It doesn't really matter to have both since it's symmetric,
13. so for all these values of me, you, and pending, collect all those states.
14. It turns out that there's 35,000 of them.
15. Then I define a variable r to be a default dictionary, which counts up integers,
16. so it starts at 0, and then I go through all the states,
17. and I increment the count for a result for the tuple of the action that's taken by
18. max_wins and the action that's taken by max_diffs.
19. I want to count up.
20. This is going to be hold, hold, roll, roll. etc.
21. I want to see how many of each do we have,
22. and let's convert r back to standard dict, and there we have it.
23. So most of the time, 29,700 out of the 35,000--both strategies agree that roll
24. is the right thing to do.
25. Then another 1200 times, both strategies agree that hold is the right thing to do.
26. But in 2 cases, they differ.
27. So sometimes, max_wins says hold and max_diffs says roll.
28. That happened 381 times, but 10 times more often, it's max_wins that says roll
29. and max_diff that says hold.
30. That actually surprised me.
31. So it's the max_wins strategy that's really more aggressive.
32. It's rolling more often.
33. I thought it was going to be the max_diffs strategy.
34. I thought that was going to be more aggressive, right?
35. So that's the one that's trying to impress the scouts.
36. I thought it was going to be rolling trying to rack up a really big score.
37. But no! So the data tells a different story.
38. It's not trying to rack up a really big score.
39. So what's going on?
40. Well, first it might be nice just to quantify how different they are
41. since I kind of asked that question.
42. So there's 35, 301 states all together and they differ on 3975 + 381,
43. and that's 12% of the states that they differ on.
44. So what's the story?
45. Where do those 12% of the states come from?
46. We still don't know, and we don't even quite know what questions to ask,
47. but it's here that some of our design choices start to pay off.
48. So remember we always start our design with an inventory of concepts,
49. and we have things like the dice and the score,
50. and then we got into things like the utility function and the quality function,
51. so we built all these up, and yes, we're building from the ground up,
52. and yes, at the top, we have a play_pig function, and we can still call that function,
53. but at the bottom, we have all these useful tools.
54. So now when we're not just about playing pig, now we're trying to analyze the situation
55. to understand this story of why are these 2 different?
56. Well, play_pig by itself--the top level function we define--that's not going to help us,
57. but all these little tools that we built down here, they will be helpful.
58. We can start to put them together and explore.
59. So we built this tower, and the tower built up to define the play pig function,
60. and in some languages, it's all about building the tower.
61. When you're done, that's all you have.
62. But in Python, it's common and in many languages, it's a good design and strategy
63. to say let's just build up components along the way so that we--yes, we have the tower,
64. but we can also go out in other directions.
65. If we're interested--not just in playing pig--but we're interested in figuring out this story,
66. then we can quickly assemble pieces from down here
67. and build something that can address that.
68. So I've got all the pieces available. It makes it easy to explore.
69. But I still need an idea, and here's my idea.
70. I expected maximize differential to be aggressive, to try to rack up the big points,
71. and I found out that it was actually maximizing the probability of winning
72. that was more aggressive that rolled more often.
73. Why could that be? I think I might know the answer.
74. I think it might be that the maximized differential is more willing to lose
75. rather than more excited about winning by a lot.
76. What do I mean by that?
77. Well, if you're maximizing the probability of winning,
78. you don't care if you lose by 1 or if you lose by 40,
79. it's all a loss.
80. The maximized differential--if he's losing by a fair amount, he might say,
81. well--say he's behind 39-0 in a game to 40,
82. and say he's accumulated 30 points,
83. If he's trying to maximize the probability of winning,
84. he would keep on rolling.
85. He says, well, I don't have that good of a chance of winning,
86. but all that counts is winning.
87. If I stop now, the opponent's going to win on the next move,
88. so I've got to keep rolling.
89. Probably I'll pig out and only get 1 point, but it's worth it for that small chance of winning.
90. That's what the maximize win probability strategy would do.
91. The maximize differential strategy would say, hey, if I can get 30 points rather than 1,
92. that cuts the differential way down, so that's worth doing.
93. I'll sacrifice winning in order to maximize the differential.
94. Now that's a suggestion of a story, but I don't know yet.
95. Is that the right story? Let's find out.