From 51f4936aff73f1024d5a55bdf12bbcf766dcfbec Mon Sep 17 00:00:00 2001 From: cdemeyer-teachx Date: Sun, 14 Sep 2025 15:46:15 +0900 Subject: [PATCH] select variable changes --- demos/sudoku/sudoku.h | 5 +++-- include/nd-wfc/wfc_builder.hpp | 37 +++++++++++++++++++++++++++------- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/demos/sudoku/sudoku.h b/demos/sudoku/sudoku.h index c1c230c..305cff1 100644 --- a/demos/sudoku/sudoku.h +++ b/demos/sudoku/sudoku.h @@ -315,9 +315,10 @@ public: private: static bool parseLine(const std::string& line, std::array& board); }; + using SudokuSolverBuilder = WFC::Builder ::DefineRange<1, 10> - ::DefineConstrainer val, auto& constrainer) constexpr { + ::ConstrainAll val, auto& constrainer) constexpr { size_t x = index % 9; size_t y = index / 9; @@ -343,7 +344,7 @@ using SudokuSolverBuilder = WFC::Builder } } - }), 1, 2, 3, 4, 5, 6, 7, 8, 9>; + })>; using SudokuSolver = SudokuSolverBuilder::Build; diff --git a/include/nd-wfc/wfc_builder.hpp b/include/nd-wfc/wfc_builder.hpp index 020051f..815dac1 100644 --- a/include/nd-wfc/wfc_builder.hpp +++ b/include/nd-wfc/wfc_builder.hpp @@ -18,7 +18,8 @@ template< typename VariableIDMapT = VariableIDMap, typename ConstrainerFunctionMapT = ConstrainerFunctionMap, typename CallbacksT = Callbacks, - typename RandomSelectorT = DefaultRandomSelector> + typename RandomSelectorT = DefaultRandomSelector, + typename SelectedValueT = void> class Builder { public: constexpr static size_t WorldSize = HasConstexprSize ? WorldT{}.size() : 0; @@ -27,27 +28,49 @@ public: using PropagationQueueType = WFCQueue; using ConstrainerType = Constrainer; + template - using DefineIDs = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT>; + using DefineIDs = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT, VariableIDMap>; template - using DefineRange = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT>; + using DefineRange = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT, VariableIDRange>; template - using DefineRange0 = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT>; + using DefineRange0 = Builder, ConstrainerFunctionMapT, CallbacksT, RandomSelectorT, VariableIDRange>; - template + + template + using Variable = Builder>; + + template + using VariableRange = Builder>; + + + template requires ConstrainerFunction - using DefineConstrainer = Builder, + SelectedValueT, + decltype([](WorldT&, size_t, WorldValue, ConstrainerType&) {}) + >, CallbacksT, RandomSelectorT, SelectedValueT + >; + + template + requires ConstrainerFunction + using ConstrainAll = Builder, ConstrainerType&) {}) >, CallbacksT, RandomSelectorT >; + template using SetCellCollapsedCallback = Builder, RandomSelectorT>; template