diff --git a/WFC++/Tiled3D/StandardRunner.h b/WFC++/Tiled3D/StandardRunner.h index b3f8087..0d111de 100644 --- a/WFC++/Tiled3D/StandardRunner.h +++ b/WFC++/Tiled3D/StandardRunner.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Grid.h" namespace WFC::Tiled3D @@ -92,13 +93,25 @@ namespace WFC::Tiled3D //Returns whether the algorithm is finished. bool TickN(int n); + void Reset() + { + Grid.ClearCells(Region3i(Grid.Cells.GetDimensions())); + report.Clear(); + nextCells.Clear(); + unsolvableCells.Clear(); + } + //TODO: Another overload that takes new 'constants'. + StandardRunner(const List& inputTiles, const Vector3i& gridSize, + const Dictionary>* constants = nullptr, PRNG rand = PRNG(std::random_device()())) : Grid(inputTiles, gridSize), Rand(rand), History(gridSize, { }) { - + if (constants != nullptr) + for (const auto& [cellPos, tileData] : *constants) + Set(cellPos, std::get<0>(tileData), std::get<1>(tileData)); } diff --git a/WFCtests/main.cpp b/WFCtests/main.cpp index a8efc56..b68cc23 100644 --- a/WFCtests/main.cpp +++ b/WFCtests/main.cpp @@ -790,24 +790,26 @@ SUITE(WFC_Tiled3D) TEST(StandardRunner) { + //Use two permutations of a single tile, + // which are compatible along Z but not X or Y, + // ensuring that each Z-level uses all one permutation. + TransformSet usedTransforms; + usedTransforms.Add(Transform3D{ }); + usedTransforms.Add(Transform3D{ false, Rotations3D::AxisZ_90 }); + StandardRunner state(OneTileArmy(usedTransforms), {4, 5, 6}); + //StandardRunner uses to generate numbers. //Run the test many times to cover a broad range of possible outcomes. const int N_TESTS = #ifdef _DEBUG - 100000 + 20000 #else - 400000 + 200000 #endif ; for (int i = 0; i < N_TESTS; ++i) { - //Use two permutations of a single tile, - // which are compatible along Z but not X or Y, - // ensuring that each Z-level uses all one permutation. - TransformSet usedTransforms; - usedTransforms.Add(Transform3D{ }); - usedTransforms.Add(Transform3D{ false, Rotations3D::AxisZ_90 }); - StandardRunner state(OneTileArmy(usedTransforms), {4, 5, 6}); + state.Reset(); //Tick once, and check that one cell is set. bool isFinished = state.Tick(); @@ -855,6 +857,8 @@ SUITE(WFC_Tiled3D) setCellPos == originalCellPos.MoreY() || setCellPos == originalCellPos.LessZ() || setCellPos == originalCellPos.MoreZ()); + + //TODO: Set a cell that makes the grid unsolvable, then watch it clear. } } } @@ -862,5 +866,6 @@ SUITE(WFC_Tiled3D) int main(int, const char* []) { + std::cout << "Running..." << std::endl; return UnitTest::RunAllTests(); } \ No newline at end of file