diff options
-rw-r--r-- | Source/Randomizer2.cpp | 59 | ||||
-rw-r--r-- | Source/Randomizer2.h | 3 | ||||
-rw-r--r-- | Source/Source.vcxproj | 14 | ||||
-rw-r--r-- | Source/Validator.cpp | 4 | ||||
-rw-r--r-- | Source/pch.cpp | 1 |
5 files changed, 70 insertions, 11 deletions
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 @@ | |||
6 | #include "Solver.h" | 6 | #include "Solver.h" |
7 | #include "Windows.h" | 7 | #include "Windows.h" |
8 | 8 | ||
9 | Randomizer2::Randomizer2(const PuzzleSerializer& serializer) : _serializer(serializer) {} | 9 | Randomizer2::Randomizer2(const PuzzleSerializer& serializer) : _serializer(serializer) { |
10 | } | ||
10 | 11 | ||
11 | void Randomizer2::Randomize() { | 12 | void Randomizer2::Randomize() { |
12 | RandomizeTutorial(); | 13 | // RandomizeTutorial(); |
13 | RandomizeSymmetry(); | 14 | // RandomizeGlassFactory(); |
15 | RandomizeSymmetryIsland(); | ||
14 | // RandomizeKeep(); | 16 | // RandomizeKeep(); |
15 | } | 17 | } |
16 | 18 | ||
@@ -144,7 +146,7 @@ void Randomizer2::RandomizeTutorial() { | |||
144 | } | 146 | } |
145 | } | 147 | } |
146 | 148 | ||
147 | void Randomizer2::RandomizeSymmetry() { | 149 | void Randomizer2::RandomizeGlassFactory() { |
148 | { // Back wall 1 | 150 | { // Back wall 1 |
149 | Puzzle p; | 151 | Puzzle p; |
150 | p.NewGrid(3, 3); | 152 | p.NewGrid(3, 3); |
@@ -359,6 +361,55 @@ void Randomizer2::RandomizeSymmetry() { | |||
359 | } | 361 | } |
360 | } | 362 | } |
361 | 363 | ||
364 | void Randomizer2::RandomizeSymmetryIsland() { | ||
365 | { // Entry door | ||
366 | Puzzle p; | ||
367 | p.NewGrid(4, 3); | ||
368 | p.grid[0][6].start = true; | ||
369 | p.grid[8][0].end = Cell::Dir::RIGHT; | ||
370 | p.grid[4][3].gap = Cell::Gap::FULL; | ||
371 | |||
372 | std::vector<Pos> corners; | ||
373 | std::vector<Pos> cells; | ||
374 | std::vector<Pos> edges; | ||
375 | for (int x=0; x<p.width; x++) { | ||
376 | for (int y=0; y<p.height; y++) { | ||
377 | if (x%2 == 0 && y%2 == 0) corners.emplace_back(Pos{x, y}); | ||
378 | else if (x%2 == 1 && y%2 == 1) cells.emplace_back(Pos{x, y}); | ||
379 | else edges.emplace_back(Pos{x, y}); | ||
380 | } | ||
381 | } | ||
382 | |||
383 | for (int j=0;; j++) { | ||
384 | auto edgesCopy = edges; | ||
385 | |||
386 | std::vector<Pos> dots; | ||
387 | for (int i=0; i<4; i++) { | ||
388 | int edge = Random::RandInt(0, static_cast<int>(edgesCopy.size() - 1)); | ||
389 | dots.emplace_back(edgesCopy[edge]); | ||
390 | edgesCopy.erase(edgesCopy.begin() + edge); | ||
391 | } | ||
392 | |||
393 | for (Pos pos : dots) { | ||
394 | p.grid[pos.x][pos.y].dot = Cell::Dot::BLACK; | ||
395 | } | ||
396 | |||
397 | auto solutions = Solver::Solve(p); | ||
398 | if (solutions.size() > 0 && solutions.size() < 10) { | ||
399 | std::string text = std::to_string(solutions.size()) + "\n"; | ||
400 | OutputDebugStringA(text.c_str()); | ||
401 | break; | ||
402 | } | ||
403 | |||
404 | for (Pos pos : dots) { | ||
405 | p.grid[pos.x][pos.y].dot = Cell::Dot::NONE; | ||
406 | } | ||
407 | } | ||
408 | |||
409 | _serializer.WritePuzzle(p, 0xB0); | ||
410 | } | ||
411 | } | ||
412 | |||
362 | void Randomizer2::RandomizeKeep() { | 413 | void Randomizer2::RandomizeKeep() { |
363 | { // Hedges 1 | 414 | { // Hedges 1 |
364 | Puzzle p; | 415 | 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: | |||
6 | Randomizer2(const PuzzleSerializer& serializer); | 6 | Randomizer2(const PuzzleSerializer& serializer); |
7 | void Randomize(); | 7 | void Randomize(); |
8 | void RandomizeTutorial(); | 8 | void RandomizeTutorial(); |
9 | void RandomizeSymmetry(); | 9 | void RandomizeGlassFactory(); |
10 | void RandomizeSymmetryIsland(); | ||
10 | void RandomizeKeep(); | 11 | void RandomizeKeep(); |
11 | 12 | ||
12 | private: | 13 | 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 @@ | |||
84 | </PropertyGroup> | 84 | </PropertyGroup> |
85 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | 85 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
86 | <ClCompile> | 86 | <ClCompile> |
87 | <PrecompiledHeader>Create</PrecompiledHeader> | 87 | <PrecompiledHeader>Use</PrecompiledHeader> |
88 | <WarningLevel>Level3</WarningLevel> | 88 | <WarningLevel>Level3</WarningLevel> |
89 | <Optimization>Disabled</Optimization> | 89 | <Optimization>Disabled</Optimization> |
90 | <SDLCheck>true</SDLCheck> | 90 | <SDLCheck>true</SDLCheck> |
@@ -101,7 +101,7 @@ | |||
101 | </ItemDefinitionGroup> | 101 | </ItemDefinitionGroup> |
102 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | 102 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
103 | <ClCompile> | 103 | <ClCompile> |
104 | <PrecompiledHeader>Create</PrecompiledHeader> | 104 | <PrecompiledHeader>Use</PrecompiledHeader> |
105 | <WarningLevel>Level3</WarningLevel> | 105 | <WarningLevel>Level3</WarningLevel> |
106 | <Optimization>Disabled</Optimization> | 106 | <Optimization>Disabled</Optimization> |
107 | <SDLCheck>true</SDLCheck> | 107 | <SDLCheck>true</SDLCheck> |
@@ -119,7 +119,7 @@ | |||
119 | </ItemDefinitionGroup> | 119 | </ItemDefinitionGroup> |
120 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | 120 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
121 | <ClCompile> | 121 | <ClCompile> |
122 | <PrecompiledHeader>Create</PrecompiledHeader> | 122 | <PrecompiledHeader>Use</PrecompiledHeader> |
123 | <WarningLevel>Level3</WarningLevel> | 123 | <WarningLevel>Level3</WarningLevel> |
124 | <Optimization>MaxSpeed</Optimization> | 124 | <Optimization>MaxSpeed</Optimization> |
125 | <FunctionLevelLinking>true</FunctionLevelLinking> | 125 | <FunctionLevelLinking>true</FunctionLevelLinking> |
@@ -140,7 +140,7 @@ | |||
140 | </ItemDefinitionGroup> | 140 | </ItemDefinitionGroup> |
141 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | 141 | <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
142 | <ClCompile> | 142 | <ClCompile> |
143 | <PrecompiledHeader>Create</PrecompiledHeader> | 143 | <PrecompiledHeader>Use</PrecompiledHeader> |
144 | <WarningLevel>Level3</WarningLevel> | 144 | <WarningLevel>Level3</WarningLevel> |
145 | <Optimization>MaxSpeed</Optimization> | 145 | <Optimization>MaxSpeed</Optimization> |
146 | <FunctionLevelLinking>true</FunctionLevelLinking> | 146 | <FunctionLevelLinking>true</FunctionLevelLinking> |
@@ -178,6 +178,12 @@ | |||
178 | <ItemGroup> | 178 | <ItemGroup> |
179 | <ClCompile Include="ChallengeRandomizer.cpp" /> | 179 | <ClCompile Include="ChallengeRandomizer.cpp" /> |
180 | <ClCompile Include="Memory.cpp" /> | 180 | <ClCompile Include="Memory.cpp" /> |
181 | <ClCompile Include="pch.cpp"> | ||
182 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> | ||
183 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> | ||
184 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader> | ||
185 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader> | ||
186 | </ClCompile> | ||
181 | <ClCompile Include="Puzzle.cpp" /> | 187 | <ClCompile Include="Puzzle.cpp" /> |
182 | <ClCompile Include="PuzzleSerializer.cpp" /> | 188 | <ClCompile Include="PuzzleSerializer.cpp" /> |
183 | <ClCompile Include="Random.cpp" /> | 189 | <ClCompile Include="Random.cpp" /> |
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) { | |||
13 | // Validate gap failures as an early exit. | 13 | // Validate gap failures as an early exit. |
14 | for (int x = 0; x < p.width; x++) { | 14 | for (int x = 0; x < p.width; x++) { |
15 | for (int y = 0; y < p.height; y++) { | 15 | for (int y = 0; y < p.height; y++) { |
16 | Cell cell = p.grid[x][y]; | 16 | const Cell& cell = p.grid[x][y]; |
17 | auto decoration = cell.decoration; | 17 | const auto& decoration = cell.decoration; |
18 | if (decoration) { | 18 | if (decoration) { |
19 | if (decoration->type == Type::Stone || | 19 | if (decoration->type == Type::Stone || |
20 | decoration->type == Type::Star || | 20 | 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 | |||