diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-30 00:18:04 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-10-30 00:18:04 -0400 |
commit | 489583486bd9d31de5bec8751d7e63997c325fd3 (patch) | |
tree | f6ebe78ad4acbfb39e76bc80aeea0ca9f17b5a1b | |
parent | 392cc8a0f938b0f363e1a9227d5ff9a3ecbdbe10 (diff) | |
download | wittle-489583486bd9d31de5bec8751d7e63997c325fd3.tar.gz wittle-489583486bd9d31de5bec8751d7e63997c325fd3.tar.bz2 wittle-489583486bd9d31de5bec8751d7e63997c325fd3.zip |
added archive page and some expert puzzles
-rw-r--r-- | app/assets/stylesheets/wittle/general.css.scss | 26 | ||||
-rw-r--r-- | app/controllers/wittle/puzzles_controller.rb | 3 | ||||
-rw-r--r-- | app/views/wittle/puzzles/about.html.haml | 1 | ||||
-rw-r--r-- | app/views/wittle/puzzles/index.html.haml | 25 | ||||
-rw-r--r-- | ext/wittle_generator/wittle_generator.cpp | 132 | ||||
-rw-r--r-- | lib/tasks/wittle_tasks.rake | 1 |
6 files changed, 184 insertions, 4 deletions
diff --git a/app/assets/stylesheets/wittle/general.css.scss b/app/assets/stylesheets/wittle/general.css.scss index c258734..a0eb980 100644 --- a/app/assets/stylesheets/wittle/general.css.scss +++ b/app/assets/stylesheets/wittle/general.css.scss | |||
@@ -143,3 +143,29 @@ input[type="range"]::-ms-thumb { | |||
143 | padding-left: 1em; | 143 | padding-left: 1em; |
144 | text-align: right; | 144 | text-align: right; |
145 | } | 145 | } |
146 | |||
147 | #archive { | ||
148 | width: 50%; | ||
149 | margin: 0 auto; | ||
150 | border-spacing: 0; | ||
151 | text-align: center; | ||
152 | |||
153 | tr { | ||
154 | &.odd { | ||
155 | background-color: #fff; | ||
156 | } | ||
157 | |||
158 | &.even { | ||
159 | background-color: #edf; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | th, td { | ||
164 | padding: 0.5em; | ||
165 | } | ||
166 | |||
167 | ul { | ||
168 | list-style-type: none; | ||
169 | padding: 0; | ||
170 | } | ||
171 | } | ||
diff --git a/app/controllers/wittle/puzzles_controller.rb b/app/controllers/wittle/puzzles_controller.rb index 2949f94..3c3c8a6 100644 --- a/app/controllers/wittle/puzzles_controller.rb +++ b/app/controllers/wittle/puzzles_controller.rb | |||
@@ -3,10 +3,11 @@ module Wittle | |||
3 | def about | 3 | def about |
4 | @normal_puzzle = Puzzle.normal.order(created_at: :desc).first | 4 | @normal_puzzle = Puzzle.normal.order(created_at: :desc).first |
5 | @hard_puzzle = Puzzle.hard.order(created_at: :desc).first | 5 | @hard_puzzle = Puzzle.hard.order(created_at: :desc).first |
6 | @expert_puzzle = Puzzle.expert.order(created_at: :desc).first | ||
6 | end | 7 | end |
7 | 8 | ||
8 | def index | 9 | def index |
9 | #@puzzle = WittleGenerator.new.generate_medium | 10 | @puzzles = Puzzle.select(:id, :created_at, :category).order(created_at: :asc).all.chunk { |puzzle| puzzle.created_at.localtime.to_date }.to_h.transform_values { |by_date| by_date.sort_by(&:category).chunk { |puzzle| puzzle.category }.to_h } |
10 | end | 11 | end |
11 | 12 | ||
12 | def show | 13 | def show |
diff --git a/app/views/wittle/puzzles/about.html.haml b/app/views/wittle/puzzles/about.html.haml index 628ba0b..6a47972 100644 --- a/app/views/wittle/puzzles/about.html.haml +++ b/app/views/wittle/puzzles/about.html.haml | |||
@@ -1,3 +1,4 @@ | |||
1 | %p by Hatkirby, with help from Sigma144 and jbzdarkid | 1 | %p by Hatkirby, with help from Sigma144 and jbzdarkid |
2 | %p= link_to "Normal", @normal_puzzle | 2 | %p= link_to "Normal", @normal_puzzle |
3 | %p= link_to "Hard", @hard_puzzle | 3 | %p= link_to "Hard", @hard_puzzle |
4 | %p= link_to "Expert", @expert_puzzle | ||
diff --git a/app/views/wittle/puzzles/index.html.haml b/app/views/wittle/puzzles/index.html.haml index e69de29..097eb87 100644 --- a/app/views/wittle/puzzles/index.html.haml +++ b/app/views/wittle/puzzles/index.html.haml | |||
@@ -0,0 +1,25 @@ | |||
1 | %h1 Archive | ||
2 | %table#archive | ||
3 | %tr | ||
4 | %th | ||
5 | %th Normal | ||
6 | %th Hard | ||
7 | %th Expert | ||
8 | - @puzzles.each do |date, dps| | ||
9 | %tr{ class: cycle("even", "odd") } | ||
10 | %td= date.strftime("%B %-d, %Y") | ||
11 | %td | ||
12 | - if dps.has_key? "normal" | ||
13 | %ul | ||
14 | - dps["normal"].each do |puzzle| | ||
15 | %li= link_to "\##{puzzle.id}", puzzle | ||
16 | %td | ||
17 | - if dps.has_key? "hard" | ||
18 | %ul | ||
19 | - dps["hard"].each do |puzzle| | ||
20 | %li= link_to "\##{puzzle.id}", puzzle | ||
21 | %td | ||
22 | - if dps.has_key? "expert" | ||
23 | %ul | ||
24 | - dps["expert"].each do |puzzle| | ||
25 | %li= link_to "\##{puzzle.id}", puzzle | ||
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 */) { | |||
404 | Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { | 403 | Rice::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 | |||
712 | Rice::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 | } |
diff --git a/lib/tasks/wittle_tasks.rake b/lib/tasks/wittle_tasks.rake index debf249..b9300c7 100644 --- a/lib/tasks/wittle_tasks.rake +++ b/lib/tasks/wittle_tasks.rake | |||
@@ -3,5 +3,6 @@ namespace :wittle do | |||
3 | task :generate_puzzles => :environment do | 3 | task :generate_puzzles => :environment do |
4 | Wittle::Puzzle.create(data: WittleGenerator.new.generate_easy, category: :normal) | 4 | Wittle::Puzzle.create(data: WittleGenerator.new.generate_easy, category: :normal) |
5 | Wittle::Puzzle.create(data: WittleGenerator.new.generate_medium, category: :hard) | 5 | Wittle::Puzzle.create(data: WittleGenerator.new.generate_medium, category: :hard) |
6 | Wittle::Puzzle.create(data: WittleGenerator.new.generate_expert, category: :expert) | ||
6 | end | 7 | end |
7 | end | 8 | end |