Skip to content

Commit

Permalink
Sym mazes nerf and some other tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma144 committed Feb 16, 2022
1 parent 7e7dc5c commit dd33cf6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
17 changes: 16 additions & 1 deletion Source/Generate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ bool Generate::generate_maze(int id, int numStarts, int numExits)
return false;

clear();
if (hasFlag(Generate::Config::ShortPath)) {
while (!generate_path_length((_panel->_width + _panel->_height),
min((_panel->_width + _panel->_height) * 2, (_panel->_width / 2 + 1) * (_panel->_height / 2 + 1) * 1 / 2))) clear();
}
while (!generate_path_length((_panel->_width + _panel->_height),
min((_panel->_width + _panel->_height) * 2, (_panel->_width / 2 + 1) * (_panel->_height / 2 + 1) * 4 / 5))) clear();
}
Expand Down Expand Up @@ -494,6 +498,17 @@ bool Generate::generate_maze(int id, int numStarts, int numExits)
set(p, Decoration::Gap_Column);
}
_path = path; //Restore backup of the correct solution for testing purposes
std::vector<std::string> solution; //For debugging only
for (int y = 0; y < _panel->_height; y++) {
std::string row;
for (int x = 0; x < _panel->_width; x++) {
if (_path.count(Point(x, y))) {
row += "xx";
}
else row += " ";
}
solution.push_back(row);
}
if (!hasFlag(Config::DisableWrite)) write(id);
return true;
}
Expand Down Expand Up @@ -618,7 +633,7 @@ bool Generate::generate_path(PuzzleSymbols & symbols)
if (_obstructions.size() > 0) {
std::vector<Point> walls = pick_random(_obstructions);
for (Point p : walls) if (get(p) == 0) set(p, p.first % 2 == 0 ? Decoration::Gap_Column : Decoration::Gap_Row);
bool result = (hasFlag(Config::ShortPath) ? generate_path_length(1) : _parity != -1 ? generate_longest_path() :
bool result = (hasFlag(Config::ShortPath) ? generate_path_length(1) : _parity != -1 ? generate_longest_path() :
hitPoints.size() > 0 ? generate_special_path() : generate_path_length(_panel->get_num_grid_points() * 3 / 4));
for (Point p : walls) if (get(p) & Decoration::Gap) set(p, 0);
return result;
Expand Down
11 changes: 6 additions & 5 deletions Source/PuzzleList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,15 @@ void PuzzleList::GenerateSymmetryN()
generator->removeFlagOnce(Generate::Config::StartEdgeOnly);
generator->generateMaze(0x00059, 1, 0);
generator->generateMaze(0x00062);
generator->generateMaze(0x0005C);
specialCase->generateSpecialSymMaze(generator, 0x0005C);
//Rotational Symmetry Mazes
generator->setSymmetry(Panel::Symmetry::Rotational);
generator->setGridSize(5, 5);
generator->generateMaze(0x0008D, 0, 1);
generator->generateMaze(0x00081, 1, 1);
generator->removeFlagOnce(Generate::Config::StartEdgeOnly);
generator->generateMaze(0x00083, 1, 1);
generator->setGridSize(6, 6);
generator->generateMaze(0x00083);
generator->setGridSize(7, 7);
generator->pathWidth = 0.8f;
generator->generateMaze(0x00084);
generator->generateMaze(0x00082);
generator->generateMaze(0x0343A);
Expand Down Expand Up @@ -472,7 +471,9 @@ void PuzzleList::GenerateTreehouseN()
generator->generate(0x17DC7, Decoration::Star | Decoration::Color::Magenta, 6, Decoration::Dot_Intersection, 6, Decoration::Gap, 3);
generator->generate(0x17CE4, Decoration::Star | Decoration::Color::Magenta, 6, Decoration::Dot_Intersection, 6, Decoration::Gap, 3);
generator->setGridSize(5, 5);
generator->pathWidth = 0.8f;
generator->generate(0x17D2D, Decoration::Star | Decoration::Color::Magenta, 6, Decoration::Dot_Intersection, 9, Decoration::Gap, 8);
generator->pathWidth = 1;
generator->generate(0x17D6C, Decoration::Star | Decoration::Color::Magenta, 8, Decoration::Dot_Intersection, 9, Decoration::Gap, 5);
generator->removeFlag(Generate::Config::FullGaps);
//Pink Bridge 2
Expand Down Expand Up @@ -1331,7 +1332,7 @@ void PuzzleList::GenerateQuarryH()
//All together
generator->removeFlag(Generate::Config::WriteColors);
generator->setFlag(Generate::Config::ResetColors);
generator->setGridSize(7, 3);
generator->setGridSize(6, 3);
generator->pathWidth = 0.6f;
generator->generate(0x0A3CB, Decoration::Star | Decoration::Color::Orange, 4, Decoration::Poly | Decoration::Color::Orange, 2,
Decoration::Poly | Decoration::Negative | Decoration::Color::Magenta, 2, Decoration::Eraser | Decoration::White, 2);
Expand Down
23 changes: 23 additions & 0 deletions Source/Special.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@
#include "Quaternion.h"
#include "../App/Version.h"

void Special::generateSpecialSymMaze(std::shared_ptr<Generate> gen, int id) {
do {
gen->setFlagOnce(Generate::Config::DisableWrite);
generator->setSymbol(Decoration::Start, 0, 16);
generator->setSymbol(Decoration::Start, 22, 16);
generator->setSymbol(Decoration::Exit, 8, 0);
generator->setSymbol(Decoration::Exit, 14, 0);
generator->setFlagOnce(Generate::Config::ShortPath);
generator->generateMaze(0x0005C);
} while (generator->_path.count(Point(12, 16)));
std::shared_ptr<Panel> puzzle = gen->_panel;
for (int x = 0; x < puzzle->_width / 2; x++) {
for (int y = 0; y < puzzle->_height; y++) {
Point sp = puzzle->get_sym_point(x, y, Panel::Symmetry::Vertical);
if (puzzle->_grid[sp.first][sp.second] & Decoration::Gap) {
puzzle->_grid[x][y] = puzzle->_grid[sp.first][sp.second];
puzzle->_grid[sp.first][sp.second] = 0;
}
}
}
gen->write(id);
}

void Special::generateReflectionDotPuzzle(std::shared_ptr<Generate> gen, int id1, int id2, std::vector<std::pair<int, int>> symbols, Panel::Symmetry symmetry, bool split)
{
gen->setFlagOnce(Generate::Config::DisableWrite);
Expand Down
1 change: 1 addition & 0 deletions Source/Special.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Special {
this->generator = generator;
}

void generateSpecialSymMaze(std::shared_ptr<Generate> gen, int id);
void generateReflectionDotPuzzle(std::shared_ptr<Generate> gen, int id1, int id2, std::vector<std::pair<int, int>> symbols, Panel::Symmetry symmetry, bool split);
void generateAntiPuzzle(int id);
void generateColorFilterPuzzle(int id, Point size, const std::vector<std::pair<int, int>>& symbols, const Color& filter);
Expand Down

0 comments on commit dd33cf6

Please sign in to comment.