about summary refs log tree commit diff stats
path: root/Source/Panel.h
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-09 13:39:10 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-09 13:39:10 -0800
commit36be1ed32ac9a554f0b11fcc13b5699e717b81f2 (patch)
tree383618d781bc5b4701b31555f90b8a629fe6d205 /Source/Panel.h
parent413e1f0aaae961660781675158e38520126c11b6 (diff)
downloadwitness-tutorializer-36be1ed32ac9a554f0b11fcc13b5699e717b81f2.tar.gz
witness-tutorializer-36be1ed32ac9a554f0b11fcc13b5699e717b81f2.tar.bz2
witness-tutorializer-36be1ed32ac9a554f0b11fcc13b5699e717b81f2.zip
Functioning solver/validator (at least for mazes)
Diffstat (limited to 'Source/Panel.h')
-rw-r--r--Source/Panel.h96
1 files changed, 0 insertions, 96 deletions
diff --git a/Source/Panel.h b/Source/Panel.h deleted file mode 100644 index 0ee94f8..0000000 --- a/Source/Panel.h +++ /dev/null
@@ -1,96 +0,0 @@
1#pragma once
2#include <memory>
3#include <vector>
4
5class Memory;
6
7enum Shape {
8 Stone = 0x100,
9 Star = 0x200,
10 Poly = 0x400,
11 Eraser = 0x500,
12 Triangle = 0x600,
13 RPoly = 0x1000,
14 Ylop = 0x2000,
15};
16
17enum Color {
18 Black = 0x1,
19 White = 0x2,
20 Gray = 0x3,
21 Purple = 0x4,
22 Green = 0x5,
23 Cyan = 0x6,
24 Pink = 0x7,
25 Yellow = 0x8,
26 Blue = 0x9,
27 Orange = 0xA,
28};
29
30struct Decoration {
31 Shape type;
32 Color color;
33 int polyshape = 0;
34 // For triangles only
35 int count = 0;
36};
37
38struct Cell {
39 bool start = false;
40 enum class Dir {NONE, LEFT, RIGHT, UP, DOWN};
41 Dir end = Dir::NONE;
42 std::shared_ptr<Decoration> decoration = nullptr;
43 enum class Dot {NONE, BLACK, BLUE, YELLOW, INVISIBLE};
44 Dot dot = Dot::NONE;
45 enum class Gap {NONE, BREAK, FULL};
46 Gap gap = Gap::NONE;
47};
48
49struct Puzzle {
50 int16_t height;
51 int16_t width;
52 bool hasDecorations = false;
53 std::vector<std::vector<Cell>> grid;
54
55 enum class Symmetry {NONE, X, Y, XY};
56 Symmetry sym = Symmetry::NONE;
57 bool pillar = false;
58};
59
60class PuzzleSerializer {
61public:
62 PuzzleSerializer(const std::shared_ptr<Memory>& memory);
63 Puzzle ReadPuzzle(int id);
64 void WritePuzzle(const Puzzle& p, int id);
65
66private:
67 // @Bug: Blue and orange are swapped?
68 enum Flags {
69 IS_ENDPOINT = 0x1,
70 IS_STARTPOINT = 0x2,
71 IS_FULL_GAP = 0x8,
72 HAS_DOT = 0x20,
73 DOT_IS_BLUE = 0x100,
74 DOT_IS_ORANGE = 0x200,
75 DOT_IS_INVISIBLE = 0x1000,
76 HAS_NO_CONN = 0x100000,
77 HAS_VERTI_CONN = 0x200000,
78 HAS_HORIZ_CONN = 0x400000,
79 };
80
81 void ReadIntersections(Puzzle& p, int id);
82 void ReadDecorations(Puzzle& p, int id);
83 void WriteIntersections(const Puzzle& p, int id);
84 void WriteDecorations(const Puzzle& p, int id);
85
86 std::tuple<int, int> loc_to_xy(const Puzzle& p, int location) const;
87 int xy_to_loc(const Puzzle& p, int x, int y) const;
88 // Decoration location
89 std::tuple<int, int> dloc_to_xy(const Puzzle& p, int location) const;
90 int xy_to_dloc(const Puzzle& p, int x, int y) const;
91 Cell::Dot FlagsToDot(int flags) const;
92 // Iterate connection lists for another location which is connected to us; return that other location.
93 int FindConnection(int i, const std::vector<int>& connections_a, const std::vector<int>& connections_b) const;
94
95 std::shared_ptr<Memory> _memory;
96};