In class we played a game called “Double Trouble”, which consists of:
• Three (3) green markers,
• Seven (7) yellow markers, and
• Five (5) orange markers.
Two players take turns removing as many markers of a single color as they wish.
The player who removes the last marker wins.
1. “Double Trouble” is really a particular instantiation of the fundamental combinatorial game. What is the real name of the game, who “solved” it, and
when? Where does it show up in popular culture? [2 bonus points]
2. Write a C++ program to play “Double Trouble”. Your program should contain
the input/output functionality necessary to have the user decide who goes first
and enter (only!) legal moves in alternation with the computer. The computer
need not play well but should declare a winner when appropriate and then
should terminate correctly. [10 points]
3. Write the necessary C++ code that will allow the computer to make a winning
move whenever such a move is available to it. You may do this in any way you
wish. It can be a stand-alone function or internal to the main program. You
may use built-in operators or design your own routine. [5 points]
4. Put it all together into a coherent package. The computer should win when it
has a winning strategy and should make random moves when it does not. Also,
the random moves should be independent from one run of the game to another.
That is, if you play in such a way that you win, the computer should not lose
the same way each time. [15 points]
Also, feel free to personalize your game. Have it play a best-of-(2n + 1)
tournament, alternating who moves first or randomly deciding who moves first.
Have your program celebrate in victory or whimper in defeat. It may not cheat,
however. No springs, honest weight!
The overall purpose here is to get you to dig in to C++ and get familiar with
whatever IDE (Integrated Development Environment) you/we choose to use.
The first part requires basic setup (#include, variable definition, etc.), input/output statements, branching (if ), and looping (for, while), perhaps. The
concepts transfer easily from Java, but they require a little attention.
The second part requires computations, procedures, and functions (perhaps).
The third part requires the rand() and srand() functions (perhaps) and some
additional setup to make them work.
Strategy recap: