# Game Levels 4 Tic Tac Toe (Single Player)

Single Player Game

In single player game you may provide at least three levels, like EASY, MEDIUM and HARD.

You know it's a two player game so when the user will select to play with Single Player then the opponent player will be system(like Phone or PC).
So in this game when the player will moves his turn, system will move the turn automatically. No we have to decide that how to instruct the system to move its turn on which blank pad, Now I am going to briefly describe about the instruction for the computer/phone/any system.

Label: EASY

In this level you may instruct the system to move its turn randomly on blank pad.
What You should keep in mind at this level:

STEP 1

Count all blank PAD(which is not marked by any player(either by player or phone) and put all blank pads name into:

List<string>

Note: Where pad is a button control.
[WHERE : PAD denotes all nine boxes on which user marks their move either by O or X ]
Example

Now put all the blank pad's name into this List of string (allBlankPad)
STEP 2

Generate random number from 0 to Count(total no of blank pad -1)
STEP 3

Here buttons is the random index  of blank pad

Example Code

Label: MEDIUM
Label
STEP 1

STEP 2

Check all the win condition for opponent , If opponent has two consecutive marked pad then marked the pad to prevent them to won otherwise generate a random number from 0 to total number of blankpad+1 and mark the blank pad which suggested by random number.
You may use the following logic to do it.

Example Code
2. {
5.       //IF Total Playe's MArked Pad=1
7.       {
9.             {
10.                   case "btnOne": haveToMarkAsMobilePad = "btnFifth"break;
11.                   case "btnTwo": haveToMarkAsMobilePad = "btnFifth"break;
12.                   case "btnThree": haveToMarkAsMobilePad = "btnFifth"break;
13.                   case "btnFourth": haveToMarkAsMobilePad = "btnFifth"break;
14.                   case "btnFifth": haveToMarkAsMobilePad = "btnOne"break;
15.                   case "btnSixth": haveToMarkAsMobilePad = "btnFifth"break;
16.                   case "btnSeventh": haveToMarkAsMobilePad = "btnFifth"break;
17.                   case "btnEighth": haveToMarkAsMobilePad = "btnFifth"break;
18.                   case "btnNinth": haveToMarkAsMobilePad = "btnFifth"break;
19.                   defaultbreak;
20.             }
21.       }
22. //IF Total Playe's MArked Pad=2
23.       else if (countPad == 2)
24.       {
26.             {
27.                   case "btnOne":
29.                   {
32.                         else
34.                   }
35.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
36.                   {
39.                         else
41.                   }
42.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
43.                   {
46.                         else
48.                   }
49.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
50.                   {
53.                         else
55.                   }
56.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
57.                   {
60.                         else
62.                   }
63.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
64.                   {
67.                         else
69.                   }
70.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
71.                   {
74.                         else
76.                   }
77.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
78.                   {
81.                         else
83.                   }
84.                   break;
85.                   case "btnTwo":
87.                   {
90.                         else
92.                   }
93.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
94.                   {
97.                         else
99.                   }
100.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
101.                   {
104.                         else
106.                   }
107.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
108.                   {
111.                         else
113.                   }
114.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
115.                   {
118.                         else
120.                   }
121.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
122.                   {
125.                         else
127.                   }
128.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
129.                   {
132.                         else
134.                   }
135.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
136.                   {
139.                         else
141.                   }
142.                   break;
143.                   case "btnThree":
145.                   {
148.                         else
150.                   }
151.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
152.                   {
155.                         else
157.                   }
158.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
159.                   {
162.                         else
164.                   }
165.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
166.                   {
169.                         else
171.                   }
172.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
173.                   {
176.                         else
178.                   }
179.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
180.                   {
183.                         else
185.                   }
186.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
187.                   {
190.                         else
192.                   }
193.                  else if (playerAllMarkedPad[1].ToString() == "btnNinth")
194.                  {
197.                         else
199.                   }
200.                   break;
201.                   case "btnFourth":
203.                   {
206.                         else
208.                   }
209.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
210.                   {
213.                         else
215.                   }
216.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
217.                   {
220.                         else
222.                   }
223.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
224.                   {
227.                         else
229.                   }
230.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
231.                   {
234.                         else
236.                   }
237.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
238.                   {
241.                         else
243.                   }
244.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
245.                   {
248.                         else
250.                   }
251.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
252.                   {
255.                         else
257.                   }
258.                   break;
259.                      case "btnFifth":
261.                   {
264.                         else
266.                   }
267.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
268.                   {
271.                         else
273.                   }
274.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
275.                   {
278.                         else
280.                   }
281.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
282.                   {
285.                         else
287.                   }
288.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
289.                   {
292.                         else
294.                   }
295.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
296.                   {
299.                         else
301.                   }
302.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
303.                   {
306.                         else
308.                   }
309.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
310.                   {
313.                         else
315.                   }
316.                   break;
317.                   case "btnSixth":
319.                   {
322.                         else
324.                   }
325.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
326.                   {
329.                         else
331.                   }
332.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
333.                   {
336.                         else
338.                   }
339.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
340.                   {
343.                         else
345.                   }
346.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
347.                   {
350.                         else
352.                   }
353.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
354.                   {
357.                         else
359.                   }
360.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
361.                   {
364.                         else
366.                   }
367.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
368.                   {
371.                         else
373.                   }
374.                   break;
375.                   case "btnSeventh":
377.                   {
380.                         else
382.                   }
383.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
384.                   {
387.                         else
389.                   }
390.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
391.                   {
394.                         else
396.                   }
397.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
398.                   {
401.                         else
403.                   }
404.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
405.                   {
408.                         else
410.                   }
411.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
412.                   {
415.                         else
417.                   }
418.                   else if (playerAllMarkedPad[1].ToString() == "btnEighth")
419.                   {
422.                         else
424.                   }
425.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
426.                   {
429.                         else
431.                   }
432.                   break;
433.                   case "btnEighth":
435.                   {
438.                         else
440.                   }
441.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
442.                   {
445.                         else
447.                   }
448.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
449.                   {
452.                         else
454.                   }
455.                   else if (playerAllMarkedPad[1].ToString() == "btnFourth")
456.                   {
459.                         else
461.                   }
462.                   else if (playerAllMarkedPad[1].ToString() == "btnFifth")
463.                   {
466.                         else
468.                   }
469.                   else if (playerAllMarkedPad[1].ToString() == "btnSixth")
470.                   {
473.                         else
475.                   }
476.                   else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
477.                   {
480.                         else
482.                   }
483.                   else if (playerAllMarkedPad[1].ToString() == "btnNinth")
484.                   {
487.                         else
489.                   }
490.                   break;
491.                   case "btnNinth":
493.                   {
496.                         else
498.                   }
499.                   else if (playerAllMarkedPad[1].ToString() == "btnTwo")
500.                   {
503.                         else
505.                   }
506.                   else if (playerAllMarkedPad[1].ToString() == "btnThree")
507.                   {
510.                         else
512.             }
513.             else if (playerAllMarkedPad[1].ToString() == "btnFourth")
514.             {
517.                   else
519.             }
520.             else if (playerAllMarkedPad[1].ToString() == "btnFifth")
521.             {
524.                   else
526.             }
527.             else if (playerAllMarkedPad[1].ToString() == "btnSixth")
528.             {
531.                   else
533.             }
534.             else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
535.             {
538.                   else
540.             }
541.             break;
542.       }
543. }
544. //IF Total Playe's MArked Pad=2
545. else if (countPad == 3)
546. {
548.       {
549.       case "btnOne":
550.       //All Possible Wind Condition with btnOne[ 123,159,147 ]
551.       //[1. For 123 position ]
553.       {
557.             else
559.             }
560.             else if (playerAllMarkedPad[1].ToString() == "btnThree")
561.             {
565.                   else
567.             }
568.             //[2. For 147 position
569.             else if (playerAllMarkedPad[1].ToString() == "btnFourth")
570.             {
574.                   else
576.             }
577.             else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
578.             {
582.                   else
584.             }
585.             //[3. For 159 position ]
586.             else if (playerAllMarkedPad[1].ToString() == "btnFifth")
587.             {
591.                   else
593.             }
594.             else if (playerAllMarkedPad[1].ToString() == "btnNinth")
595.             {
599.                   else
601.             }
602.             else
603.             {
606.             }
607.             break;
608.             case "btnTwo":
609.             //All Possible Wind Condition with btnOne[ 258,123 ]
610.             //[1. For 258 position ]
612.             {
616.                   else
618.             }
619.             else if (playerAllMarkedPad[1].ToString() == "btnEighth")
620.             {
624.                   else
626.             }
627.             //[2. For 123 position ]
628.             else if (playerAllMarkedPad[1].ToString() == "btnOne")
629.             {
633.                   else
635.             }
636.             else if (playerAllMarkedPad[1].ToString() == "btnThree")
637.             {
640.                   else
642.             }
643.             else
644.             {
647.             }
648.             break;
649.             case "btnThree":
650.             //All Possible Wind Condition with btnOne[ 123,357,369 ]
651.             //[1. For 123 position ]
653.             {
657.                   else
659.             }
660.             else if (playerAllMarkedPad[1].ToString() == "btnOne")
661.             {
665.                   else
667.             }
668.             //[2. For 357 position ]
669.             else if (playerAllMarkedPad[1].ToString() == "btnFifth")
670.             {
674.                   else
676.             }
677.             else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
678.             {
682.                   else
684.             }
685.             else
686.             {
689.             }
690.             break;
691.             case "btnFourth":
692.             //All Possible Wind Condition with btnOne[ 147,456 ]
693.             //[1. For 147 position ]
695.             {
699.                   else
701.             }
702.             else if (playerAllMarkedPad[1].ToString() == "btnOne")
703.             {
707.                   else
709.             }
710.             //[1. For 456 position ]
711.             else if (playerAllMarkedPad[1].ToString() == "btnFifth")
712.             {
716.                   else
718.             }
719.             else if (playerAllMarkedPad[1].ToString() == "btnSixth")
720.             {
724.                   else
726.             }
727.             else
728.             {
731.             }
732.             break;
733.             case "btnFifth":
734.             //All posible win condition [456, 257]
735.             //[1. For 456 position ]
737.             {
741.                   else
743.             }
744.             else if (playerAllMarkedPad[1].ToString() == "btnSixth")
745.             {
749.                   else
751.             }
752.             //[ for 258 position ]
753.             else if (playerAllMarkedPad[1].ToString() == "btnTwo")
754.             {
758.                   else
760.             }
761.             else if (playerAllMarkedPad[1].ToString() == "btnEighth")
762.             {
766.                   else
768.             }
769.             else
770.             {
773.             }
774.             break;
775.             case "btnSixth":
776.             //For all wind condition with 6
777.             //[1. For 456 position ]
779.             {
783.                   else
785.             }
786.             else if (playerAllMarkedPad[1].ToString() == "btnFifth")
787.             {
791.                   else
793.             }
794.             //[ For 3,6,6 position ]
795.             else if (playerAllMarkedPad[1].ToString() == "btnThree")
796.             {
800.                   else
802.             }
803.             else if (playerAllMarkedPad[1].ToString() == "btnNinth")
804.             {
808.                   else
810.             }
811.             else
812.             {
815.             }
816.             break;
817.             case "btnSeventh":
818.             //[1. For 147 position ]
820.             {
824.                   else
826.             }
827.             else if (playerAllMarkedPad[1].ToString() == "btnOne")
828.             {
832.                   else
834.             }
835.             //[1. For 789 position ]
836.             else if (playerAllMarkedPad[1].ToString() == "btnEighth")
837.             {
841.                   else
843.             }
844.             else if (playerAllMarkedPad[1].ToString() == "btnNinth")
845.             {
849.                   else
851.             }
852.             else
853.             {
856.             }
857.             break;
858.             case "btnEighth":
859.             //All posible win conditions with 8
860.             //[1. For 258 position ]
862.             {
866.                   else
868.             }
869.             else if (playerAllMarkedPad[1].ToString() == "btnTwo")
870.             {
874.                   else
876.             }
877.             //[1. For 789 position ]
878.             else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
879.             {
883.                   else
885.             }
886.             else if (playerAllMarkedPad[1].ToString() == "btnNinth")
887.             {
891.                   else
893.             }
894.             else
895.             {
898.             }
899.             break;
900.             case "btnNinth":
901.             //All posible win conditions with 9
902.             //[1. For 159 position ]
904.             {
908.                   else
910.             }
911.             else if (playerAllMarkedPad[1].ToString() == "btnOne")
912.             {
916.                   else
918.             }
919.             //For 369 positions ]
920.             else if (playerAllMarkedPad[1].ToString() == "btnSixth")
921.             {
925.                   else
927.             }
928.             else if (playerAllMarkedPad[1].ToString() == "btnThree")
929.             {
933.                   else
935.             }
936.             else
937.             {
940.             }
941.             break;
942.       }
943. }
944. //IF Total Playe's MArked Pad=2
945. else if (countPad == 4)
946. {
948.       {
950.             {
951.                   case "btnOne":
964.                   else
965.                   {
968.                   }
969.                   break;
970.                   case "btnTwo":
983.                   else
984.                   {
987.                   }
988.                   break;
989.                   case "btnThree":
1002.                   else
1003.                   {
1006.                   }
1007.                   break;
1008.                   case "btnFourth":
1017.                   else
1018.                   {
1021.                   }
1022.                   break;
1023.                   case "btnFifth":
1036.                   else
1037.                   {
1040.                   }
1041.                   break;
1042.                   case "btnSixth":
1051.                   else
1052.                   {
1055.                   }
1056.                   break;
1057.                   case "btnSeventh":
1070.                   else
1071.                   {
1074.                   }
1075.                   break;
1076.                   case "btnEighth":
1085.                   else
1086.                   {
1089.                   }
1090.                   break;
1091.                   case "btnNinth":
1104.                   else
1105.                   {
1108.                   }
1109.                   break;
1110.             }
1111.             //Switch End
1112.       }
1113. }