Problem
1:
Write the ten-match game as explained below:
1)
There are ten matches at the start
2)
On each turn, you should remove either 1 or 2 matches
3)
The computer will respond accordingly
4)
After each turn, you will see the number of matches remaining
5)
Whoever selects the last match loses
Example
Output:
START GAME
Match Sticks on The Table = 10
Your Choice - Select 1 or 2
2
Matches left after your choice = 8
Computer's Choice - 2
Matches left after computer' choice = 6
Your Choice - Select 1 or 2
2
Matches left after your choice = 4
Computer's Choice - 1
Matches left after computer' choice = 3
Your Choice - Select 1 or 2
2
Matches left after your choice = 1
Human Won
Problem
2:
Start with your solution for Problem #1 and implement a reinforcement
learning strategy for computer’s turn as described in the program output below.
(Solution)
Example
Output:
START GAME
Match Sticks on The Table = 10
Your Choice - Select 1 or 2
1
Matches left after your choice = 9
Computer's Choice - 1
Matches left after computer' choice = 8
Computer's Choices so Far in this Game: 8
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 6
Computer's Choice - 1
Matches left after computer' choice = 5
Computer's Choices so Far in this game :
8 5
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
Your Choice - Select 1 or 2
1
Matches left after your choice = 4
Computer's Choice - 1
Matches left after computer' choice = 3
Computer's Choices so Far in this game :
8 5
3
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 1
Human Won
Play Again?
yes
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 -1
4 0
5 -1
6 0
7 0
8 -1
9 0
START GAME
Match Sticks on The Table = 10
Your Choice - Select 1 or 2
1
Matches left after your choice = 9
Computer's Choice - 2
Matches left after computer' choice = 7
Computer's Choices so Far in this game :
7
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 -1
4 0
5 -1
6 0
7 0
8 -1
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 5
Computer's Choice - 1
Matches left after computer' choice = 4
Computer's Choices so Far in this game :
7 4
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 -1
4 0
5 -1
6 0
7 0
8 -1
9 0
Your Choice - Select 1 or 2
1
Matches left after your choice = 3
Computer's Choice - 1
Matches left after computer' choice = 2
Computer's Choices so Far in this game :
7 4
2
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 0
3 -1
4 0
5 -1
6 0
7 0
8 -1
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 0
Computer Won
Play Again?
yes
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 1
3 -1
4 1
5 -1
6 0
7 1
8 -1
9 0
START GAME
Match Sticks on The Table = 10
Your Choice - Select 1 or 2
2
Matches left after your choice = 8
Computer's Choice - 1
Matches left after computer' choice = 7
Computer's Choices so Far in this game :
7
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 1
3 -1
4 1
5 -1
6 0
7 1
8 -1
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 5
Computer's Choice - 1
Matches left after computer' choice = 4
Computer's Choices so Far in this game :
7 4
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 1
3 -1
4 1
5 -1
6 0
7 1
8 -1
9 0
Your Choice - Select 1 or 2
2
Matches left after your choice = 2
Computer's Choice - 1
Matches left after computer' choice = 1
Computer's Choices so Far in this game :
7 4
1
Frequency Table for Computer's Choices
MATCHES
REMAINING SCORE
1 0
2 1
3 -1
4 1
5 -1
6 0
7 1
8 -1
9 0
Computer Won
Play Again?
No