The Magic Card Teller

Intro

The way this game works is quite simple. When you run the game, the player is presented with a set of nine cards and is asked to remember a card from the list. Then the cards are divided into sets of 3. The player is then prompted with questions to check which of the three set has the card they chose in the beginning. The answers are limited to 'Yes' and 'No'. 
    After checking the user few times with questions, the computer "magically" determines what the chosen card is.

The Problems and the evolution of the Game

The game started as an interest and I was not exactly sure that this would be my final project. The beginning was the most frustrating and seemed like I was not getting anywhere. Although this was a relatively small project it did pose some interesting and difficult challanges for me throughout. I did opt to do a small project like this and then add Graphics at the end to make it look nice and increase its limitation which I think I was able to fulfil.

1. First Big Step 

RandomRelist[x_List] := 
        Block[{n = x, p}, 
          Do[p = Random[Integer, {1, i}]; 
            n[[{p, i}]] = n[[{i, p}]], {i, Length[x]}]; n]

The above function was what I initially used to generate the list of nine cards. I borrowed it from the Mathematica's in built functions. The module (the block actually) functioned exactly the way I wanted. I used it in the beginning stages in my program to generate my list of cards.

cards=RandomRelist[Range[9]]; (* generating a random list of number from 1 to 9 *)

set={{1,4,7},{2,5,8},{3,6,9}}; (* this is how the cards are divided into three groups *)
  
first={2,5,8,1,4,7,3,6,9};(* while the card is found in the first try put them in this order *)

second={1,4,7,2,5,8,3,6,9};(* while the card is found in the second try put them in this order *)

third={1,4,7,3,6,9,2,5,8};(* while the card is found in the third try put them in this order *)

The things above were my few steps of what the program initially looked like. I had divided the cards into three sets. In my later version the indeces take care of that. The first, second and third divided the cards in different possible orders as stated in the statement next to it. For example for 'first' it puts the card in {1,4,7}th position between the other two sets and redefines the list or cards. This way of defining things was not working as I can see now. It was very difficult to explain and was not global.

tally=Input[
      	"Is the card you chose any of these three     " <>
        ToString     [    cards   [[        set [[1]]        ]]      ] 
        
         <>"                      Answer in ---Yes---- and ----No----"
      	];

If [tally== yes, (cards=cards[[first]])  ];
Return[cards];

I had also used the Input function to get and use the input (Yes and No) from the player. Then I stored it in some variable and changed the list accordingly. The bold part with cards=cards[[first]] defined the cards in the first order. If second or third went into the first place it would be defined accordingly. 

Although all this was working it wasn't efficient for the whole program. I had trouble explaining the structure of my program.

2. Second Big Step

After much thinking I finally was able to plot my whole structure of my program onto my notebook. I divided my program into a tree structure. 
										Cards
								Yes					No
							Yes	     No	     			Yes	          		No
						Done		Yes	No		     Yes        No    	      Yes
							     Done       Yes		Done	 Yes     No	  Yes         No
							     	   Done			         Done    Yes      Done      Yes     No
							     	   				     Done	        Done    Yes
							     	   				     			     Done
							     	   				     			     
The structure suggested that there was a similar pattern through out the game. Yet I was not completely sure I could use that pattern as there was a slight difference in the pattern. Regardless this pattern game a clear idea what my game would be doing when and what were the extremes. For example I found any two Yes means the game is done. There could not be a three No in a row, which would mean the person is cheating.	       

After help from Jim I figured I could define 'Yes' and 'No' as a module itself, which meant that everytime Yes and No was typed it would execute the program. I tried the program the Brut force way. This resulted in a nested Yes and No. The thing below is rather long, but it shows how tedious Brut force way was. If you look at the tree structure above it is seen, I was not even done for the left chunk that came after the first Yes. A Yes had Yes and No in it, The No then had Yes and No again and so on.

(* Picks are just to keep track what level the programming is on, 
  not to get confuse with the Yes and No *)
Pick=1; 
Yes:= 
  Module[{},
    cards=cards[[first]]; (* Re arrange the cards in first order *) 
    Print[cards];
    Print[
      "Is the card you chose any of these three     " <>        
        ToString     [    cards   [[        set   [[1]]        ]]      ]
      	];
    Print["Answer in 'Yes' and 'No' "];
    
    (* This is a Yes inside Yes *)
         Pick=2;
    	Yes:= 
      	Module[{},
        	cards=cards[[first]];
        	Print[cards];
        	Print   [
          		
          "The card you chose was    "       <>
            		
            ToString[  cards    [[5]]    ]
          		     ];
        		   ]; (* End of Pick 2 Yes Module *)
    
    	Pick=2;
    	No:=
      	Module[{},
        	Print[cards];
        	Print[
          		"Is the card you chose any of 
            				these three     " <>      
            		ToString     [   cards   [[       set [[2]]       ]]      ]
          		  ];
        	Print["Answer in 'Yes' and 'No' "];
        
        	Pick=3;
        	Yes:=
          	Module[{},
            		cards=cards[[second]]; 
            		(* Re arrange the cards in second order *)
            		
            Print[cards];
            		Print[
              			"The card you chose was     " <>        
                			ToString    [    cards   [[5]]    ]
              			    ];
            		      ];
          
          At this point I was desperately trying to see the pattern and was trying to write a general program that followed the pattern that was completely recognizable in the tree structure but still was not completely clear enough in my head. The Brut force way was driving me nuts as I easily lost track of myself in the program and the braces gave me alot of trouble.

I went though a period of head banging period.   

3. Third Big Step

After much thinking some things started to seem more clear and evident. Some ideas emerged. You can see in the Brut force way that I used pick to keep track of myself. I thought maybe I could use that in the game somehow. Also I thought about Yes and No function globally. Spent some time thinking what was the general funtion of Yes and No. I tried writing it down in words in my notebook. Once again the notebook was of help, breaking things sparkled some ideas in my head. 

I tried programming what I wrote down in words. I played around with deleting cards and placing them in the list in the desired place. I called it the putInBtwin function.

indeces ={1,4,7};
values = list[[indeces]]

putInBtwin:= 
  Module[{},
    	Do[
      	list = Delete[list,indeces[[i]]];
      	,{i,Length[indeces],1,-1}
      	];
    	list;
    	list = Flatten[Insert[list,values,4]];
    ]
    Basically the purpose of the function was to delete the 3 cards indeces was pointing at and insert it back in the middle of the list. This basically would be the Yes function.
    
    For No, I had to increase the indeces by 1 at every position which meant in second turn the indeces would be pointing at {2,5,7} and {3,6,9} later. Then  I just had to ask the question. I felt great at that time. Things felt to be getting somewhere.
    
    Still little problems didn't let go off me. The game worked fine for cards in certain position but was not working for some cards. It took me a while before I realized that I had to re evaluate the values of the indeces position and stuff.
    
    At last the game worked, I was really happy. After much effort and time it was working. But now the game looked really small and did not seem the output of the effort that I put in. I guess that's programming. I though about beautification of the program now. Enhancing it a bit.
    
    4. Fourth Not so big but Important Step

    Graphics was what I wanted to add to the Game. I wanted to represent the number that I showed the players with cards or a similar graphical representation. The numbers in list did not seem very appealing. So I played around with graphics for a while. I wanted to add number inside a rectangle making it look like a card. Instead came up with a better idea dots to represent numbers. Played around with Line and Disk functions till the output was what I exactly wanted. Few hours and the result was exactly what I wanted.

card1 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.5, 1}, 0.1]},  AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

Show[card1]

Now I had to show the cards instead of numbers.It took me a while after stumbling through many problems to make the program work well with the graphics.The problem I had was producing a group of graphics in an array.I tried to put a do loop,but that spitted the result one below the other and not across the screen.So I defined and saved each card in a seperate name.I then put those name in a list and have it spit out in an array form.That worked perfect.

(* first:=GraphicsArray  [listOfCards     [[cards    [[1]]    ]]    ]; *)
I then put these in an array form 
(*Show[GraphicsArray[{first,second, third, fourth, fifth, sixth, seventh, 
        eight, ninth}], ImageSize->740];*)

I did similar thing with the cards pointing at the indeces.I defined them seperately too.
(* firstIndeces:=  GraphicsArray  [     listOfCards     [[cards      [[indeces  [[1]]   ]]              ]]    ]; *)

The graphics then worked perfectly fine. 

The only thing I would say about adding on to this Graphic would be to make it real card looking, 3-d graphics and cards flipping around maybe. But I personally thought, the idea I came out with was more simple, innovative (me being an artist and stuff and blah blah you know) and unique.

5. Fifth and Final - Buttons

Buttons for me were the most problematic. Regardless it was a lot of fun experementing the possibilities. I came really close to what I wanted. The only thing I screwed up was the selection. The cursor position was always difficult to locate and thus gave a lot of trouble because the buttons popped up where the cursor was last clicked and not where you wanted or thought should have popped. 

Play the game Button works fine and the Yes and No button works almost as desired with small glitch. Button Function could have been better and certainly is one of the area I could improve on.

Altogether it is a nice game with pleasing graphics.

For More Information on any of the above writings, you can visit my home drive
wwww.marlboro.edu/~srana/fall2004/Game Folder
the game folder is labelled Game Progress and goes from Game Progress.nb to Game Progress7.nb, each one with added features and improvement I achieved throughout the game. The above writing is an interpretation of the programs that the Game Progress files are.

For any question or queries email me at ~ srana@marlboro.edu.

Trying out some of the smaller version of the program and graphics, and looking at how the Game works

The first thing I needed for the game was to generate a set of nine cards which could not repeat itself and had to be in a random order everytime the game was run. The following set of commnads lets you do that. First I define a list of nine numbers. Then I apply the function Permutations to generate each and every possible way of putting these nine numbers - which comes out to be 9! (factorial) or 362880 different sets. I save these values in a variable named perm. Then I access one of the set, out of the total 362880 sets, saved in perm in random. So every time cards is evaluated, the function is going to pick a set of nine randomly. Try it

list = {1, 2, 3, 4, 5, 6, 7, 8, 9};
perm = Permutations[list];

cards =  
      perm[[   Random[Integer,  {1, 362880}]     ]]

Major part of my game funtions around two comments/input which being 'Yes' and 'No'. When a Yes is typed or clicked certain action has to be executed and when a No is typed/clicked some different action. Yes function is similar at every step with slight differences, so is No function. 

What happens when Yes is the input?

-the counter of numYes is increased.
-putInBtwin function is executed.
-indeces is set to {1,4,7} everytime Yes module is run.
-the values of the card at the indeces position is defined.
-and depending on the counter of Yes (counter numYes at 2 means win) either the result is displayed or the set of three cards at position {1,4,7} is displayed.

- The major task of the Yes function is built in the "putInBtwin" function. When 'Yes' is the input, it implies that the card is in the set that is being shown to the player. So the putInBtwin funtion takes that set of cards, removes it from the list (defined as "cards" above). Now the list only has six cards in it. Now the program finds the middle of the remaining cards (as I knew it was 6 cards, I stated the middle as 4) by some simple mid point formula. Then the program places the 3 cards that was removed in the 4th, 5th and 6th position and redefines the list ( or cards).

To know what cards are to be deleted,we check with the indeces funtion which starts at{1,4,7}th positions of the list and goes till {3,6,9}th positions, with an increment of 1 in each position.

What happens when No is the input?

-the counter numNo is incremented
-indeces is increased by 1 at every position
-conditional statement is set to check if the user is cheating. It is done simply by checking the numNo counter and the indeces (numNo at 3 and indeces at {3,6,9} means cheating).
-if the conditional statement  above is not fulfilled, the next line is executed which is simply displaying the cards at the indeces positions.

This is how indeces and values work. indeces points at certain places. Values state what number are at those positions. indeces+ increases the positions in indeces by a digit. The 'No' function basically works with these three simple function.

cards

\(\(\(indeces\)\(\ \)\(=\)\({1, 4, 7}\)\(\ 	\)\)\)

values  =  cards[[indeces]]

indeces += {1, 1, 1};

Graphics
As the game was simple and not too flashy, I decided to add some graphics to it. So that it is aesthetically pleasing to the player and interesting. Below are some of the details of the graphics that I have used.

The graphics I have used is made out of simple geometrical drawings. The card is made out of a rectangular border with disks inside them.

card1 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.5, 1}, 0.1]},  AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

Show[card1]

The rectangle is nothing but lines bordering a region, which can be seen above, defined with five points,each one consisting of x and y coordinate. Similarly the Disk is described with the center of origin followed by the radius of the disk. The disk by default is filled. The AspectRatio as by its definition calculates the aspect of the drawing, whereas the imagesize determines how big of a rectangle is the card going to be placed in. It is the pixel size(windows in some case). I played around with the sizes till it looked right, so it is basically figured from trial and error method. The random function generates a random color for every card every time the program is executed.

The cards are defined as an array for convenienve reason.

Buttons
Another feature of the game are the buttons. I added on the buttons in the later stages. It was also for aesthetic reason and for user interaction featuring mouse. As mathematica is very picky about capitalisation issues, I figured buttons would be handy tool instead of having to type the Yes and No and to run the Game itself too. The buttons were very problematic and it was difficult for me to keep track of the cursor after a button is pressed (selection issues), so everytime the buttons are pressed, the user has to place the cursor (selection) right below it. Still it is really cool to have them. 

Buttons are created with quite a few steps. These are the funtion required to built, place and give the button a task.
- doButtonClick = This module basically creates or executes the module drawButton
- makeButtonYes = This module returns the button and determines the function of the button. In this case is to make a new button and execute Yes module, defined earlier in the game
- makeButtonNo = This module is similar to one above except this executes the No module.
- makeButtonContentYes = This module returns the stuff that should be shown within the button Yes.    
- makeButtonContentNo = This module returns the stuff that should be shown within the button No.
- makeButtonCell = This module returns the cell that has the button in it (both makeButtonYes and makeButtonNo are called in this function)
- drawButton = This module selects the current notebook and writes the makeButton cell function. This function actually puts everything together and draws the buttons.

\(\(\( (*Return\ the\ \(\(button\)\(.\)\)*) \)\(
\)\(makeButtonYes := 
ButtonBox[
makeButtonContentYes, 
ButtonFunction :> 
            Module[{}, doButtonClick[]; \ Yes], \  (*\ 
            ButtonFunction\ determines\ what\ the\ button\ is\ supposed\ to\ do\ *) 
ButtonEvaluator -> 
            Automatic, 
Active -> 
            True, 
ButtonStyle -> "None"];\)\)\)

makeButton by itself does not do anything like drawButton. But it has to be called by another function like such:

makeButtonCell := 
        Cell[BoxData[
            GridBox[{{makeButtonYes,  makeButtonNo}}]]];

this function draws the buttons 'Yes' and 'No', with their relative function. Just remember to place the cursor after the drawButton

drawButton;

Programming Bits

Off[General::spell1]

list = {1, 2, 3, 4, 5, 6, 7, 8, 9};    
perm = Permutations[list];

(* Generating Graphics for the cards:*)

card1 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.5, 1}, 0.1]},  AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card2 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1]}, 
          AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card3 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1]}, AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card4 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1]}, 
          AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card5 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1],  
            Disk[{0.5, 1.4}, 0.1]}, AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card6 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1],  
            Disk[{0.5, 1.4}, 0.1], Disk[{0.5, 1.6}, 0.1]}, 
          AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card7 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1],  
            Disk[{0.5, 1.4}, 0.1], Disk[{0.5, 1.6}, 0.1],  
            Disk[{0.5, 0.8}, 0.1]}, AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card8 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1],  
            Disk[{0.5, 1.4}, 0.1], Disk[{0.5, 1.6}, 0.1],  
            Disk[{0.5, 0.8}, 0.1],  Disk[{0.5, 0.6}, 0.1] }, 
          AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

card9 := 
        Graphics[{RGBColor[Random[], Random[], Random[]], 
            Line[{{0, 0}, {1, 0}, {1, 2}, {0, 2}, {0, 0}}],  
            Disk[{0.7, 1}, 0.1],  Disk[{0.5, 1}, 0.1],  
            Disk[{0.3, 1},  0.1],  Disk[{0.5,  1.2}, 0.1],  
            Disk[{0.5, 1.4}, 0.1], Disk[{0.5, 1.6}, 0.1],  
            Disk[{0.5, 0.8}, 0.1],  Disk[{0.5, 0.6}, 0.1], 
            Disk[{0.5, 0.4}, 0.1] }, AspectRatio ->  3/2,  
          ImageSize -> {90, 90}];

\(\(\(
\)\(
\)\(\(game[] := 
Module[{}, 

numYes = 0; \  (*\ counter\ for\ ' 
            Yes'\ *) 
 (*\ \(Print["The value of numYes is" <> ToString[
                  numYes]];\)\ *) 

numNo = 0; \  (*\ counter\ for\ ' 
            No'\ *) 

cards = \ 
          perm[\([\ \ \ Random[Integer, \ {1, 362880}]\ \ \ \ \ ]\)]; \  (*\ 
          generating\ a\ random\ list\ of\ number\ from\ 1\ to\ 9\ *) 

indeces\  = {1, 4, 7}; \  (*\ 
          pointing\ at\ which\ cards\ the\ index\ is\ pointing\ on\ *) 
	
values\  = \ cards[\([indeces]\)]; \  (*\ 
          the\ cards\ that\ are\ in\ the\ position\ of\ the\ indeces*) 

listOfCards = {{card1}, {card2}, {card3}, {card4}, \ {card5}, \ {card6}, \ {card7}, \ {card8}, \ {card9}}; \  (*\ placing\ the\ graphics\ generated\ above\ into\ a\ list\ *) 

 (*\ 
          giving\ each\ graphic\ a\ value, \ 
          so\ that\ when\ required\ each\ card\ can\ be\ pulled\ out\ seperately\ and\ then\ placed\ in\ an\ array\ *) 

first := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([1]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
second := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([2]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
third := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([3]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
fourth := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([4]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
fifth := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([5]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
sixth := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ [\([6]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
seventh := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ \ [\([7]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
eight := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ [\([8]\)]\ \ \ \ ]\)]\ \ \ \ ]; 
ninth := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ \ [\([9]\)]\ \ \ \ ]\)]\ \ \ \ ]; 

 (*\ 
          Same\ as\ for\ graphic\ values, \ 
          I\ seperate\ the\ indeces\ value . \ 
              Although\ the\ cards\ in\ the\ list\ changes\ from\ when\ the\ game\ starts\ till\ the\ end, \ 
          the\ indeces\ position\ points\ to\ the\ position\ and\ not\ to\ the\ specific\ card\ *) 

firstIndeces := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ \ \ [\([indeces\ \ [\([1]\)]\ \ \ ]\)]\ \ \ \ \ \ \ \ \ \ \ \ \ \ ]\)]\ \ \ \ ]; 
secondIndeces := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ \ \ [\([indeces\ \ [\([2]\)]\ \ \ ]\)]\ \ \ \ \ \ \ \ \ \ \ \ \ \ ]\)]\ \ \ \ ]; 
thirdIndeces := 
          GraphicsArray\ \ [
            listOfCards\ \ \ \ \ [\([cards\ \ \ \ \ \ [\([indeces\ \ [\([3]\)]\ \ \ ]\)]\ \ \ \ \ \ \ \ \ \ \ \ \ \ ]\)]\ \ \ \ ]; 

 (*\ 
          this\ module\ deletes\ 3\ cards\ from\ the\ list\ defined\ in\ the\ indeces\ position, \ redefines\ the\ list, \ 
          and\ puts\ the\ pulled\ out\ cards\ in\ the\ center\ of\ the\ list\ *) 
putInBtwin := 
Module[{}, 
	
            Do[
	\(cards\  = \ 
                  Delete[cards, indeces\ \ [\([i]\)]\ \ \ \ ];\)\  (*\ 
                Deletes\ the\ 3\ cards\ the\ indeces\ is\ pointing\ at\ *) 
	, {i, Length[indeces], 
                1, \(-1\)}\ \ 
	]; 
	
            cards; 
	
            cards\  = \ 
              Flatten[Insert\ \ \ [cards, values, 4]\ \ \ \ ]; \  (*\ 
              Adds\ the\ 3\ card\ from\ above\ in\ the\ 4  
                th\ place\ and\ flattens\ the\ list\ *) 
	
            values\  = \ 
              cards[\([indeces]\)];
	]; 

Print["Choose a card from the list below and remember it"]; 

Print[
          cards]; 
Show[
          GraphicsArray[{first, second, \ third, \ fourth, \ fifth, \ 
              sixth, \ seventh, \ eight, \ ninth}], \ 
          ImageSize -> 740]; 

Pause[
          8]; 
Print["Is the card you chose any of these three     "\  <> 
            ToString\ \ \ \ \ [\ \ \ \ cards\ \ [\([indeces]\)]\ \ \ \ \ \ ]
	]; 
Show[
          GraphicsArray\ \ [{firstIndeces, \ secondIndeces, \ 
              thirdIndeces}\ ]\ \ \ \ ]; 
Print["Answer in 'Yes' and 'No' "]; 


Yes := \ 
Module[{}, 
numYes = numYes + 1; \  (*\ 
              Increases\ the\ counter\ of\ Yes\ everytime\ ' 
                Yes \*"" is typed "*) 
 (*\ \(Print["The value of numYes is" <> 
                    ToString[
                      numYes]];\)\ *) 

putInBtwin; 
indeces\  = {1, 4, 7}; \  (*\ Everytime\ Yes\ is\ typed, \ 
              sets\ the\ indeces\ back\ to\ {1, 4, 
                  7}\ *) 
values\  = \ 
              cards[\([indeces]\)]; \  (*\ Re\ defines\ the\ values, \ 
              erasing\ the\ earlier\ stored\ data\ *) 

 (*\ 
              Print[cards]; 
Show[
                GraphicsArray[{first, second, \ third, \ fourth, \ fifth, \ 
                    sixth, \ seventh, \ eight, \ ninth}], \ 
                ImageSize -> 
                  740];\ *) 

\ 
            If[
	numYes == 2, \ 
              Print["The card you chose was"]; 
Show[
                GraphicsArray[{fifth}]]; 
 (*\ \(Print\ \ [	"The card you chose was    "\ \ \ \ \ \ \  <> 		ToString[\ \ cards\ \ \ \ [\([5]\)]\ \ \ \ ]	\ \ \ ];\)\ *) \ \ \ \ \ \ \ \ \ 
\ 
              Return[]
\ \ \ \ \ \ ]; \  (*\ 
              the\ game\ is\ done\ when\ the\ counter\ of\ num\ is\ 2, \ 
              returns\ from\ the\ program\ and\ spits\ out\ the\ statement\ out\ the\ print\ statement\ *) 

Print["Is the card you chose any of these three     "\  <> 
                ToString\ \ \ \ \ [\ \ \ \ cards\ \ [\([indeces]\)]\ \ \ \ \ \ ]
	]; 
Show[
              GraphicsArray\ \ [{firstIndeces, \ secondIndeces, \ 
                  thirdIndeces}\ ]\ \ \ \ ];
]; \  (*\ 
          end\ of\ Yes\ Module\ *) 


 (*\ 
          When\ typed\ ' 
            No'\ by\ the\ user\ the\ value\ of\ the\ indeces\ is\ increased\ by\ 1, \ and\ the\ same\ question\ is\ asked\ again\ *) 
No := Module[{}, 
numNo = numNo + 1; \  (*\ 
              Everytime\ the\ No\ program\ is\ run\ the\ counter\ is\ increased\ *) 

indeces += {1, 1, 
                1}; \  (*\ 
              Everytime\ ' 
                No'\ is\ typed\ the\ counter\ increases\ by\ one\ position\ *) 
If[
              numNo == 3\  && \ indeces == {3, 6, 9}, \ 
              Print[" Hey caught you cheating, the cards had to be in one of the set"]; \ 
Return[]\ \ 
]; 

values\  = \ 
              cards[\([indeces]\)]; \  (*\ 
              Re\ defines\ the\ data\ stored\ in\ values\ *) 

 (*\ 
              Print[cards]; 
Show[
                GraphicsArray[{first, second, \ third, \ fourth, \ fifth, \ 
                    sixth, \ seventh, \ eight, \ ninth}], \ 
                ImageSize -> 
                  740];\ *) 


Print["Is the card you chose any of these three     "\  <> ToString\ \ \ \ \ [\ \ \ \ cards\ \ [\([indeces]\)]\ \ \ \ \ \ ]
	]; 
Show[
              GraphicsArray\ \ [{firstIndeces, \ secondIndeces, \ 
                  thirdIndeces}\ ]\ \ \ \ ];

]


]\)\(;\)\( (*\ 
      Module\ bracket\ for\ the\ Game\ *) \)\(
\)\)\)\)

Trying to figure button click functions..

(*What to do when the button is clicked.*) 
doButtonClick[] := 
        Module[{}, 
drawButton;
];

\(\(\( (*Return\ the\ Yes\ \(\(button\)\(.\)\)*) \)\(
\)\(\(makeButtonYes := 
ButtonBox[
makeButtonContentYes, 
ButtonFunction :> 
            Module[{}, doButtonClick[]; \ Yes], \  (*\ 
            defines\ what\ the\ button\ does\ when\ clicked\ *) 
ButtonEvaluator -> 
            Automatic, 
Active -> 
            True, 
ButtonStyle -> "None"];\)\(
\)
    \)\)\)

\(\(\( (*Return\ the\ No\ \(\(button\)\(.\)\)*) \)\(
\)\(makeButtonNo := 
ButtonBox[
makeButtonContentNo, 
ButtonFunction :> 
            Module[{}, doButtonClick[]; \ 
              No], 
ButtonEvaluator -> 
            Automatic, 
Active -> 
            True, 
ButtonStyle -> "None"];\)\)\)

makeButtonContentYes := 
        Cell[BoxData[RowBox[{"Yes"}]], "Input"];

makeButtonContentNo := 
        Cell[BoxData[RowBox[{"No"}], "Input"]];

makeButtonCell := 
        Cell[BoxData[
            GridBox[{{makeButtonYes,  
                  makeButtonNo}}]]   ];

\(\(\( (*In\ the\ current\ notebook, 
      write\ a\ new\ \(\(makeButtonCell\)\(.\)\)*) \)\(
\)\(\(drawButton := 
        Module[{nb}, 
nb = SelectedNotebook[]; \  (*\ 
            selects\ the\ notebook\ that\ is\ currently\ open\ *) 
 (*\ \(NotebookFind[nb, theGame, All, 
                CellTags];\)\ *) \ 
NotebookWrite[nb, 
            makeButtonCell, All]; \  (*\ writes\ the\ makeButtonCell, \ 
            which\ draws\ the\ button, \ 
            in\ the\ notebook\ that\ is\ currently\ selected\ *) 
	];\)\(
\)\(
\)
    \)\)\)

Game

game[]

Play the Game