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
List<string> allBlankPad =new List<string>()
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)
int buttons = randomPad.Next(0, allBlankPad.Count - 1);
STEP 3
Mark the pad at: allBlankPad[buttons]
Here buttons is the random index of blank pad
Example Code
int buttons = randomPad.Next(0, allBlankPad.Count - 1);
string haveToMarkAsMobilePad = allBlankPad[buttons].ToString();
Label: MEDIUM
Label
Find the allBlankPad, allPlayerMarkedPad and SystemMarkedPad and keep them into List<string> or ArrayList
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
- public string Medium(List<string> playerAllMarkedPad, List<string> allMobileMarkedPad, List<string> allBlankPad)
- {
- countPad = playerAllMarkedPad.Count;
- haveToMarkAsMobilePad = "Empty";
-
- if (countPad == 1)
- {
- switch (playerAllMarkedPad[0].ToString())
- {
- case "btnOne": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnTwo": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnThree": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnFourth": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnFifth": haveToMarkAsMobilePad = "btnOne"; break;
- case "btnSixth": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnSeventh": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnEighth": haveToMarkAsMobilePad = "btnFifth"; break;
- case "btnNinth": haveToMarkAsMobilePad = "btnFifth"; break;
- default: break;
- }
- }
-
- else if (countPad == 2)
- {
- switch (playerAllMarkedPad[0].ToString())
- {
- case "btnOne":
- if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() == "btnTwo")
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFourth")
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnTwo":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnEighth")
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFifth")
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnThree":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnTwo")
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFifth")
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnFourth":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFifth")
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnFifth":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnEighth")
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFourth")
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnTwo")
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnSixth":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFifth")
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFourth")
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnSeventh":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFourth")
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnFifth")
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnEighth")
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnEighth":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnTwo")
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnNinth")
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- case "btnNinth":
- if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSixth")
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnSeventh")
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- if (allMobileMarkedPad[0].ToString() != "btnThree")
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- if (allMobileMarkedPad[0].ToString() != "btnEighth")
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- break;
- }
- }
-
- else if (countPad == 3)
- {
- switch (playerAllMarkedPad[0].ToString())
- {
- case "btnOne":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- haveToMarkAsMobilePad = "btnThree";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- haveToMarkAsMobilePad = "btnTwo";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- haveToMarkAsMobilePad = "btnSeventh";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- haveToMarkAsMobilePad = "btnFourth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnNinth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnTwo":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnEighth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- if (playerAllMarkedPad[2].ToString() != "btnOne")
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnThree":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- haveToMarkAsMobilePad = "btnOne";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- haveToMarkAsMobilePad = "btnTwo";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnSeventh";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnFourth":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- haveToMarkAsMobilePad = "btnOne";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- haveToMarkAsMobilePad = "btnSeventh";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnSixth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnFifth":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- haveToMarkAsMobilePad = "btnSixth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- haveToMarkAsMobilePad = "btnFourth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- haveToMarkAsMobilePad = "btnEighth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- haveToMarkAsMobilePad = "btnTwo";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnSixth":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnFourth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- haveToMarkAsMobilePad = "btnNinth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- haveToMarkAsMobilePad = "btnThree";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnSeventh":
-
- if (playerAllMarkedPad[1].ToString() == "btnFourth")
- {
- haveToMarkAsMobilePad = "btnOne";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- haveToMarkAsMobilePad = "btnFourth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFourth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnEighth")
- {
- haveToMarkAsMobilePad = "btnNinth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- haveToMarkAsMobilePad = "btnEighth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnEighth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnEighth":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnTwo";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnTwo";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnTwo")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnSeventh")
- {
- haveToMarkAsMobilePad = "btnNinth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnNinth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnNinth")
- {
- haveToMarkAsMobilePad = "btnSeventh";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSeventh";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnNinth":
-
-
- if (playerAllMarkedPad[1].ToString() == "btnFifth")
- {
- haveToMarkAsMobilePad = "btnOne";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnOne";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnOne")
- {
- haveToMarkAsMobilePad = "btnFifth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnFifth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
-
- else if (playerAllMarkedPad[1].ToString() == "btnSixth")
- {
- haveToMarkAsMobilePad = "btnThree";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnThree";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else if (playerAllMarkedPad[1].ToString() == "btnThree")
- {
- haveToMarkAsMobilePad = "btnSixth";
- if (allBlankPad.Contains(haveToMarkAsMobilePad))
- haveToMarkAsMobilePad = "btnSixth";
- else
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- }
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- }
- }
-
- else if (countPad == 4)
- {
- if (allBlankPad.Count != 0)
- {
- switch (allBlankPad[0].ToString())
- {
- case "btnOne":
- if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnThree"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFourth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnTwo":
- if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnThree"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFourth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnThree":
- if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnOne"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSixth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnFourth":
- if (playerAllMarkedPad.Contains("btnOne"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSixth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnFifth":
- if (playerAllMarkedPad.Contains("btnSixth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFourth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnEighth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnSixth":
- if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFourth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnSeventh":
- if (playerAllMarkedPad.Contains("btnEighth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFourth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnThree"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnEighth":
- if (playerAllMarkedPad.Contains("btnNinth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnTwo"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- case "btnNinth":
- if (playerAllMarkedPad.Contains("btnEighth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSeventh"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnSixth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnThree"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnFifth"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else if (playerAllMarkedPad.Contains("btnOne"))
- haveToMarkAsMobilePad = allBlankPad[0].ToString();
- else
- {
- index = randomPad.Next(1, allBlankPad.Count - 1);
- haveToMarkAsMobilePad = allBlankPad[index].ToString();
- }
- break;
- }
-
- }
- }
- return haveToMarkAsMobilePad;
- }
Lable: HARD
In hard level do the steps of MEDIUM Level but when the opponent has no two consecutive marked pad then think on you move by which the phone could win and if any now possibility to win the make move which could help to win on next turn
Note: Most of the code will be same as level MEDIUM except the random move because in medium level we are checking the win condition of opponent , if it is then we were marking those pad by which opponent could not win on next turn other wise we were marking any blank pad using random selection of blank pad.
But in this level we won't marked any pad randomly. If opponent has no chance to win at next turn then phone will think about its win condition, if any possibility available to win then marked that pad to become winner or try to marked that pad which will help you to win at future turn.
Thanks!