private bool SetTilRandomLegalMove(int x, int y) { //Random.InitState(oldSeed + 100); //oldSeed += 100; //Debug.Log("element: " + (i * gridSize + j)); int maxX = (x <= gridAPI.GridSize() / 2) ? gridAPI.GridSize() - x : gridAPI.GridSize() - x / 2; int maxY = (y <= gridAPI.GridSize() / 2) ? gridAPI.GridSize() - y : gridAPI.GridSize() - y / 2; //Random function's second parameter is exclusive int randomX = Random.Range(1, maxX); int randomY = Random.Range(1, maxY); int random = Random.Range(0, 2); if (random == 0) { gridAPI.SetNumMovesForTile(x, y, randomX); } else { gridAPI.SetNumMovesForTile(x, y, randomY); } return(true); }
private bool RandHillClimbTileMove(int x, int y, int randomSide) { //Random.InitState(oldSeed + 100); //oldSeed += 100; //Debug.Log("element: " + (i * gridSize + j)); int gridSize = gridAPI.GridSize(); int maxX = (x <= gridSize / 2) ? gridSize - x : gridSize - x / 2; int minX = 1; int maxY = (y <= gridSize / 2) ? gridSize - y : gridSize - y / 2; int minY = 1; int dividePoint = 3; if ((x != 0 && y != 0) && (x != gridSize - 1 && y != 1)) { if (randomSide == 0) { if (y >= gridSize / dividePoint) { maxY = Mathf.Min(5, gridSize / dividePoint); minY = 1; } else { maxY = (y <= gridSize / 2) ? gridSize - y : gridSize - y / 2; minY = 1; } maxX = (x <= gridSize / 2) ? gridSize - x : gridSize - x / 2; minX = 1; } else { if (x <= (dividePoint - 1) * gridSize / dividePoint) { maxX = Mathf.Min(5, gridSize / dividePoint); minX = 1; } else { maxX = (x <= gridSize / 2) ? gridSize - x : gridSize - x / 2; minX = 1; } maxY = (y <= gridSize / 2) ? gridSize - y : gridSize - y / 2; minY = 1; } } else { if (x == 0 && y == 0) { minX = 1; maxX = gridSize - 1; minY = 1; maxY = gridSize - 1; } else { minX = 2; maxX = gridSize; minY = 2; maxY = gridSize; } } //Random function's second parameter is exclusive int randomX = Random.Range(minX, maxX); int randomY = Random.Range(minY, maxY); int random = Random.Range(0, 2); if (random == 0) { gridAPI.SetNumMovesForTile(x, y, randomX); } else { gridAPI.SetNumMovesForTile(x, y, randomY); } return(true); }