From 00641f16c889093b32b8e97a6050817f6fe43780 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 3 Nov 2023 00:18:41 -0400 Subject: added weird symmetries (and some more puzzles) --- ext/wittle_generator/Panel.cpp | 8 +-- ext/wittle_generator/Panel.h | 32 ++++----- ext/wittle_generator/wittle_generator.cpp | 116 +++++++++++++++++++++++++++++- 3 files changed, 132 insertions(+), 24 deletions(-) (limited to 'ext/wittle_generator') diff --git a/ext/wittle_generator/Panel.cpp b/ext/wittle_generator/Panel.cpp index 879d205..3279943 100644 --- a/ext/wittle_generator/Panel.cpp +++ b/ext/wittle_generator/Panel.cpp @@ -127,12 +127,6 @@ std::string Panel::Write() { int genericFlags = 0; if (symmetry != Symmetry::None) { genericFlags |= Serializer::Symmetrical; - if (symmetry == Symmetry::Vertical || symmetry == Symmetry::Rotational) { - genericFlags |= Serializer::SymmetryX; - } - if (symmetry == Symmetry::Horizontal || symmetry == Symmetry::Rotational) { - genericFlags |= Serializer::SymmetryY; - } } serializer.writeByte(genericFlags); @@ -233,5 +227,7 @@ std::string Panel::Write() { } serializer.writeByte(settings); + serializer.writeByte(symmetry); + return serializer.str(); } diff --git a/ext/wittle_generator/Panel.h b/ext/wittle_generator/Panel.h index d152370..3bc23c9 100644 --- a/ext/wittle_generator/Panel.h +++ b/ext/wittle_generator/Panel.h @@ -188,22 +188,22 @@ class Panel { enum Symmetry { // NOTE - Not all of these are valid symmetries for certain // puzzles - None, - Horizontal, - Vertical, - Rotational, - RotateLeft, - RotateRight, - FlipXY, - FlipNegXY, - ParallelH, - ParallelV, - ParallelHFlip, - ParallelVFlip, - PillarParallel, - PillarHorizontal, - PillarVertical, - PillarRotational + None = 0, + Horizontal = 1, + Vertical = 2, + Rotational = 3, + RotateLeft = 4, + RotateRight = 5, + FlipXY = 6, + FlipNegXY = 7, + ParallelH = 8, + ParallelV = 9, + ParallelHFlip = 10, + ParallelVFlip = 11, + PillarParallel = 12, + PillarHorizontal = 13, + PillarVertical = 14, + PillarRotational = 15, }; Symmetry symmetry; diff --git a/ext/wittle_generator/wittle_generator.cpp b/ext/wittle_generator/wittle_generator.cpp index c2407cf..0efac07 100644 --- a/ext/wittle_generator/wittle_generator.cpp +++ b/ext/wittle_generator/wittle_generator.cpp @@ -420,7 +420,7 @@ Rice::Object wittle_generator_generate_easy(Rice::Object /* self */) { Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { Generate generator; - int choice = Random::rand() % 66; + int choice = Random::rand() % 69; std::cout << "Generate MEDIUM: choice " << std::dec << choice << std::endl; switch (choice) { @@ -1015,6 +1015,33 @@ Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { {Decoration::Dot_Intersection, 25}}}); break; } + case 66: { + generator.setSymmetry(Panel::Symmetry::FlipNegXY); + generator.generate(7, 7, + {{{Decoration::Gap, 10}, + {Decoration::Dot_Intersection, 8}, + {Decoration::Start, 2}, + {Decoration::Exit, 1}}}); + break; + } + case 67: { + generator.setSymmetry(Panel::Symmetry::ParallelV); + generator.generate(7, 7, + {{{Decoration::Gap, 12}, + {Decoration::Dot_Intersection, 10}, + {Decoration::Start, 2}, + {Decoration::Exit, 1}}}); + break; + } + case 68: { + generator.setSymmetry(Panel::Symmetry::ParallelHFlip); + generator.generate(7, 7, + {{{Decoration::Gap, 12}, + {Decoration::Dot_Intersection, 10}, + {Decoration::Start, 2}, + {Decoration::Exit, 1}}}); + break; + } } Rice::String str(generator.AsCode()); @@ -1024,7 +1051,7 @@ Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { Rice::Object wittle_generator_generate_expert(Rice::Object /* self */) { Generate generator; - int choice = Random::rand() % 40; + int choice = Random::rand() % 46; std::cout << "Generate EXPERT: choice " << std::dec << choice << std::endl; switch (choice) { @@ -1497,6 +1524,91 @@ Rice::Object wittle_generator_generate_expert(Rice::Object /* self */) { {Decoration::Dot_Intersection, 36}}}); break; } + case 40: { + generator.setGridSize(7, 7); + generator.setFlag(Generate::RequireCombineShapes); + generator.setSymmetry(Panel::ParallelV); + generator.setSymbol(Decoration::Start, 0, 14); + generator.setSymbol(Decoration::Start, 8, 14); + generator.setSymbol(Decoration::Exit, 6, 0); + generator.setSymbol(Decoration::Exit, 14, 0); + generator.generate(7, 7, + {{{Decoration::Poly | Decoration::Color::Orange, 5}}}); + break; + } + case 41: { + generator.setGridSize(7, 7); + generator.setFlag(Generate::RequireCombineShapes); + generator.setSymmetry(Panel::ParallelHFlip); + generator.setSymbol(Decoration::Start, 0, 14); + generator.setSymbol(Decoration::Start, 14, 6); + generator.setSymbol(Decoration::Exit, 0, 0); + generator.setSymbol(Decoration::Exit, 14, 8); + generator.generate(7, 7, + {{{Decoration::Poly | Decoration::Color::Orange, 5}}}); + break; + } + case 42: { + generator.setGridSize(7, 7); + generator.setFlag(Generate::RequireCombineShapes); + generator.setSymmetry(Panel::ParallelVFlip); + generator.setSymbol(Decoration::Start, 0, 14); + generator.setSymbol(Decoration::Start, 8, 0); + generator.setSymbol(Decoration::Exit, 6, 0); + generator.setSymbol(Decoration::Exit, 14, 14); + generator.generate(7, 7, + {{{Decoration::Poly | Decoration::Color::Orange, 5}}}); + break; + } + case 43: { + generator.setSymmetry(Panel::Symmetry::RotateLeft); + generator.setSymbol(Decoration::Start, 4, 4); + generator.setSymbol(Decoration::Start, 10, 4); + generator.setSymbol(Decoration::Start, 4, 10); + generator.setSymbol(Decoration::Start, 10, 10); + generator.setSymbol(Decoration::Exit, 4, 0); + generator.setSymbol(Decoration::Exit, 14, 4); + generator.setSymbol(Decoration::Exit, 0, 10); + generator.setSymbol(Decoration::Exit, 10, 14); + generator.generate( + 7, 7, + {{{Decoration::Triangle4 | Decoration::Color::Orange, 1}, + {Decoration::Triangle | Decoration::Color::Orange, 4}}}); + break; + } + case 44: { + generator.setFlag(Generate::WriteInvisible); + generator.setFlag(Generate::StartEdgeOnly); + generator.setSymmetry(Panel::Symmetry::FlipXY); + generator.setSymbol(Decoration::Exit, 0, 8); + generator.setSymbol(Decoration::Exit, 8, 0); + generator.generate(7, 7, + {{{Decoration::Dot | Decoration::Color::Blue, 2}, + {Decoration::Dot | Decoration::Color::Yellow, 2}, + {Decoration::Dot, 8}, + {Decoration::Eraser | Decoration::Color::White, 1}, + {Decoration::Start, 1}}}); + break; + } + case 45: { + generator.setFlag(Generate::WriteInvisible); + generator.setSymmetry(Panel::Symmetry::FlipXY); + generator.setSymbol(Decoration::Start, 0, 16); + generator.setSymbol(Decoration::Start, 16, 0); + generator.setSymbol(Decoration::Exit, 8, 0); + generator.setSymbol(Decoration::Exit, 8, 16); + generator.setSymbol(Decoration::Exit, 0, 8); + generator.setSymbol(Decoration::Exit, 16, 8); + generator.generate( + 8, 8, + {{{Decoration::Triangle | Decoration::Color::Cyan, 3}, + {Decoration::Triangle | Decoration::Color::Yellow, 2}, + {Decoration::Star | Decoration::Color::Cyan, 3}, + {Decoration::Star | Decoration::Color::Yellow, 3}, + {Decoration::Stone | Decoration::Color::Cyan, 2}, + {Decoration::Stone | Decoration::Color::Yellow, 3}}}); + break; + } } Rice::String str(generator.AsCode()); -- cgit 1.4.1