about summary refs log tree commit diff stats
path: root/Source/Puzzle.h
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2019-11-09 14:23:42 -0800
committerjbzdarkid <jbzdarkid@gmail.com>2019-11-09 14:23:42 -0800
commit98db209c9008492baec6bb482b047d386fbdd42b (patch)
tree9f4a932ed1ff2367a98fe02908fee4c884a2d4ed /Source/Puzzle.h
parent36be1ed32ac9a554f0b11fcc13b5699e717b81f2 (diff)
downloadwitness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.tar.gz
witness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.tar.bz2
witness-tutorializer-98db209c9008492baec6bb482b047d386fbdd42b.zip
One down, 522 to go.
Diffstat (limited to 'Source/Puzzle.h')
-rw-r--r--Source/Puzzle.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/Puzzle.h b/Source/Puzzle.h index 7a98a78..94cb4b0 100644 --- a/Source/Puzzle.h +++ b/Source/Puzzle.h
@@ -37,7 +37,6 @@ struct Decoration {
37 int count = 0; 37 int count = 0;
38}; 38};
39 39
40
41struct Cell { 40struct Cell {
42 inline static Cell Undefined() { 41 inline static Cell Undefined() {
43 Cell c; 42 Cell c;
@@ -63,7 +62,9 @@ struct Cell {
63struct Negation {}; 62struct Negation {};
64struct Pos {int x; int y;}; 63struct Pos {int x; int y;};
65 64
66struct Puzzle { 65#include <cassert> // TODO: Move this + impl to cpp
66class Puzzle {
67public:
67 int16_t height; 68 int16_t height;
68 int16_t width; 69 int16_t width;
69 bool hasDecorations = false; 70 bool hasDecorations = false;
@@ -72,6 +73,10 @@ struct Puzzle {
72 Symmetry sym = Symmetry::NONE; 73 Symmetry sym = Symmetry::NONE;
73 bool pillar = false; 74 bool pillar = false;
74 75
76 bool valid;
77 std::vector<Negation> negations;
78 std::vector<Pos> invalidElements;
79
75 inline Cell GetCell(int x, int y) const { 80 inline Cell GetCell(int x, int y) const {
76 x = Mod(x); 81 x = Mod(x);
77 if (!SafeCell(x, y)) return Cell::Undefined(); 82 if (!SafeCell(x, y)) return Cell::Undefined();
@@ -80,13 +85,24 @@ struct Puzzle {
80 inline Cell::Color GetLine(int x, int y) const { 85 inline Cell::Color GetLine(int x, int y) const {
81 return grid[x][y].color; 86 return grid[x][y].color;
82 } 87 }
88 inline void NewGrid(int newWidth, int newHeight) {
89 if (newWidth == 0) {
90 assert(false);
91 newWidth = width;
92 newHeight = height;
93 } else {
94 // @Cleanup! This should be in the ctor...
95 width = 2*newWidth + 1;
96 height = 2*newHeight + 1;
97 }
98 grid.clear();
99 grid.resize(width);
100 for (int x=0; x<width; x++) grid[x].resize(height);
101 }
102
83 // @TODO: 103 // @TODO:
84 Pos GetSymmetricalPos(int x, int y); 104 Pos GetSymmetricalPos(int x, int y);
85 105
86 bool valid;
87 std::vector<Negation> negations;
88 std::vector<Pos> invalidElements;
89
90// private: 106// private:
91 std::vector<std::vector<Cell>> grid; 107 std::vector<std::vector<Cell>> grid;
92 108