Game Description - PowerPoint PPT Presentation

About This Presentation
Title:

Game Description

Description:

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 – PowerPoint PPT presentation

Number of Views:29
Avg rating:3.0/5.0
Slides: 13
Provided by: yana150
Learn more at: https://cs.widener.edu
Category:

less

Transcript and Presenter's Notes

Title: Game Description


1
Game Description
  • Player 1 Decides on integer x gt 0
  • Player 2 Has to find a number yn so that yn ?
    x
  • Rules
  • Player 2 y1lt y2lt lt yn
  • y1lt y2lt lt yn-1 lt 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

2
Optimization Criteria
  • Let the guesses be y1, y2, .yn, so that
  • yn ? x
  • yj lt x for all j ? n 1
  • The optimization criteria is the
  • performance ratio

3
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.

4
EXAMPLE
Player 1
Player 2
x is chosen, please provide a guess
1
Smaller than x, next guess
3
Smaller than x, next guess
10
Smaller than x, next guess
28
Smaller than x, next guess
76
STOP! x 37
Performance Ratio 118 / 37 3.189189
5
EXAMPLE
Player 1
Player 2
x is chosen, please provide a guess
1
Smaller than x, next guess
2
Smaller than x, next guess
3
Smaller than x, next guess
4
Smaller than x, next guess
23
STOP! x 5
Performance Ratio (123423) / 5 6.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 2j1

7
EXAMPLE
  • x 13
  • guesses 1, 2, 4, 8, 16
  • sum 124816 31
  • performance ratio is 2.384615
  • x 65
  • guesses 1, 2, 4, 8, 16, 32, 64, 128
  • sum 1248163264128 255
  • performance ratio is 3.923

8
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 ? )? lt x ? ?exp( i
    ? )?
  • The expected performance ratio is

9
EXAMPLE
Player 1
Player 2
x is chosen, please provide a guess
? 0.419
?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
Smaller than x, next guess
?exp(?4)? 83
STOP! x 48
Performance Ratio 129 / 48 2.6875
10
EXAMPLE
Player 1
Player 2
x is chosen, please provide a guess
? 0.866
?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
Smaller than x, next guess
?exp(?4)? 129
STOP! x 63
Performance Ratio 201 / 63 3.190476
11
EXAMPLE
Player 1
Player 2
x is chosen, please provide a guess
? 0.195
?exp(?)? 1
Smaller than x, next guess
?exp(?1)? 3
Smaller than x, next guess
STOP! x 6
?exp(?2)? 8
Performance Ratio 12 / 6 2.0000
12
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?
Write a Comment
User Comments (0)
About PowerShow.com