Ejemplo n.º 1
0
    public void CalculateFaceDownProbability100Percent()
    {
        AISearch    ai        = new AISearch();
        AIBoardData testBoard = CreateTestBoardFaceDownOnly1();

        Assert.AreEqual(1, ai.ProbabilityOfPieceFlip(testBoard, Player.Red, CellValue.One));
    }
Ejemplo n.º 2
0
    public void EvaluatePosition2()
    {
        AISearch    ai        = new AISearch();
        AIBoardData testBoard = CreateTestBoardFaceDown1();

        Assert.AreEqual(1, ai.EvaluatePosition(testBoard));
    }
Ejemplo n.º 3
0
    public IEnumerator FinishMove()
    {
        if (canMove())
        {
            AISearch    ai        = new AISearch();
            AIBoardData testBoard = ScanBoard();
            yield return(new WaitForSeconds(1));

            AIBoardData bestBoard = ai.BestMove(testBoard, 4, 1);
            MakeMove(testBoard, bestBoard);
        }
    }
Ejemplo n.º 4
0
 /*
  * doAISearchMethods will make a search agent to start searching though the navigation mesh
  * Parameter:	none
  * Return:	none
  */
 void doAISearchMethods()
 {
     AINavigationMeshAgent.polygonLengthMin = surfacePolygonHolders [positionToStart].getMinPolygonLength();
     AINavigationMeshAgent.polygonLengthAvg = surfacePolygonHolders [positionToStart].getAveragePolygonLength();
     if (positionToStart != -1)
     {
         tempSearch = new AISearch(searchType, goalPosition, surfacePolygonHolders [positionToStart].getPolygons());
     }
     if (tempSearch != null)
     {
         Vector3[] vertices = tempSearch.getWayPoints();
         if (vertices != null)
         {
             for (int count = 0; count < vertices.Length; count++)
             {
                 Instantiate(sphere, vertices [count], new Quaternion(0f, 0f, 0f, 0f));
             }
         }
     }
 }
Ejemplo n.º 5
0
    /*
     * doNavigationMethods method will start building the navigation mesh
     * Parameter:	(string)searchTypeToRun is the search type that will be ran on the navigation mesh
     * Return:	none
     */
    public void doNavigationMethods(string searchTypeToRun)
    {
        searchType = searchTypeToRun;
        if (AINavigationMeshAgent.loadNavigationMesh == true)
        {
            loadNavigationMeshFromFile();
        }
        else
        {
            startTime       = Time.realtimeSinceStartup;
            positionToStart = 0;
            tempSearch      = null;
            AINavigationMeshData.initialPolygonCount = getSurfacePolygonCount();
            AINavigationMeshData.obstacleCount       = staticObjects.Length;
            mergeSurfacePolygonHolders();
            seperateEdgesIntoVectors();
            getObjectsToSplitSurfacePolygons();
            AINavigationMeshData.timeTaken         = Time.realtimeSinceStartup - startTime;
            AINavigationMeshData.finalPolygonCount = getSurfacePolygonCount();
            for (int count = 0; count < surfacePolygonHolders.Length; count++)
            {
                if (surfacePolygonHolders [count] != null)
                {
                    positionToStart = count;
                }
            }
            writeNavigationMeshToFile();
        }
        startTime = Time.realtimeSinceStartup;
        int searchTimes;

        if (AINavigationMeshAgent.runSearch1000Times == false)
        {
            searchTimes      = 1;
            AISearch.canWalk = true;
        }
        else
        {
            AISearch.canWalk = false;
            searchTimes      = 1000;
        }
        if (AINavigationMeshAgent.runAllSearchs == true)
        {
            AISearch.canWalk = false;
            for (int count = 0; count < 9; count++)
            {
                searchType = allSearchs [count];
                for (int count2 = 0; count2 < searchTimes; count2++)
                {
                    doAISearchMethods();
                    writeAfterDataToFile();
                }
            }
        }
        else
        {
            for (int count = 0; count < searchTimes; count++)
            {
                doAISearchMethods();
                writeAfterDataToFile();
            }
        }
    }
Ejemplo n.º 6
0
 private void Awake()
 {
     boardX = board.boardX;
     boardY = board.boardY;
     ai     = new AISearch();
 }