about summary refs log tree commit diff stats
path: root/ext
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-10-30 00:18:04 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-10-30 00:18:04 -0400
commit489583486bd9d31de5bec8751d7e63997c325fd3 (patch)
treef6ebe78ad4acbfb39e76bc80aeea0ca9f17b5a1b /ext
parent392cc8a0f938b0f363e1a9227d5ff9a3ecbdbe10 (diff)
downloadwittle-489583486bd9d31de5bec8751d7e63997c325fd3.tar.gz
wittle-489583486bd9d31de5bec8751d7e63997c325fd3.tar.bz2
wittle-489583486bd9d31de5bec8751d7e63997c325fd3.zip
added archive page and some expert puzzles
Diffstat (limited to 'ext')
-rw-r--r--ext/wittle_generator/wittle_generator.cpp132
1 files changed, 129 insertions, 3 deletions
diff --git a/ext/wittle_generator/wittle_generator.cpp b/ext/wittle_generator/wittle_generator.cpp index e1b5323..f3d2947 100644 --- a/ext/wittle_generator/wittle_generator.cpp +++ b/ext/wittle_generator/wittle_generator.cpp
@@ -392,7 +392,6 @@ Rice::Object wittle_generator_generate_easy(Rice::Object /* self */) {
392 {{{Decoration::Star | Decoration::Color::Magenta, 6}, 392 {{{Decoration::Star | Decoration::Color::Magenta, 6},
393 {Decoration::Stone | Decoration::Color::Orange, 4}, 393 {Decoration::Stone | Decoration::Color::Orange, 4},
394 {Decoration::Stone | Decoration::Color::Green, 4}}}); 394 {Decoration::Stone | Decoration::Color::Green, 4}}});
395 generator.place_gaps(8);
396 break; 395 break;
397 } 396 }
398 } 397 }
@@ -404,7 +403,7 @@ Rice::Object wittle_generator_generate_easy(Rice::Object /* self */) {
404Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { 403Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) {
405 Generate generator; 404 Generate generator;
406 405
407 int choice = Random::rand() % 30; 406 int choice = Random::rand() % 33;
408 std::cout << "Generate MEDIUM: choice " << std::dec << choice << std::endl; 407 std::cout << "Generate MEDIUM: choice " << std::dec << choice << std::endl;
409 408
410 switch (choice) { 409 switch (choice) {
@@ -679,6 +678,132 @@ Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) {
679 4, 4, {{{Decoration::Triangle | Decoration::Color::Orange, 8}}}); 678 4, 4, {{{Decoration::Triangle | Decoration::Color::Orange, 8}}});
680 break; 679 break;
681 } 680 }
681 case 30: {
682 generator.setFlag(Generate::RegularStartEnd);
683 generator.setFlag(Generate::LongestPath);
684 generator.setFlag(Generate::FullGaps);
685 generator.generate(
686 6, 6, {{{Decoration::Dot_Intersection, 12}, {Decoration::Gap, 18}}});
687 break;
688 }
689 case 31: {
690 generator.generate(5, 5,
691 {{{Decoration::Start, 8},
692 {Decoration::Exit, 1},
693 {Decoration::Dot_Intersection, 36}}});
694 break;
695 }
696 case 32: {
697 generator.setFlag(Generate::RegularStartEnd);
698 generator.setSymmetry(Panel::Horizontal);
699 generator.generate(
700 6, 6,
701 {{{Decoration::Triangle | Decoration::Color::Orange, 12},
702 {Decoration::Start, 1},
703 {Decoration::Exit, 1}}});
704 break;
705 }
706 }
707
708 Rice::String str(generator.AsCode());
709 return str;
710}
711
712Rice::Object wittle_generator_generate_expert(Rice::Object /* self */) {
713 Generate generator;
714
715 int choice = Random::rand() % 8;
716 std::cout << "Generate EXPERT: choice " << std::dec << choice << std::endl;
717
718 switch (choice) {
719 case 0: {
720 generator.setFlag(Generate::StartEdgeOnly);
721 generator.setSymmetry(Panel::Rotational);
722 generator.generate(
723 6, 6,
724 {{{Decoration::Triangle | Decoration::Color::Orange, 12},
725 {Decoration::Start, 1},
726 {Decoration::Exit, 1}}});
727 break;
728 }
729 case 1: {
730 generator.setFlag(Generate::StartEdgeOnly);
731 generator.setFlag(Generate::WriteInvisible);
732 generator.setSymmetry(Panel::Rotational);
733 generator.generate(7, 7,
734 {{{Decoration::Dot | Decoration::Color::Blue, 4},
735 {Decoration::Dot | Decoration::Color::Yellow, 4},
736 {Decoration::Dot, 7},
737 {Decoration::Start, 1},
738 {Decoration::Exit, 1}}});
739 break;
740 }
741 case 2: {
742 generator.setFlag(Generate::StartEdgeOnly);
743 generator.setFlag(Generate::WriteInvisible);
744 generator.setSymmetry(Panel::Rotational);
745 generator.generate(7, 7,
746 {{{Decoration::Stone | Decoration::Color::Black, 6},
747 {Decoration::Stone | Decoration::Color::White, 6},
748 {Decoration::Start, 1},
749 {Decoration::Exit, 1}}});
750 break;
751 }
752 case 3: {
753 generator.setFlag(Generate::StartEdgeOnly);
754 generator.setFlag(Generate::WriteInvisible);
755 generator.setSymmetry(Panel::Rotational);
756 generator.generate(7, 7,
757 {{{Decoration::Star | Decoration::Color::Orange, 6},
758 {Decoration::Star | Decoration::Color::Green, 6},
759 {Decoration::Start, 1},
760 {Decoration::Exit, 1}}});
761 break;
762 }
763 case 4: {
764 generator.setFlag(Generate::StartEdgeOnly);
765 generator.setFlag(Generate::WriteInvisible);
766 generator.setFlag(Generate::RequireCombineShapes);
767 generator.setSymmetry(Panel::Rotational);
768 generator.generate(5, 5,
769 {{{Decoration::Poly | Decoration::Color::Yellow, 3},
770 {Decoration::Start, 1},
771 {Decoration::Exit, 1}}});
772 break;
773 }
774 case 5: {
775 generator.setFlag(Generate::StartEdgeOnly);
776 generator.setFlag(Generate::WriteInvisible);
777 generator.setSymmetry(Panel::Rotational);
778 generator.generate(7, 7,
779 {{{Decoration::Dot | Decoration::Color::Blue, 2},
780 {Decoration::Dot | Decoration::Color::Yellow, 2},
781 {Decoration::Dot, 8},
782 {Decoration::Eraser | Decoration::Color::Purple, 1},
783 {Decoration::Start, 1}}});
784 break;
785 }
786 case 6: {
787 generator.setFlag(Generate::RegularStartEnd);
788 generator.generate(
789 4, 4,
790 {{{Decoration::Triangle | Decoration::Color::Orange, 15},
791 {Decoration::Eraser | Decoration::Color::Purple, 1}}});
792 break;
793 }
794 case 7: {
795 generator.setFlag(Generate::RegularStartEnd);
796 generator.generate(
797 4, 4,
798 {{{Decoration::Stone | Decoration::Color::White, 1},
799 {Decoration::Stone | Decoration::Color::Black, 2},
800 {Decoration::Stone | Decoration::Color::Red, 2},
801 {Decoration::Star | Decoration::Color::White, 4},
802 {Decoration::Star | Decoration::Color::Black, 3},
803 {Decoration::Star | Decoration::Color::Red, 3},
804 {Decoration::Decoration::Eraser | Decoration::Color::Green, 1}}});
805 break;
806 }
682 } 807 }
683 808
684 Rice::String str(generator.AsCode()); 809 Rice::String str(generator.AsCode());
@@ -689,5 +814,6 @@ extern "C" void Init_wittle_generator() {
689 Rice::Class rb_cWittleGenerator = 814 Rice::Class rb_cWittleGenerator =
690 Rice::define_class("WittleGenerator") 815 Rice::define_class("WittleGenerator")
691 .define_method("generate_easy", &wittle_generator_generate_easy) 816 .define_method("generate_easy", &wittle_generator_generate_easy)
692 .define_method("generate_medium", &wittle_generator_generate_medium); 817 .define_method("generate_medium", &wittle_generator_generate_medium)
818 .define_method("generate_expert", &wittle_generator_generate_expert);
693} 819}