Interactive Coin Toss Game with Scanner Functionality

 
 
 
 
T
H
Q0
C=’H’
(ACT 1)
C = 1 or 2 (‘H’ or ‘T’)
N = 1
C = ‘T’
(ACT 3)
Print N and stop
C = ‘T’
C=’T’
C=’H’
Q1
(ACT 2)
C = 1 or 2 (‘H’ or ‘T’)
N++
C=’H’
(ACT 2)
C = 1 or 2 (‘H’ or ‘T’)
N++
HT Game
Pick HH
Toss coins n times
until ‘HH’
Pick HT
Toss coins m times
until ‘HT’
n<m: HH wins by m-n
n>m: HT wins by n-m
 
 
 
 
T
H
Q0
C=’H’
(ACT 1)
C = 1 or 2 (‘H’ or ‘T’)
N = 1
C = ‘T’
(ACT 3)
Print N and stop
C = ‘T’
C=’T’
C=’H’
Q1
(ACT 2)
C = 1 or 2 (‘H’ or ‘T’)
N++
C=’H’
(ACT 2)
C = 1 or 2 (‘H’ or ‘T’)
N++
HT Game
Pick HH
Toss coins n times
until ‘HH’
Pick HT
Toss coins m times
until ‘HT’
n<m: HH wins by m-n
n>m: HT wins by n-m
 
 
 
 
Q1/Act2
T=6
Q9/Act4
Q8/Act3
Q5/Act1
Q0/Act1
T != 1,2
T=1,2
T=2 (alpha)
Q1
Act1: 
curChar=inBuf[j]
            T = charType(curChar)
Act2: 
curToken = curChar
            curType = T
            tokSpace = 7
Act3: 
curToken += curChar
            tokSpace -= 1
Act4: 
store curToken in tabToken
            clear curToken
HW
 
-
 
Scanner
Input string:
  loop: $t1, 3  #
 
 
 
 
Q1/Act2
T=6
Q9/Act4
Q8/Act3
Q5/Act1
Q3 /Act4
Q0/Act1
T != 1,2
T=1,2
T=3,4
T=2 (alpha)
Q0
Q1
Act1: 
curChar=inBuf[j]
            T = charType(curChar)
Act2: 
curToken = curChar
            curType = T
            tokSpace = 7
Act3: 
curToken += curChar
            tokSpace -= 1
Act4: 
store curToken in tabToken
            clear curToken
Scanner
Input string:
  loop: $t1,3 #
Q1/Act2
T=6
Q9/Act4
Q8/Act3
Q7/Act4
Q6/Act3
Q5/Act1
Q3 /Act4
Q2/Act1
Q0/Act1
T=1 (digit)
T=1
T != 1
T != 1,2
T=1,2
T=3,4
T=2 (alpha)
Q0
Q1
Q1
Act1: 
curChar=inBuf[j]
            T = charType(curChar)
Act2: 
curToken = curChar
            curType = T
            tokSpace = 7
Act3: 
curToken += curChar
            tokSpace -= 1
Act4: 
store curToken in tabToken
            clear curToken
Scanner
Input string:
  loop: $t1,3 #
 
 
 
 
Q1/Act2
T=6
Q9/Act4
Q8/Act3
Q7/Act4
Q6/Act3
Q5/Act1
Q3 /Act4
Q2/Act1
Q0/Act1
T=1 (digit)
T=1
T != 1
T != 1,2
T=1,2
T=3,4
T=5 (#)
T=2 (alpha)
Q4/Ret
Q0
Q1
Q1
Act1: 
curChar=inBuf[j]
            T = charType(curChar)
Act2: 
curToken = curChar
            curType = T
            tokSpace = 7
Act3: 
curToken += curChar
            tokSpace -= 1
Act4: 
store curToken in tabToken
            clear curToken
Scanner
Input string:
  loop: $t1,3 #
 
 
 
 
Q1/Act2
T=6
Q9/Act4
Q8/Act3
Q7/Act4
Q6/Act3
Q5/Act1
Q3 /Act4
Q2/Act1
Q0/Act1
T=1 (digit)
T=1
T != 1
T != 1,2
T=1,2
T=3,4
T=5 (#)
T=2 (alpha)
Q4/Ret
Q0
Q1
Q1
Act1: 
curChar=inBuf[j]
            T = charType(curChar)
Act2: 
curToken = curChar
            curType = T
            tokSpace = 7
Act3: 
curToken += curChar
            tokSpace -= 1
Act4: 
store curToken in tabToken
            clear curToken
Scanner State Diagram
Input string:
  loop: $t1,3 #
HW
 
-
 
Scanner
Data Structures
inBuf
j
curToken
curType
Token
Token Type
.
.
k
t
a
b
T
o
k
e
n
tabChar
curChar
T
Slide Note
Embed
Share

In this interactive game, players engage in a coin toss scenario where outcomes determine wins or losses based on specific patterns. Additionally, it features a scanner functionality that processes and categorizes input strings. The game mechanics involve making choices based on coin toss results, leading to various outcomes. Images depict the game interface and scanning process, highlighting the engaging elements of the game.

  • Interactive
  • Coin Toss
  • Game
  • Scanner Functionality
  • Pattern Recognition

Uploaded on Oct 09, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. HT Game HT Game Pick HT Pick HH Toss coins n times until HH Toss coins m times until HT n<m: HH wins by m-n n>m: HT wins by n-m (ACT 1) C = 1 or 2 ( H or T ) N = 1 Q0 C= H (ACT 2) C = 1 or 2 ( H or T ) N++ C= T (ACT 2) C = 1 or 2 ( H or T ) N++ H C= H C= H T C = T C = T Q1 (ACT 3) Print N and stop

  2. HT Game HT Game Pick HT Pick HH Toss coins n times until HH Toss coins m times until HT n<m: HH wins by m-n n>m: HT wins by n-m Q0 (ACT 1) C = 1 or 2 ( H or T ) N = 1 C= T C= H H T State\ C (ACT 2) C = 1 or 2 ( H or T ) N++ Q0 H T Q1 ACT1 ACT2 ACT2 ACT3 H H H - T T T - (ACT 2) C = 1 or 2 ( H or T ) N++ H C= H C= H T C = T C = T Q1 (ACT 3) Print N and stop

  3. HW HW - - Scanner Scanner Act1: curChar=inBuf[j] T = charType(curChar) Input string: loop: $t1, 3 # Act2: curToken = curChar curType = T tokSpace = 7 Q0/Act1 Act3: curToken += curChar tokSpace -= 1 T=6 Q1/Act2 Act4: store curToken in tabToken clear curToken T=2 (alpha) Q5/Act1 T=1,2 T != 1,2 Q8/Act3 Q9/Act4 Q1

  4. Scanner Scanner Act1: curChar=inBuf[j] T = charType(curChar) Input string: loop: $t1,3 # Act2: curToken = curChar curType = T tokSpace = 7 Q0/Act1 Act3: curToken += curChar tokSpace -= 1 T=6 Q1/Act2 Act4: store curToken in tabToken clear curToken T=2 (alpha) T=3,4 Q3 /Act4 Q5/Act1 Q0 T=1,2 T != 1,2 Q8/Act3 Q9/Act4 Q1

  5. Scanner Scanner Act1: curChar=inBuf[j] T = charType(curChar) Input string: loop: $t1,3 # Act2: curToken = curChar curType = T tokSpace = 7 Q0/Act1 Act3: curToken += curChar tokSpace -= 1 T=6 Q1/Act2 Act4: store curToken in tabToken clear curToken T=2 (alpha) T=1 (digit) T=3,4 Q3 /Act4 Q5/Act1 Q2/Act1 Q0 T=1,2 T != 1,2 T=1 T != 1 Q8/Act3 Q9/Act4 Q6/Act3 Q7/Act4 Q1 Q1

  6. Scanner Scanner Act1: curChar=inBuf[j] T = charType(curChar) Input string: loop: $t1,3 # Act2: curToken = curChar curType = T tokSpace = 7 Q0/Act1 Act3: curToken += curChar tokSpace -= 1 T=6 Q1/Act2 Act4: store curToken in tabToken clear curToken T=2 (alpha) T=1 (digit) T=3,4 T=5 (#) Q3 /Act4 Q4/Ret Q5/Act1 Q2/Act1 Q0 T=1,2 T != 1,2 T=1 T != 1 Q8/Act3 Q9/Act4 Q6/Act3 Q7/Act4 Q1 Q1

  7. Scanner State Diagram Scanner State Diagram Act1: curChar=inBuf[j] T = charType(curChar) Input string: loop: $t1,3 # Act2: curToken = curChar curType = T tokSpace = 7 Q0/Act1 Act3: curToken += curChar tokSpace -= 1 T=6 Q1/Act2 Act4: store curToken in tabToken clear curToken T=2 (alpha) T=1 (digit) T=3,4 T=5 (#) Q3 /Act4 Q4/Ret Q5/Act1 Q2/Act1 Q0 T=1,2 T != 1,2 T=1 T != 1 Q8/Act3 Q9/Act4 Q6/Act3 Q7/Act4 Q1 Q1

  8. HW HW - - Scanner Scanner Data Structures j inBuf tabChar tabToken curChar Token Type Token T k . . curToken curType

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#