From 1fe1316e1c5be458af23748a7f651edf350da7d6 Mon Sep 17 00:00:00 2001 From: grunt-lucas Date: Sat, 23 Sep 2023 13:07:30 -0700 Subject: [PATCH] BFS can now compile secondary sets --- include/cli_options.h | 1 + src/palette_assignment.cpp | 25 ++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/cli_options.h b/include/cli_options.h index c53f0467..e7f52b01 100644 --- a/include/cli_options.h +++ b/include/cli_options.h @@ -105,6 +105,7 @@ const std::string ASSIGN_ALGO_DESC = " Select the assignment algorithm. Valid options are `dfs' and `bfs'. Default is `dfs'.\n"; constexpr int ASSIGN_ALGO_VAL = 3001; +// TODO : swap this around, instead of pruning N most unpromising branches, make it try top N promising branches const std::string PRUNE_BRANCHES = "prune-branches"; const std::string PRUNE_BRANCHES_DESC = " -" + PRUNE_BRANCHES + "=\n" diff --git a/src/palette_assignment.cpp b/src/palette_assignment.cpp index 4eff0cd8..038a7a2d 100644 --- a/src/palette_assignment.cpp +++ b/src/palette_assignment.cpp @@ -40,7 +40,7 @@ AssignResult assignDepthFirst(PtContext &ctx, AssignState &state, std::vector hardwarePalettesCopy; + std::copy(std::begin(currentState.hardwarePalettes), std::end(currentState.hardwarePalettes), + std::back_inserter(hardwarePalettesCopy)); + AssignState updatedState = {hardwarePalettesCopy, currentState.unassignedCount - 1}; + stateQueue.push_back(updatedState); + visitedStates.insert(updatedState); + foundPrimaryMatch = true; + } + } + } + + /* + * If we found a matching primary palette for the current assignment, go ahead and skip ahead to the next toAssign. + * No need to process anything further for this toAssign. + */ + if (foundPrimaryMatch) { + continue; } std::stable_sort(std::begin(currentState.hardwarePalettes), std::end(currentState.hardwarePalettes),