diff options
Diffstat (limited to 'ext/wittle_generator')
-rw-r--r-- | ext/wittle_generator/Generate.cpp | 8 | ||||
-rw-r--r-- | ext/wittle_generator/Generate.h | 4 | ||||
-rw-r--r-- | ext/wittle_generator/Panel.cpp | 17 | ||||
-rw-r--r-- | ext/wittle_generator/Panel.h | 2 | ||||
-rw-r--r-- | ext/wittle_generator/wittle_generator.cpp | 693 |
5 files changed, 695 insertions, 29 deletions
diff --git a/ext/wittle_generator/Generate.cpp b/ext/wittle_generator/Generate.cpp index 5e38ba8..2a92269 100644 --- a/ext/wittle_generator/Generate.cpp +++ b/ext/wittle_generator/Generate.cpp | |||
@@ -491,8 +491,8 @@ void Generate::generate(int width, int height, PuzzleSymbols symbols) { | |||
491 | // point the generator fails to add a symbol while still making the solution | 491 | // point the generator fails to add a symbol while still making the solution |
492 | // correct, the function returns false and must be called again. | 492 | // correct, the function returns false and must be called again. |
493 | bool Generate::generateInternal(int width, int height, PuzzleSymbols symbols) { | 493 | bool Generate::generateInternal(int width, int height, PuzzleSymbols symbols) { |
494 | _width = width; | 494 | _width = width * 2 + 1; |
495 | _height = height; | 495 | _height = height * 2 + 1; |
496 | 496 | ||
497 | initPanel(); | 497 | initPanel(); |
498 | 498 | ||
@@ -966,7 +966,7 @@ std::vector<int> Generate::get_symbols_in_region( | |||
966 | // Place a start point in a random location | 966 | // Place a start point in a random location |
967 | bool Generate::place_start(int amount) { | 967 | bool Generate::place_start(int amount) { |
968 | _starts.clear(); | 968 | _starts.clear(); |
969 | //_panel->_startpoints.clear(); | 969 | _panel->ClearStartpoints(); |
970 | while (amount > 0) { | 970 | while (amount > 0) { |
971 | Point pos = Point(Random::rand() % (_panel->width() / 2 + 1) * 2, | 971 | Point pos = Point(Random::rand() % (_panel->width() / 2 + 1) * 2, |
972 | Random::rand() % (_panel->height() / 2 + 1) * 2); | 972 | Random::rand() % (_panel->height() / 2 + 1) * 2); |
@@ -1014,7 +1014,7 @@ bool Generate::place_start(int amount) { | |||
1014 | // Place an exit point in a random location on the edge of the grid | 1014 | // Place an exit point in a random location on the edge of the grid |
1015 | bool Generate::place_exit(int amount) { | 1015 | bool Generate::place_exit(int amount) { |
1016 | _exits.clear(); | 1016 | _exits.clear(); |
1017 | //_panel->_endpoints.clear(); | 1017 | _panel->ClearExits(); |
1018 | while (amount > 0) { | 1018 | while (amount > 0) { |
1019 | Point pos = Point(Random::rand() % (_panel->width() / 2 + 1) * 2, | 1019 | Point pos = Point(Random::rand() % (_panel->width() / 2 + 1) * 2, |
1020 | Random::rand() % (_panel->height() / 2 + 1) * 2); | 1020 | Random::rand() % (_panel->height() / 2 + 1) * 2); |
diff --git a/ext/wittle_generator/Generate.h b/ext/wittle_generator/Generate.h index cbb870d..9969998 100644 --- a/ext/wittle_generator/Generate.h +++ b/ext/wittle_generator/Generate.h | |||
@@ -114,6 +114,8 @@ class Generate { | |||
114 | std::set<Point> customPath; | 114 | std::set<Point> customPath; |
115 | Color arrowColor, backgroundColor, successColor; // For the arrow puzzles | 115 | Color arrowColor, backgroundColor, successColor; // For the arrow puzzles |
116 | 116 | ||
117 | bool place_gaps(int amount); | ||
118 | |||
117 | private: | 119 | private: |
118 | int get_symbol_type(int flags) { return flags & 0x700; } | 120 | int get_symbol_type(int flags) { return flags & 0x700; } |
119 | void set_path(Point pos); | 121 | void set_path(Point pos); |
@@ -174,7 +176,7 @@ class Generate { | |||
174 | bool place_start(int amount); | 176 | bool place_start(int amount); |
175 | bool place_exit(int amount); | 177 | bool place_exit(int amount); |
176 | bool can_place_gap(Point pos); | 178 | bool can_place_gap(Point pos); |
177 | bool place_gaps(int amount); | 179 | |
178 | bool can_place_dot(Point pos, bool intersectionOnly); | 180 | bool can_place_dot(Point pos, bool intersectionOnly); |
179 | bool place_dots(int amount, int color, bool intersectionOnly); | 181 | bool place_dots(int amount, int color, bool intersectionOnly); |
180 | bool can_place_stone(const std::set<Point>& region, int color); | 182 | bool can_place_stone(const std::set<Point>& region, int color); |
diff --git a/ext/wittle_generator/Panel.cpp b/ext/wittle_generator/Panel.cpp index 4bf4be7..892d4cc 100644 --- a/ext/wittle_generator/Panel.cpp +++ b/ext/wittle_generator/Panel.cpp | |||
@@ -157,16 +157,11 @@ std::string Panel::Write() { | |||
157 | serializer.writeByte(Serializer::Nega); | 157 | serializer.writeByte(Serializer::Nega); |
158 | serializer.writeColor(val & 0xF); | 158 | serializer.writeColor(val & 0xF); |
159 | } else if (symbol == Decoration::Poly) { | 159 | } else if (symbol == Decoration::Poly) { |
160 | serializer.writeByte(Serializer::Poly); | 160 | if (val & Decoration::Negative) { |
161 | serializer.writeColor(val & 0xF); | 161 | serializer.writeByte(Serializer::Ylop); |
162 | 162 | } else { | |
163 | long polyshape = (val & 0xFFFF0000) >> 16; | 163 | serializer.writeByte(Serializer::Poly); |
164 | if (val & Decoration::Can_Rotate) { | ||
165 | polyshape |= (1 << 20); | ||
166 | } | 164 | } |
167 | serializer.writeLong(polyshape); | ||
168 | } else if (symbol == Decoration::Negative) { | ||
169 | serializer.writeByte(Serializer::Ylop); | ||
170 | serializer.writeColor(val & 0xF); | 165 | serializer.writeColor(val & 0xF); |
171 | 166 | ||
172 | long polyshape = (val & 0xFFFF0000) >> 16; | 167 | long polyshape = (val & 0xFFFF0000) >> 16; |
@@ -194,7 +189,9 @@ std::string Panel::Write() { | |||
194 | } else { | 189 | } else { |
195 | serializer.writeByte(Serializer::DotNone); | 190 | serializer.writeByte(Serializer::DotNone); |
196 | } | 191 | } |
197 | if (val & Decoration::Gap) { | 192 | if (val == OPEN) { |
193 | serializer.writeByte(Serializer::GapFull); | ||
194 | } else if (val & Decoration::Gap) { | ||
198 | serializer.writeByte(Serializer::GapBreak); | 195 | serializer.writeByte(Serializer::GapBreak); |
199 | } else { | 196 | } else { |
200 | serializer.writeByte(Serializer::GapNone); | 197 | serializer.writeByte(Serializer::GapNone); |
diff --git a/ext/wittle_generator/Panel.h b/ext/wittle_generator/Panel.h index 7f1588d..b8dec2f 100644 --- a/ext/wittle_generator/Panel.h +++ b/ext/wittle_generator/Panel.h | |||
@@ -160,6 +160,8 @@ class Panel { | |||
160 | Decoration::Color color = Decoration::Color::None); | 160 | Decoration::Color color = Decoration::Color::None); |
161 | void ClearGridSymbol(int x, int y); | 161 | void ClearGridSymbol(int x, int y); |
162 | void Resize(int width, int height); | 162 | void Resize(int width, int height); |
163 | void ClearStartpoints() { _startpoints.clear(); } | ||
164 | void ClearExits() { _endpoints.clear(); } | ||
163 | 165 | ||
164 | int width() const { return _width; } | 166 | int width() const { return _width; } |
165 | int height() const { return _height; } | 167 | int height() const { return _height; } |
diff --git a/ext/wittle_generator/wittle_generator.cpp b/ext/wittle_generator/wittle_generator.cpp index e8f2dba..e1b5323 100644 --- a/ext/wittle_generator/wittle_generator.cpp +++ b/ext/wittle_generator/wittle_generator.cpp | |||
@@ -1,21 +1,685 @@ | |||
1 | #include <iostream> | ||
1 | #include <rice/rice.hpp> | 2 | #include <rice/rice.hpp> |
2 | 3 | ||
3 | #include "Generate.h" | 4 | #include "Generate.h" |
5 | #include "Random.h" | ||
4 | 6 | ||
5 | Rice::Object wittle_generator_generate(Rice::Object /* self */) { | 7 | Rice::Object wittle_generator_generate_easy(Rice::Object /* self */) { |
6 | Generate generator; | 8 | Generate generator; |
7 | // generator.setFlag(Generate::RegularStartEnd); | 9 | |
8 | /*generator.generate(4 * 2 + 1, 4 * 2 + 1, | 10 | int choice = Random::rand() % 46; |
9 | {{{Decoration::Triangle | Decoration::Orange, 6}}});*/ | 11 | std::cout << "Generate EASY: choice " << std::dec << choice << std::endl; |
10 | // generator.setSymmetry(Panel::Vertical); | 12 | |
11 | generator.setSymbol(Decoration::Exit, 0, 0); | 13 | switch (choice) { |
12 | generator.setSymbol(Decoration::Exit, 7 * 2, 0); | 14 | case 0: { |
13 | generator.setSymbol(Decoration::Exit, 7 * 2, 7 * 2); | 15 | generator.setSymbol(Decoration::Start, 2 * 2, 2 * 2); |
14 | generator.generate(7 * 2 + 1, 7 * 2 + 1, | 16 | generator.setSymbol(Decoration::Exit, 4 * 2, 0); |
15 | {{{Decoration::Stone | Decoration::Color::White, 10}, | 17 | generator.generate( |
16 | {Decoration::Stone | Decoration::Color::Black, 10}, | 18 | 4, 4, {{{Decoration::Dot_Intersection, 25}, {Decoration::Gap, 2}}}); |
17 | {Decoration::Dot, 10}, | 19 | break; |
18 | {Decoration::Start, 2}}}); | 20 | } |
21 | case 1: { | ||
22 | generator.setSymbol(Decoration::Start, 0, 4 * 2); | ||
23 | generator.generate(4, 4, | ||
24 | {{{Decoration::Stone | Decoration::Color::Black, 7}, | ||
25 | {Decoration::Stone | Decoration::Color::White, 5}, | ||
26 | {Decoration::Exit, 1}}}); | ||
27 | break; | ||
28 | } | ||
29 | case 2: { | ||
30 | generator.setFlag(Generate::RegularStartEnd); | ||
31 | generator.setSymmetry(Panel::Rotational); | ||
32 | generator.generate(6, 6, {{{Decoration::Gap, 15}}}); | ||
33 | break; | ||
34 | } | ||
35 | case 3: { | ||
36 | generator.setFlag(Generate::RegularStartEnd); | ||
37 | generator.setSymmetry(Panel::Vertical); | ||
38 | generator.generate(5, 8, {{{Decoration::Gap, 15}}}); | ||
39 | break; | ||
40 | } | ||
41 | case 4: { | ||
42 | generator.setFlag(Generate::RegularStartEnd); | ||
43 | generator.setSymmetry(Panel::Horizontal); | ||
44 | generator.generate(5, 5, {{{Decoration::Dot, 7}}}); | ||
45 | break; | ||
46 | } | ||
47 | case 5: { | ||
48 | generator.setFlag(Generate::RegularStartEnd); | ||
49 | generator.setSymmetry(Panel::Rotational); | ||
50 | generator.generate(5, 5, {{{Decoration::Dot, 6}}}); | ||
51 | break; | ||
52 | } | ||
53 | case 6: { | ||
54 | generator.setFlag(Generate::RegularStartEnd); | ||
55 | generator.setSymmetry(Panel::Rotational); | ||
56 | generator.generate(5, 5, | ||
57 | {{{Decoration::Dot | Decoration::Color::Blue, 1}, | ||
58 | {Decoration::Dot | Decoration::Color::Yellow, 2}, | ||
59 | {Decoration::Dot, 4}}}); | ||
60 | break; | ||
61 | } | ||
62 | case 7: { | ||
63 | generator.setFlag(Generate::RegularStartEnd); | ||
64 | generator.generate(4, 4, | ||
65 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}}}); | ||
66 | break; | ||
67 | } | ||
68 | case 8: { | ||
69 | generator.setFlag(Generate::FullGaps); | ||
70 | generator.setFlag(Generate::StartEdgeOnly); | ||
71 | generator.generate(5, 5, | ||
72 | {{{Decoration::Gap, 16}, | ||
73 | {Decoration::Dot, 10}, | ||
74 | {Decoration::Exit, 1}, | ||
75 | {Decoration::Start, 1}}}); | ||
76 | break; | ||
77 | } | ||
78 | case 9: { | ||
79 | generator.setFlag(Generate::RegularStartEnd); | ||
80 | generator.generate(3, 3, | ||
81 | {{{Decoration::Eraser | Decoration::Color::Green, 1}, | ||
82 | {Decoration::Dot, 8}}}); | ||
83 | break; | ||
84 | } | ||
85 | case 10: { | ||
86 | generator.setFlag(Generate::RegularStartEnd); | ||
87 | generator.generate( | ||
88 | 4, 4, | ||
89 | {{{Decoration::Stone | Decoration::Color::White, 8}, | ||
90 | {Decoration::Stone | Decoration::Color::Black, 4}, | ||
91 | {Decoration::Eraser | Decoration::Color::Green, 1}}}); | ||
92 | break; | ||
93 | } | ||
94 | case 11: { | ||
95 | generator.setFlag(Generate::RegularStartEnd); | ||
96 | generator.generate( | ||
97 | 4, 4, | ||
98 | {{{Decoration::Stone | Decoration::Color::Red, 4}, | ||
99 | {Decoration::Stone | Decoration::Color::White, 4}, | ||
100 | {Decoration::Stone | Decoration::Color::Black, 3}, | ||
101 | {Decoration::Eraser | Decoration::Color::Green, 1}}}); | ||
102 | break; | ||
103 | } | ||
104 | case 12: { | ||
105 | generator.setFlag(Generate::RegularStartEnd); | ||
106 | generator.setFlag(Generate::RequireCombineShapes); | ||
107 | generator.generate(4, 4, | ||
108 | {{{Decoration::Poly | Decoration::Color::Yellow, 1}, | ||
109 | {Decoration::Poly | Decoration::Color::Yellow | | ||
110 | Decoration::Can_Rotate, | ||
111 | 1}, | ||
112 | {Decoration::Gap, 5}}}); | ||
113 | break; | ||
114 | } | ||
115 | case 13: { | ||
116 | generator.setFlag(Generate::RegularStartEnd); | ||
117 | generator.generate( | ||
118 | 3, 3, | ||
119 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
120 | {Decoration::Eraser | Decoration::Color::White, 1}}}); | ||
121 | break; | ||
122 | } | ||
123 | case 14: { | ||
124 | generator.setFlag(Generate::FullGaps); | ||
125 | generator.generate(4, 4, | ||
126 | {{{Decoration::Gap, 8}, | ||
127 | {Decoration::Dot_Intersection, 10}, | ||
128 | {Decoration::Exit, 1}, | ||
129 | {Decoration::Start, 3}}}); | ||
130 | break; | ||
131 | } | ||
132 | case 15: { | ||
133 | generator.generate(5, 5, | ||
134 | {{{Decoration::Exit, 1}, | ||
135 | {Decoration::Stone | Decoration::Color::Black, 11}, | ||
136 | {Decoration::Stone | Decoration::Color::White, 8}, | ||
137 | {Decoration::Start, 3}}}); | ||
138 | break; | ||
139 | } | ||
140 | case 16: { | ||
141 | generator.setFlag(Generate::RegularStartEnd); | ||
142 | generator.generate(4, 4, | ||
143 | {{{Decoration::Star | Decoration::Color::Green, 6}, | ||
144 | {Decoration::Star | Decoration::Color::Orange, 5}, | ||
145 | {Decoration::Eraser | Decoration::Orange, 1}}}); | ||
146 | break; | ||
147 | } | ||
148 | case 17: { | ||
149 | generator.setFlag(Generate::RegularStartEnd); | ||
150 | generator.generate(4, 4, | ||
151 | {{{Decoration::Star | Decoration::Color::Orange, 6}, | ||
152 | {Decoration::Star | Decoration::Color::Magenta, 5}, | ||
153 | {Decoration::Star | Decoration::Color::Green, 4}, | ||
154 | {Decoration::Eraser | Decoration::Magenta, 1}}}); | ||
155 | break; | ||
156 | } | ||
157 | case 18: { | ||
158 | generator.setFlag(Generate::RegularStartEnd); | ||
159 | generator.generate(4, 4, | ||
160 | {{{Decoration::Star | Decoration::Color::Magenta, 6}, | ||
161 | {Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
162 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
163 | break; | ||
164 | } | ||
165 | case 19: { | ||
166 | generator.setFlag(Generate::RegularStartEnd); | ||
167 | generator.generate(4, 4, | ||
168 | {{{Decoration::Star | Decoration::Color::Magenta, 5}, | ||
169 | {Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
170 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
171 | break; | ||
172 | } | ||
173 | case 20: { | ||
174 | generator.setFlag(Generate::TreehouseLayout); | ||
175 | generator.generate(4, 4, | ||
176 | {{{Decoration::Star | Decoration::Color::Orange, 4}, | ||
177 | {Decoration::Gap, 10}}}); | ||
178 | break; | ||
179 | } | ||
180 | case 21: { | ||
181 | generator.setFlag(Generate::RegularStartEnd); | ||
182 | generator.generate(5, 5, | ||
183 | {{{Decoration::Star | Decoration::Color::Orange, 10}, | ||
184 | {Decoration::Gap, 3}}}); | ||
185 | break; | ||
186 | } | ||
187 | case 22: { | ||
188 | generator.setFlag(Generate::TreehouseLayout); | ||
189 | generator.generate(4, 4, | ||
190 | {{{Decoration::Star | Decoration::Color::Orange, 4}, | ||
191 | {Decoration::Star | Decoration::Color::Magenta, 4}, | ||
192 | {Decoration::Gap, 8}}}); | ||
193 | break; | ||
194 | } | ||
195 | case 23: { | ||
196 | generator.setFlag(Generate::TreehouseLayout); | ||
197 | generator.generate(4, 4, | ||
198 | {{{Decoration::Star | Decoration::Color::Orange, 4}, | ||
199 | {Decoration::Star | Decoration::Color::Magenta, 2}, | ||
200 | {Decoration::Star | Decoration::Color::Green, 2}, | ||
201 | {Decoration::Gap, 8}}}); | ||
202 | break; | ||
203 | } | ||
204 | case 24: { | ||
205 | generator.setFlag(Generate::TreehouseLayout); | ||
206 | generator.generate(4, 3, | ||
207 | {{{Decoration::Star | Decoration::Color::Orange, 6}, | ||
208 | {Decoration::Star | Decoration::Color::Magenta, 4}, | ||
209 | {Decoration::Star | Decoration::Color::Green, 2}}}); | ||
210 | break; | ||
211 | } | ||
212 | case 25: { | ||
213 | generator.setFlag(Generate::TreehouseLayout); | ||
214 | generator.setFlag(Generate::FullGaps); | ||
215 | generator.generate(4, 4, | ||
216 | {{{Decoration::Star | Decoration::Color::Magenta, 6}, | ||
217 | {Decoration::Dot_Intersection, 6}, | ||
218 | {Decoration::Gap, 3}}}); | ||
219 | break; | ||
220 | } | ||
221 | case 26: { | ||
222 | generator.setFlag(Generate::TreehouseLayout); | ||
223 | generator.generate(4, 4, | ||
224 | {{{Decoration::Star | Decoration::Color::Magenta, 4}, | ||
225 | {Decoration::Stone | Decoration::Color::Black, 4}, | ||
226 | {Decoration::Stone | Decoration::Color::White, 4}}}); | ||
227 | break; | ||
228 | } | ||
229 | case 27: { | ||
230 | generator.setFlag(Generate::TreehouseLayout); | ||
231 | generator.generate(3, 3, | ||
232 | {{{Decoration::Star | Decoration::Color::Black, 1}, | ||
233 | {Decoration::Stone | Decoration::Color::Black, 2}, | ||
234 | {Decoration::Stone | Decoration::Color::White, 2}}}); | ||
235 | break; | ||
236 | } | ||
237 | case 28: { | ||
238 | generator.setFlag(Generate::TreehouseLayout); | ||
239 | generator.generate( | ||
240 | 4, 4, | ||
241 | {{{Decoration::Star | Decoration::Color::White, 2}, | ||
242 | {Decoration::Stone | Decoration::Color::Black, 2}, | ||
243 | {Decoration::Stone | Decoration::Color::White, 2}, | ||
244 | {Decoration::Stone | Decoration::Color::Purple, 2}}}); | ||
245 | break; | ||
246 | } | ||
247 | case 29: { | ||
248 | generator.setFlag(Generate::TreehouseLayout); | ||
249 | generator.generate( | ||
250 | 4, 4, | ||
251 | {{{Decoration::Poly | Decoration::Color::Orange, 2}, | ||
252 | {Decoration::Star | Decoration::Color::Magenta, 4}}}); | ||
253 | break; | ||
254 | } | ||
255 | case 30: { | ||
256 | generator.setFlag(Generate::TreehouseLayout); | ||
257 | generator.generate( | ||
258 | 4, 5, | ||
259 | {{{Decoration::Stone | Decoration::Color::White, 8}, | ||
260 | {Decoration::Stone | Decoration::Color::Black, 8}, | ||
261 | {Decoration::Eraser | Decoration::Color::White, 2}}}); | ||
262 | break; | ||
263 | } | ||
264 | case 31: { | ||
265 | generator.setFlag(Generate::TreehouseLayout); | ||
266 | generator.generate(4, 5, | ||
267 | {{{Decoration::Poly | Decoration::Color::Orange, 2}, | ||
268 | {Decoration::Stone | Decoration::Color::White, 4}, | ||
269 | {Decoration::Stone | Decoration::Color::Black, 4}, | ||
270 | {Decoration::Gap, 4}}}); | ||
271 | break; | ||
272 | } | ||
273 | case 32: { | ||
274 | generator.setFlag(Generate::RegularStartEnd); | ||
275 | generator.generate(4, 4, | ||
276 | {{{Decoration::Dot_Intersection, 25}, | ||
277 | {Decoration::Poly | Decoration::Color::Yellow, 2}}}); | ||
278 | break; | ||
279 | } | ||
280 | case 33: { | ||
281 | generator.setFlag(Generate::RegularStartEnd); | ||
282 | generator.generate( | ||
283 | 4, 4, | ||
284 | {{{Decoration::Dot_Intersection, 25}, | ||
285 | {Decoration::Poly | Decoration::Color::Yellow | | ||
286 | Decoration::Can_Rotate, | ||
287 | 2}, | ||
288 | {Decoration::Eraser | Decoration::Color::White, 1}}}); | ||
289 | break; | ||
290 | } | ||
291 | case 34: { | ||
292 | generator.setFlag(Generate::RegularStartEnd); | ||
293 | generator.setSymmetry(Panel::Rotational); | ||
294 | generator.generate(5, 5, | ||
295 | {{{Decoration::Stone | Decoration::Color::Black, 6}, | ||
296 | {Decoration::Stone | Decoration::Color::White, 6}}}); | ||
297 | break; | ||
298 | } | ||
299 | case 35: { | ||
300 | generator.setFlag(Generate::RegularStartEnd); | ||
301 | generator.setSymmetry(Panel::Rotational); | ||
302 | generator.generate(5, 5, | ||
303 | {{{Decoration::Stone | Decoration::Color::Black, 5}, | ||
304 | {Decoration::Stone | Decoration::Color::White, 5}, | ||
305 | {Decoration::Dot, 3}}}); | ||
306 | break; | ||
307 | } | ||
308 | case 36: { | ||
309 | generator.setFlag(Generate::RegularStartEnd); | ||
310 | generator.setFlag(Generate::SplitShapes); | ||
311 | generator.generate(4, 4, | ||
312 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
313 | {Decoration::Gap, 8}}}); | ||
314 | break; | ||
315 | } | ||
316 | case 37: { | ||
317 | generator.setFlag(Generate::RegularStartEnd); | ||
318 | generator.setFlag(Generate::BigShapes); | ||
319 | generator.generate(5, 5, | ||
320 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
321 | {Decoration::Gap, 12}}}); | ||
322 | break; | ||
323 | } | ||
324 | case 38: { | ||
325 | generator.setFlag(Generate::RegularStartEnd); | ||
326 | generator.setFlag(Generate::DisconnectShapes); | ||
327 | generator.generate(3, 3, | ||
328 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}}}); | ||
329 | break; | ||
330 | } | ||
331 | case 39: { | ||
332 | generator.setFlag(Generate::RegularStartEnd); | ||
333 | generator.setFlag(Generate::DisconnectShapes); | ||
334 | generator.setFlag(Generate::BigShapes); | ||
335 | generator.generate(4, 4, | ||
336 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}}}); | ||
337 | break; | ||
338 | } | ||
339 | case 40: { | ||
340 | generator.setFlag(Generate::RegularStartEnd); | ||
341 | generator.setFlag(Generate::RequireCombineShapes); | ||
342 | generator.setFlag(Generate::DisableCancelShapes); | ||
343 | generator.generate( | ||
344 | 3, 3, | ||
345 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
346 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
347 | 1}}}); | ||
348 | break; | ||
349 | } | ||
350 | case 41: { | ||
351 | generator.setFlag(Generate::RegularStartEnd); | ||
352 | generator.setFlag(Generate::RequireCombineShapes); | ||
353 | generator.setFlag(Generate::DisableCancelShapes); | ||
354 | generator.generate( | ||
355 | 4, 4, | ||
356 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
357 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
358 | 1}}}); | ||
359 | break; | ||
360 | } | ||
361 | case 42: { | ||
362 | generator.setFlag(Generate::RegularStartEnd); | ||
363 | generator.setFlag(Generate::BigShapes); | ||
364 | generator.setFlag(Generate::DisableCancelShapes); | ||
365 | generator.generate( | ||
366 | 4, 4, | ||
367 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
368 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
369 | 1}}}); | ||
370 | break; | ||
371 | } | ||
372 | case 43: { | ||
373 | generator.setFlag(Generate::RegularStartEnd); | ||
374 | generator.setFlag(Generate::RequireCancelShapes); | ||
375 | generator.generate( | ||
376 | 4, 4, | ||
377 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
378 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
379 | 2}}}); | ||
380 | break; | ||
381 | } | ||
382 | case 44: { | ||
383 | generator.setFlag(Generate::RegularStartEnd); | ||
384 | generator.generate( | ||
385 | 4, 4, {{{Decoration::Triangle | Decoration::Color::Orange, 6}}}); | ||
386 | break; | ||
387 | } | ||
388 | case 45: { | ||
389 | generator.setFlag(Generate::TreehouseLayout); | ||
390 | generator.setFlag(Generate::LongPath); | ||
391 | generator.generate(5, 4, | ||
392 | {{{Decoration::Star | Decoration::Color::Magenta, 6}, | ||
393 | {Decoration::Stone | Decoration::Color::Orange, 4}, | ||
394 | {Decoration::Stone | Decoration::Color::Green, 4}}}); | ||
395 | generator.place_gaps(8); | ||
396 | break; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | Rice::String str(generator.AsCode()); | ||
401 | return str; | ||
402 | } | ||
403 | |||
404 | Rice::Object wittle_generator_generate_medium(Rice::Object /* self */) { | ||
405 | Generate generator; | ||
406 | |||
407 | int choice = Random::rand() % 30; | ||
408 | std::cout << "Generate MEDIUM: choice " << std::dec << choice << std::endl; | ||
409 | |||
410 | switch (choice) { | ||
411 | case 0: { | ||
412 | generator.setSymbol(Decoration::Start, 2 * 2, 2 * 2); | ||
413 | generator.setSymbol(Decoration::Exit, 4 * 2, 0); | ||
414 | generator.generate( | ||
415 | 4, 4, | ||
416 | {{{Decoration::Stone | Decoration::Color::White, 5}, | ||
417 | {Decoration::Stone | Decoration::Color::Black, 5}, | ||
418 | {Decoration::Dot, 4}, | ||
419 | {Decoration::Eraser | Decoration::Color::Green, 1}}}); | ||
420 | break; | ||
421 | } | ||
422 | case 1: { | ||
423 | generator.setSymbol(Decoration::Exit, 0, 0); | ||
424 | generator.setSymbol(Decoration::Exit, 7 * 2, 0); | ||
425 | generator.setSymbol(Decoration::Exit, 7 * 2, 7 * 2); | ||
426 | generator.generate(7, 7, | ||
427 | {{{Decoration::Stone | Decoration::Color::White, 10}, | ||
428 | {Decoration::Stone | Decoration::Color::Black, 10}, | ||
429 | {Decoration::Dot, 10}, | ||
430 | {Decoration::Start, 4}}}); | ||
431 | break; | ||
432 | } | ||
433 | case 2: { | ||
434 | generator.setSymbol(Decoration::Exit, 0, 0); | ||
435 | generator.setSymbol(Decoration::Exit, 7 * 2, 0); | ||
436 | generator.setSymbol(Decoration::Exit, 7 * 2, 7 * 2); | ||
437 | generator.generate(7, 7, | ||
438 | {{{Decoration::Stone | Decoration::Color::White, 10}, | ||
439 | {Decoration::Stone | Decoration::Color::Black, 10}, | ||
440 | {Decoration::Dot, 10}, | ||
441 | {Decoration::Eraser | Decoration::Color::Purple, 1}, | ||
442 | {Decoration::Start, 3}}}); | ||
443 | break; | ||
444 | } | ||
445 | case 3: { | ||
446 | generator.setFlag(Generate::RegularStartEnd); | ||
447 | generator.generate(5, 5, | ||
448 | {{{Decoration::Star | Decoration::White, 8}, | ||
449 | {Decoration::Star | Decoration::Black, 6}}}); | ||
450 | break; | ||
451 | } | ||
452 | case 4: { | ||
453 | generator.setFlag(Generate::RegularStartEnd); | ||
454 | generator.setFlag(Generate::DisconnectShapes); | ||
455 | generator.generate( | ||
456 | 4, 4, | ||
457 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
458 | {Decoration::Eraser | Decoration::Color::White, 1}}}); | ||
459 | break; | ||
460 | } | ||
461 | case 5: { | ||
462 | generator.setSymbol(Decoration::Start, 2 * 2, 2 * 2); | ||
463 | generator.setSymbol(Decoration::Exit, 4 * 2, 0); | ||
464 | generator.generate(4, 4, | ||
465 | {{{Decoration::Dot_Intersection, 25}, | ||
466 | {Decoration::Stone | Decoration::Color::Black, 2}, | ||
467 | {Decoration::Stone | Decoration::Color::White, 2}}}); | ||
468 | break; | ||
469 | } | ||
470 | case 6: { | ||
471 | generator.setSymmetry(Panel::Rotational); | ||
472 | generator.generate(5, 5, | ||
473 | {{{Decoration::Dot | Decoration::Color::Blue, 2}, | ||
474 | {Decoration::Dot | Decoration::Color::Yellow, 2}, | ||
475 | {Decoration::Dot, 4}, | ||
476 | {Decoration::Start, 2}, | ||
477 | {Decoration::Exit, 1}}}); | ||
478 | break; | ||
479 | } | ||
480 | case 7: { | ||
481 | generator.setFlag(Generate::RegularStartEnd); | ||
482 | generator.setFlag(Generate::RequireCancelShapes); | ||
483 | generator.generate( | ||
484 | 6, 6, | ||
485 | {{{Decoration::Dot_Intersection, 49}, | ||
486 | {Decoration::Poly | Decoration::Color::Yellow, 1}, | ||
487 | {Decoration::Poly | Decoration::Color::Yellow | | ||
488 | Decoration::Can_Rotate, | ||
489 | 2}, | ||
490 | {Decoration::Poly | Decoration::Color::Blue | Decoration::Negative, | ||
491 | 3}}}); | ||
492 | break; | ||
493 | } | ||
494 | case 8: { | ||
495 | generator.setFlag(Generate::RegularStartEnd); | ||
496 | generator.generate( | ||
497 | 4, 4, | ||
498 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
499 | {Decoration::Eraser | Decoration::Color::White, 1}}}); | ||
500 | break; | ||
501 | } | ||
502 | case 9: { | ||
503 | generator.setSymbol(Decoration::Start, 0, 3 * 2); | ||
504 | generator.setSymbol(Decoration::Exit, 6 * 2, 3 * 2); | ||
505 | generator.generate(6, 3, | ||
506 | {{{Decoration::Star | Decoration::Color::Magenta, 3}, | ||
507 | {Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
508 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
509 | break; | ||
510 | } | ||
511 | case 10: { | ||
512 | generator.setSymbol(Decoration::Start, 0, 3 * 2); | ||
513 | generator.setSymbol(Decoration::Exit, 6 * 2, 3 * 2); | ||
514 | generator.generate(6, 3, | ||
515 | {{{Decoration::Star | Decoration::Color::Magenta, 5}, | ||
516 | {Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
517 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
518 | break; | ||
519 | } | ||
520 | case 11: { | ||
521 | generator.setSymbol(Decoration::Start, 0, 3 * 2); | ||
522 | generator.setSymbol(Decoration::Exit, 6 * 2, 3 * 2); | ||
523 | generator.generate(6, 3, | ||
524 | {{{Decoration::Star | Decoration::Color::Magenta, 6}, | ||
525 | {Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
526 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
527 | break; | ||
528 | } | ||
529 | case 12: { | ||
530 | generator.setSymbol(Decoration::Start, 0, 3 * 2); | ||
531 | generator.setSymbol(Decoration::Exit, 7 * 2, 3 * 2); | ||
532 | generator.generate(7, 3, | ||
533 | {{{Decoration::Star | Decoration::Color::Magenta, 5}, | ||
534 | {Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
535 | {Decoration::Eraser | Decoration::White, 1}}}); | ||
536 | break; | ||
537 | } | ||
538 | case 13: { | ||
539 | generator.setFlag(Generate::TreehouseLayout); | ||
540 | generator.generate(4, 4, | ||
541 | {{{Decoration::Star | Decoration::Color::Orange, 6}, | ||
542 | {Decoration::Star | Decoration::Color::Magenta, 6}, | ||
543 | {Decoration::Star | Decoration::Color::Green, 4}}}); | ||
544 | break; | ||
545 | } | ||
546 | case 14: { | ||
547 | generator.setFlag(Generate::TreehouseLayout); | ||
548 | generator.setFlag(Generate::FullGaps); | ||
549 | generator.generate(5, 5, | ||
550 | {{{Decoration::Star | Decoration::Color::Magenta, 8}, | ||
551 | {Decoration::Dot_Intersection, 9}, | ||
552 | {Decoration::Gap, 5}}}); | ||
553 | break; | ||
554 | } | ||
555 | case 15: { | ||
556 | generator.setFlag(Generate::TreehouseLayout); | ||
557 | generator.generate(4, 4, | ||
558 | {{{Decoration::Star | Decoration::Color::Black, 4}, | ||
559 | {Decoration::Star | Decoration::Color::White, 4}, | ||
560 | {Decoration::Stone | Decoration::Color::Black, 2}, | ||
561 | {Decoration::Stone | Decoration::Color::White, 2}}}); | ||
562 | break; | ||
563 | } | ||
564 | case 16: { | ||
565 | generator.setFlag(Generate::TreehouseLayout); | ||
566 | generator.generate( | ||
567 | 5, 5, | ||
568 | {{{Decoration::Poly | Decoration::Color::Orange, 2}, | ||
569 | {Decoration::Poly | Decoration::Color::Magenta, 1}, | ||
570 | {Decoration::Star | Decoration::Color::Magenta, 3}}}); | ||
571 | break; | ||
572 | } | ||
573 | case 17: { | ||
574 | generator.setFlag(Generate::TreehouseLayout); | ||
575 | generator.setFlag(Generate::RequireCombineShapes); | ||
576 | generator.generate(5, 5, | ||
577 | {{{Decoration::Poly | Decoration::Color::Orange, 1}, | ||
578 | {Decoration::Poly | Decoration::Can_Rotate | | ||
579 | Decoration::Color::Orange, | ||
580 | 1}, | ||
581 | {Decoration::Star | Decoration::Color::Magenta, 4}, | ||
582 | {Decoration::Star | Decoration::Color::Green, 4}}}); | ||
583 | break; | ||
584 | } | ||
585 | case 18: { | ||
586 | generator.setFlag(Generate::RegularStartEnd); | ||
587 | generator.generate(4, 4, | ||
588 | {{{Decoration::Poly | Decoration::Color::Orange, 3}, | ||
589 | {Decoration::Stone | Decoration::Color::White, 2}, | ||
590 | {Decoration::Stone | Decoration::Color::Black, 2}}}); | ||
591 | break; | ||
592 | } | ||
593 | case 19: { | ||
594 | generator.setFlag(Generate::RegularStartEnd); | ||
595 | generator.generate(4, 4, | ||
596 | {{{Decoration::Dot_Intersection, 25}, | ||
597 | {Decoration::Poly | Decoration::Can_Rotate | | ||
598 | Decoration::Color::Yellow, | ||
599 | 2}}}); | ||
600 | break; | ||
601 | } | ||
602 | case 20: { | ||
603 | generator.setFlag(Generate::RegularStartEnd); | ||
604 | generator.setFlag(Generate::SmallShapes); | ||
605 | generator.generate(5, 5, | ||
606 | {{{Decoration::Poly | Decoration::Can_Rotate | | ||
607 | Decoration::Color::Yellow, | ||
608 | 4}, | ||
609 | {Decoration::Star | Decoration::Color::Orange, 6}}}); | ||
610 | break; | ||
611 | } | ||
612 | case 21: { | ||
613 | generator.setFlag(Generate::RegularStartEnd); | ||
614 | generator.generate(5, 5, | ||
615 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
616 | {Decoration::Gap, 5}}}); | ||
617 | break; | ||
618 | } | ||
619 | case 22: { | ||
620 | generator.setFlag(Generate::RegularStartEnd); | ||
621 | generator.generate(5, 5, | ||
622 | {{{Decoration::Poly | Decoration::Color::Yellow, 4}}}); | ||
623 | break; | ||
624 | } | ||
625 | case 23: { | ||
626 | generator.setFlag(Generate::RegularStartEnd); | ||
627 | generator.setFlag(Generate::DisconnectShapes); | ||
628 | generator.generate(4, 4, | ||
629 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}}}); | ||
630 | break; | ||
631 | } | ||
632 | case 24: { | ||
633 | generator.setFlag(Generate::RegularStartEnd); | ||
634 | generator.generate(5, 5, | ||
635 | {{{Decoration::Poly | Decoration::Can_Rotate | | ||
636 | Decoration::Color::Yellow, | ||
637 | 2}, | ||
638 | {Decoration::Poly | Decoration::Color::Yellow, 1}, | ||
639 | {Decoration::Gap, 2}}}); | ||
640 | break; | ||
641 | } | ||
642 | case 25: { | ||
643 | generator.setFlag(Generate::RegularStartEnd); | ||
644 | generator.setFlag(Generate::BigShapes); | ||
645 | generator.generate(5, 5, | ||
646 | {{{Decoration::Poly | Decoration::Can_Rotate | | ||
647 | Decoration::Color::Yellow, | ||
648 | 3}}}); | ||
649 | break; | ||
650 | } | ||
651 | case 26: { | ||
652 | generator.setFlag(Generate::RegularStartEnd); | ||
653 | generator.generate(5, 6, | ||
654 | {{{Decoration::Poly | Decoration::Color::Yellow, 5}}}); | ||
655 | break; | ||
656 | } | ||
657 | case 27: { | ||
658 | generator.setFlag(Generate::RegularStartEnd); | ||
659 | generator.setFlag(Generate::BigShapes); | ||
660 | generator.generate( | ||
661 | 4, 4, | ||
662 | {{{Decoration::Poly | Decoration::Color::Yellow, 2}, | ||
663 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
664 | 2}}}); | ||
665 | break; | ||
666 | } | ||
667 | case 28: { | ||
668 | generator.setFlag(Generate::RegularStartEnd); | ||
669 | generator.generate( | ||
670 | 4, 4, | ||
671 | {{{Decoration::Poly | Decoration::Color::Yellow, 3}, | ||
672 | {Decoration::Poly | Decoration::Negative | Decoration::Color::Blue, | ||
673 | 2}}}); | ||
674 | break; | ||
675 | } | ||
676 | case 29: { | ||
677 | generator.setFlag(Generate::RegularStartEnd); | ||
678 | generator.generate( | ||
679 | 4, 4, {{{Decoration::Triangle | Decoration::Color::Orange, 8}}}); | ||
680 | break; | ||
681 | } | ||
682 | } | ||
19 | 683 | ||
20 | Rice::String str(generator.AsCode()); | 684 | Rice::String str(generator.AsCode()); |
21 | return str; | 685 | return str; |
@@ -24,5 +688,6 @@ Rice::Object wittle_generator_generate(Rice::Object /* self */) { | |||
24 | extern "C" void Init_wittle_generator() { | 688 | extern "C" void Init_wittle_generator() { |
25 | Rice::Class rb_cWittleGenerator = | 689 | Rice::Class rb_cWittleGenerator = |
26 | Rice::define_class("WittleGenerator") | 690 | Rice::define_class("WittleGenerator") |
27 | .define_method("generate", &wittle_generator_generate); | 691 | .define_method("generate_easy", &wittle_generator_generate_easy) |
692 | .define_method("generate_medium", &wittle_generator_generate_medium); | ||
28 | } | 693 | } |