Example #1
0
    void CalculateAIAndInstantiateSphere()
    {
        //
        //Hard Strategy
        //
        Ai_Comp = new AICompMinimax(grid);
        Ai_Comp.setChance(AIComp.Chance.COMP);


        //
        //Easy Strategy
        //

        //This function performs tasks for AI and plays the computer chance
//		bool found = false;
//		int sphere_box = -1;
//		while (!found) {
//			int next_box = Random.Range(0,8);
//			if(grid[next_box] == 0)
//			{
//				sphere_box = next_box;
//				found = true;
//				grid[sphere_box] = 2;
//				steps++;
//			}
//		}

        int sphere_box = Ai_Comp.move();

        int[] center = ComputeCenter(sphere_box);
        grid[sphere_box] = 2;
        steps++;
        Debug.Log("Instantiating Sphere");
        Instantiate(sphere, new Vector3(center [0], center [1], 0), Quaternion.identity);
        Game_States current_state = CheckPattern(2);

        if (current_state == Game_States.COMP_WON)
        {
            //End the game and display Player wins
            Debug.Log("Comp Won");
        }
        else
        {
            //This will start the process for comp
            hasUserPlayed = false;
        }

        Debug.Log("Click User");
    }
Example #2
0
    void CalculateAIAndInstantiateSphere()
    {
        //
        //Hard Strategy
        //
        Ai_Comp = new AICompMinimax (grid);
        Ai_Comp.setChance (AIComp.Chance.COMP);

        //
        //Easy Strategy
        //

        //This function performs tasks for AI and plays the computer chance
        //		bool found = false;
        //		int sphere_box = -1;
        //		while (!found) {
        //			int next_box = Random.Range(0,8);
        //			if(grid[next_box] == 0)
        //			{
        //				sphere_box = next_box;
        //				found = true;
        //				grid[sphere_box] = 2;
        //				steps++;
        //			}
        //		}

        int sphere_box = Ai_Comp.move();
        int[] center = ComputeCenter (sphere_box);
        grid[sphere_box] = 2;
        steps++;
        Debug.Log ("Instantiating Sphere");
        Instantiate(sphere, new Vector3 (center [0], center [1], 0), Quaternion.identity);
        Game_States current_state =  CheckPattern (2);
        if (current_state == Game_States.COMP_WON) {
            //End the game and display Player wins
            Debug.Log("Comp Won");
        } else {
            //This will start the process for comp
            hasUserPlayed = false;
        }

        Debug.Log ("Click User");
    }