public void CoreSolverEntropyUpdatePass() { outputGrid = new OutputGrid(2, 2, patternManager.GetNumberOfPatterns()); solver = new CoreSolver(outputGrid, patternManager); var position = new Vector2Int(0, 0); solver.CollapseCell(position); solver.Propagate(); var newPosition1 = solver.GetLowestEntropyCell(); solver.CollapseCell(newPosition1); solver.Propagate(); while (solver.CheckForConflics() == false && outputGrid.CheckIfGridIsSolved() == false) { newPosition1 = solver.GetLowestEntropyCell(); solver.CollapseCell(newPosition1); solver.Propagate(); } Debug.Log(outputGrid.GetPossibleValuesForPositon(new Vector2Int(0, 1)).Count + " " + outputGrid.GetPossibleValuesForPositon(new Vector2Int(1, 1)).Count); Debug.Log(outputGrid.GetPossibleValuesForPositon(new Vector2Int(0, 0)).Count + " " + outputGrid.GetPossibleValuesForPositon(new Vector2Int(1, 0)).Count); Assert.True(solver.CheckForConflics() || outputGrid.CheckIfGridIsSolved()); }
public void TileMapOutputTestSimplePasses() { //outputGrid = new OutputGrid(3, 3, patternManager.GetNumberOfPatterns()); //solver = new CoreSolver(outputGrid, patternManager); //var position = new Vector2Int(0, 0); //for (int i = 0; i < 3; i++) //{ // for (int j = 0; j < 3; j++) // { // outputGrid.SetPatternOnPosition(i, j, 1); // } //} outputGrid = new OutputGrid(5, 5, patternManager.GetNumberOfPatterns()); solver = new CoreSolver(outputGrid, patternManager); var position = new Vector2Int(0, 0); solver.CollapseCell(position); solver.Propagate(); var newPosition1 = solver.GetLowestEntropyCell(); solver.CollapseCell(newPosition1); solver.Propagate(); while (solver.CheckForConflics() == false && outputGrid.CheckIfGridIsSolved() == false) { newPosition1 = solver.GetLowestEntropyCell(); solver.CollapseCell(newPosition1); solver.Propagate(); } if (solver.CheckForConflics()) { Debug.Log("Conflict"); Assert.True(true); } else { outputGrid.PrintResultsToConsol(); int[][] wfcOutput = outputGrid.GetSolvedOutputGrid(); IOutputCreator <Tilemap> tileOutput = new TileMapOutput(valueManager, outputtilemap); tileOutput.CreateOutput(patternManager, wfcOutput, outputGrid.width, outputGrid.height); Assert.True(CheckEveryNeighbour(outputGrid)); } }
public void CoreSolverCheckLowestEntropyPasses() { outputGrid = new OutputGrid(10, 10, patternManager.GetNumberOfPatterns()); solver = new CoreSolver(outputGrid, patternManager); var position = new Vector2Int(0, 0); solver.CollapseCell(position); Assert.True(outputGrid.CheckIfCellIsCollapsed(position)); }
public void CoreSolverPropagatePass() { outputGrid = new OutputGrid(2, 2, patternManager.GetNumberOfPatterns()); solver = new CoreSolver(outputGrid, patternManager); var position = new Vector2Int(0, 0); solver.CollapseCell(position); solver.Propagate(); var numberOfPossiblePatterns = patternManager.GetNumberOfPatterns(); Assert.True(outputGrid.GetPossibleValuesForPositon(new Vector2Int(1, 0)).Count < numberOfPossiblePatterns && outputGrid.GetPossibleValuesForPositon(new Vector2Int(0, 1)).Count < numberOfPossiblePatterns); }
public void CoreSolverEntropyPass() { outputGrid = new OutputGrid(2, 2, patternManager.GetNumberOfPatterns()); outputGrid.SetPatternOnPosition(1, 1, 0); solver = new CoreSolver(outputGrid, patternManager); var position = new Vector2Int(0, 0); solver.CollapseCell(position); solver.Propagate(); var newPosition1 = solver.GetLowestEntropyCell(); var newPosition2 = solver.GetLowestEntropyCell(); Debug.Log(newPosition1 + " " + newPosition2); Debug.Log(outputGrid.GetPossibleValuesForPositon(new Vector2Int(0, 1)).Count + " " + outputGrid.GetPossibleValuesForPositon(new Vector2Int(1, 1)).Count); Debug.Log(outputGrid.GetPossibleValuesForPositon(new Vector2Int(0, 0)).Count + " " + outputGrid.GetPossibleValuesForPositon(new Vector2Int(1, 0)).Count); Assert.True(((newPosition1 == new Vector2Int(0, 1) || newPosition1 == new Vector2Int(1, 0)) && (newPosition2 == new Vector2Int(0, 1) || newPosition2 == new Vector2Int(1, 0))) || outputGrid.CheckIfGridIsSolved()); }