From 39644676e2716a285fcea6bb81e07f326bda2f68 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Tue, 3 Dec 2019 10:04:16 -0800 Subject: Started work on symmetry island --- Source/Randomizer2.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++++++---- Source/Randomizer2.h | 3 ++- Source/Source.vcxproj | 14 ++++++++---- Source/Validator.cpp | 4 ++-- Source/pch.cpp | 1 + 5 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 Source/pch.cpp diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index db90f4c..e1b1712 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp @@ -6,11 +6,13 @@ #include "Solver.h" #include "Windows.h" -Randomizer2::Randomizer2(const PuzzleSerializer& serializer) : _serializer(serializer) {} +Randomizer2::Randomizer2(const PuzzleSerializer& serializer) : _serializer(serializer) { +} void Randomizer2::Randomize() { - RandomizeTutorial(); - RandomizeSymmetry(); + // RandomizeTutorial(); + // RandomizeGlassFactory(); + RandomizeSymmetryIsland(); // RandomizeKeep(); } @@ -144,7 +146,7 @@ void Randomizer2::RandomizeTutorial() { } } -void Randomizer2::RandomizeSymmetry() { +void Randomizer2::RandomizeGlassFactory() { { // Back wall 1 Puzzle p; p.NewGrid(3, 3); @@ -359,6 +361,55 @@ void Randomizer2::RandomizeSymmetry() { } } +void Randomizer2::RandomizeSymmetryIsland() { + { // Entry door + Puzzle p; + p.NewGrid(4, 3); + p.grid[0][6].start = true; + p.grid[8][0].end = Cell::Dir::RIGHT; + p.grid[4][3].gap = Cell::Gap::FULL; + + std::vector corners; + std::vector cells; + std::vector edges; + for (int x=0; x dots; + for (int i=0; i<4; i++) { + int edge = Random::RandInt(0, static_cast(edgesCopy.size() - 1)); + dots.emplace_back(edgesCopy[edge]); + edgesCopy.erase(edgesCopy.begin() + edge); + } + + for (Pos pos : dots) { + p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; + } + + auto solutions = Solver::Solve(p); + if (solutions.size() > 0 && solutions.size() < 10) { + std::string text = std::to_string(solutions.size()) + "\n"; + OutputDebugStringA(text.c_str()); + break; + } + + for (Pos pos : dots) { + p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; + } + } + + _serializer.WritePuzzle(p, 0xB0); + } +} + void Randomizer2::RandomizeKeep() { { // Hedges 1 Puzzle p; diff --git a/Source/Randomizer2.h b/Source/Randomizer2.h index 34c89f5..a2b5ebd 100644 --- a/Source/Randomizer2.h +++ b/Source/Randomizer2.h @@ -6,7 +6,8 @@ public: Randomizer2(const PuzzleSerializer& serializer); void Randomize(); void RandomizeTutorial(); - void RandomizeSymmetry(); + void RandomizeGlassFactory(); + void RandomizeSymmetryIsland(); void RandomizeKeep(); private: diff --git a/Source/Source.vcxproj b/Source/Source.vcxproj index c63c664..76fdcef 100644 --- a/Source/Source.vcxproj +++ b/Source/Source.vcxproj @@ -84,7 +84,7 @@ - Create + Use Level3 Disabled true @@ -101,7 +101,7 @@ - Create + Use Level3 Disabled true @@ -119,7 +119,7 @@ - Create + Use Level3 MaxSpeed true @@ -140,7 +140,7 @@ - Create + Use Level3 MaxSpeed true @@ -178,6 +178,12 @@ + + Create + Create + Create + Create + diff --git a/Source/Validator.cpp b/Source/Validator.cpp index 3001790..3b4020b 100644 --- a/Source/Validator.cpp +++ b/Source/Validator.cpp @@ -13,8 +13,8 @@ void Validator::Validate(Puzzle& p) { // Validate gap failures as an early exit. for (int x = 0; x < p.width; x++) { for (int y = 0; y < p.height; y++) { - Cell cell = p.grid[x][y]; - auto decoration = cell.decoration; + const Cell& cell = p.grid[x][y]; + const auto& decoration = cell.decoration; if (decoration) { if (decoration->type == Type::Stone || decoration->type == Type::Star || diff --git a/Source/pch.cpp b/Source/pch.cpp new file mode 100644 index 0000000..1730571 --- /dev/null +++ b/Source/pch.cpp @@ -0,0 +1 @@ +#include "pch.h" \ No newline at end of file -- cgit 1.4.1