public void CalculateFaceDownProbability100Percent() { AISearch ai = new AISearch(); AIBoardData testBoard = CreateTestBoardFaceDownOnly1(); Assert.AreEqual(1, ai.ProbabilityOfPieceFlip(testBoard, Player.Red, CellValue.One)); }
public void EvaluatePosition2() { AISearch ai = new AISearch(); AIBoardData testBoard = CreateTestBoardFaceDown1(); Assert.AreEqual(1, ai.EvaluatePosition(testBoard)); }
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); } }
/* * 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)); } } } }
/* * 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(); } } }
private void Awake() { boardX = board.boardX; boardY = board.boardY; ai = new AISearch(); }