Game Description Player 1: Decides on integer x > 0

Slides:



Advertisements
Similar presentations
Games Game 1 Each pair picks exactly one whole number The lowest unique positive integer wins Game 2: Nim Example: Player A picks 5, Player B picks 6,
Advertisements

Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Time for playing games Form pairs You will get a sheet of paper to play games with You will have 12 minutes to play the games and turn them in.
The Marriage Problem Finding an Optimal Stopping Procedure.
The possible outcomes are 2 + 2, 2 + 3, 2 + 4, 3 + 2, 3 + 3, 3 + 4, 4 + 2, 4 + 3, The probability of an even sum is ____. The probability of an.
6 Sums of Games.. Lecture6 Admin Plagiarism forms Answer football cup final problem. //Daisy Problem hints e.g. try a smaller size. General problem solving.
Probability Distributions. We need to develop probabilities of all possible distributions instead of just a particular/individual outcome Many probability.
Even more problems.. Mean (average) I need a program that calculates the average of student test scores. I need a program that calculates the average.
Lesson 10.5 AIM: The Game of Pig. DO NOW What is a strategy? Give an example from your daily life of how you use strategies.
Number lines, fractions and knowing where you are.
COMP Loop Statements Yi Hong May 21, 2015.
Chapter 14 Genetic Algorithms.
Hypothesis testing and statistical decision theory
Chapter 8: Estimating with Confidence
Encountering Euler's Number
Some more Decrease-and-conquer Algorithms
Chapter 8: Estimating with Confidence
CSc 110, Spring 2017 Lecture 12: Random Numbers
Recitation #3 Tel Aviv University 2016/2017 Slava Novgorodov
Intro to Computer Science CS1510 Dr. Sarah Diesburg
Determining the theoretical probability of an event
Python - Iteration Iteration
C ODEBREAKER Class discussion.
Chapter 8: Inference for Proportions
Lecture 12.
Copyright © Cengage Learning. All rights reserved.
A R R A Y ! for Multiplication!!
CS330 Discussion 4 Spring 2017.
Learning to Program in Python
4 Probability Lesson 4.8 Combinations and Probability.
Pick a number, any number …
More Loops.
Intro to Computer Science CS1510 Dr. Sarah Diesburg
We’re moving on to more recap from other programming languages
Choose the best answer for each problem.
random number between 1 and 5.
COUNTING AND PROBABILITY
Writing Functions( ) (Part 4)
Matthew Renner, Trish Beeksma, Patch Kenny
Chapter 8: Estimating with Confidence
The first number is posted telling what random number was selected, I did this for testing purposes, in the real thing it would not be there. Since the.
Strike it out.
Building a Game in Scratch
Chapter 8: Estimating with Confidence
Chapter 8: Estimating with Confidence
Chapter 8: Estimating with Confidence
Basic Lessons 5 & 6 Mr. Kalmes.
Chapter 8: Estimating with Confidence
Chapter 8: Estimating with Confidence
Unit 2: Computational Thinking, Algorithms & Programming
Chapter 7 Empowering Programs with Math
Chapter 8: Estimating with Confidence
Chapter 8: Estimating with Confidence
Factor Game Sample Game.
Chapter 8: Estimating with Confidence
The Game of Estimation point 3 points 2 points
6.5 Find Expected Value MM1D2d.
Randomized Algorithms
Exploratory Challenge: Game Show—Picking Blue!
Chapter 8: Estimating with Confidence
Primary School Computing
Randomized Algorithms
Starter Look at the hand-out.
The storytelling icon game
Iteration – While Loops
Let’s play a game….
GCSE Computing.
A R R A Y ! for Multiplication!!
Surveys How to create one.
Whose is it? Game.
Presentation transcript:

Game Description Player 1: Decides on integer x > 0 Player 2 : Has to find a number yn so that yn  x Rules: Player 2: y1< y2< …< yn y1< y2< …< yn-1 < x and yn  x On a guess yj, player 1 either says: smaller than x, please provide a next guess larger or equal x, and reveals x stopping the game

Optimization Criteria Let the guesses be y1, y2, ….yn, so that yn  x yj < x for all j  n – 1 The optimization criteria is the performance ratio:

Programming Examples 1. Write a C program that randomly generates the number to guess and ask user to provide the guesses. The program will calculate and print the performance ratio for one game 2. Write a C program that randomly generates the number to guess and ask user to provide the guesses. The program will calculate and print the performance ratio for 10 games and also calculates the average of performance ratios for 10 games. 3. Modification of example 2: let user decide on amount of games that user would like to play and output the average performance ratio over all games.

EXAMPLE 76 Performance Ratio 118 / 37 = 3.189189 1 3 10 28 Player 1 Player 2 x is chosen, please provide a guess Smaller than x, next guess 1 Smaller than x, next guess 3 Smaller than x, next guess 10 Smaller than x, next guess 28 STOP! x = 37 76 Performance Ratio 118 / 37 = 3.189189

EXAMPLE 23 Performance Ratio (1+2+3+4+23) / 5 = 6.6 1 2 3 4 Player 1 Player 2 x is chosen, please provide a guess Smaller than x, next guess 1 Smaller than x, next guess 2 Smaller than x, next guess 3 Smaller than x, next guess 4 STOP! x = 5 23 Performance Ratio (1+2+3+4+23) / 5 = 6.6

The Powers of 2 Strategy for the Second Player It turns out that the simple strategy that selects powers of 2: y0 = 1, y1 = 2, y2 = 4, … yi = 2i … is an optimal deterministic strategy for this game The worst case for the strategy is when the number selected by the first player is x = 2j + 1 In this case the game is played until the second player suggests 2j+1

EXAMPLE x = 13 x = 65 guesses: 1, 2, 4, 8, 16 sum: 1+2+4+8+16 = 31 performance ratio is 2.384615 x = 65 guesses: 1, 2, 4, 8, 16, 32, 64, 128 sum: 1+2+4+8+16+32+64+128 = 255 performance ratio is 3.923

A Randomized Strategy The following simple randomized strategy gives an improved expected value Let  R [0, 1) – randomly and uniformly chosen from interval [0, 1) Define yj = exp( j +  ) Let i be so that exp( i - 1 +  ) < x  exp( i +  ) The expected performance ratio is:

EXAMPLE Performance Ratio 129 / 48 = 2.6875  = 0.419 STOP! x = 48 Player 1 Player 2 x is chosen, please provide a guess  = 0.419 Smaller than x, next guess exp() = 1 Smaller than x, next guess exp(+1) = 4 Smaller than x, next guess exp(+2) = 11 Smaller than x, next guess exp(+3) =30 STOP! x = 48 exp(+4) = 83 Performance Ratio 129 / 48 = 2.6875

EXAMPLE Performance Ratio 201 / 63 = 3.190476  = 0.866 STOP! x = 63 Player 1 Player 2 x is chosen, please provide a guess  = 0.866 Smaller than x, next guess exp() = 2 Smaller than x, next guess exp(+1) = 6 Smaller than x, next guess exp(+2) = 17 Smaller than x, next guess exp(+3) =47 STOP! x = 63 exp(+4) = 129 Performance Ratio 201 / 63 = 3.190476

Smaller than x, next guess Smaller than x, next guess EXAMPLE Player 1 Player 2 x is chosen, please provide a guess  = 0.195 Smaller than x, next guess exp() = 1 Smaller than x, next guess exp(+1) = 3 STOP! x = 6 exp(+2) = 8 Performance Ratio 12 / 6 = 2.0000

Discussion Questions Discussion of the Optimization Criteria selection: Why not to choose yi/x, where yi  x? Answer: simple strategy 1, 2, 3, …is optimal Discussion of possible strategies: Why not to start with some “large” number? Why do we not benefit from increasing the next guess only a little compared to the previous guess? What is the disadvantage of making the next guess, say, 100 times larger than previous guess?