about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Source/PuzzleSerializer.cpp2
-rw-r--r--Source/Randomizer2.cpp42
2 files changed, 32 insertions, 12 deletions
diff --git a/Source/PuzzleSerializer.cpp b/Source/PuzzleSerializer.cpp index e845578..5c91b56 100644 --- a/Source/PuzzleSerializer.cpp +++ b/Source/PuzzleSerializer.cpp
@@ -10,6 +10,8 @@ PuzzleSerializer::PuzzleSerializer(const std::shared_ptr<Memory>& memory) : _mem
10Puzzle PuzzleSerializer::ReadPuzzle(int id) { 10Puzzle PuzzleSerializer::ReadPuzzle(int id) {
11 int width = 2 * _memory->ReadEntityData<int>(id, GRID_SIZE_X, 1)[0] - 1; 11 int width = 2 * _memory->ReadEntityData<int>(id, GRID_SIZE_X, 1)[0] - 1;
12 int height = 2 * _memory->ReadEntityData<int>(id, GRID_SIZE_Y, 1)[0] - 1; 12 int height = 2 * _memory->ReadEntityData<int>(id, GRID_SIZE_Y, 1)[0] - 1;
13 if (width == 0) width = height;
14 if (height == 0) height = width;
13 if (width < 0 || height < 0) return Puzzle(); // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though. 15 if (width < 0 || height < 0) return Puzzle(); // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though.
14 16
15 int numIntersections = _memory->ReadEntityData<int>(id, NUM_DOTS, 1)[0]; 17 int numIntersections = _memory->ReadEntityData<int>(id, NUM_DOTS, 1)[0];
diff --git a/Source/Randomizer2.cpp b/Source/Randomizer2.cpp index c28795a..83427d7 100644 --- a/Source/Randomizer2.cpp +++ b/Source/Randomizer2.cpp
@@ -30,7 +30,7 @@ void Randomizer2::RandomizeTutorial() {
30 _serializer.WritePuzzle(p, 0x293); 30 _serializer.WritePuzzle(p, 0x293);
31 } 31 }
32 32
33 { 33 { // Center left
34 Puzzle p; 34 Puzzle p;
35 p.NewGrid(6, 6); 35 p.NewGrid(6, 6);
36 36
@@ -48,17 +48,8 @@ void Randomizer2::RandomizeTutorial() {
48 p.grid[p.width-1][Random::RandInt(0, p.height-1)].end = Cell::Dir::RIGHT; 48 p.grid[p.width-1][Random::RandInt(0, p.height-1)].end = Cell::Dir::RIGHT;
49 break; 49 break;
50 } 50 }
51 switch (Random::RandInt(1, 3)) { 51 // [4/6/8][4/6/8]
52 case 1: // Horiz (6) [5/7][4/6/8] 52 p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 2)*2 + 4].start = true;
53 p.grid[Random::RandInt(0, 1)*2 + 5][Random::RandInt(0, 2)*2 + 4].start = true;
54 break;
55 case 2: // Verti (6) [4/6/8][5/7]
56 p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 1)*2 + 5].start = true;
57 break;
58 case 3: // Inter (9) [4/6/8][4/6/8]
59 p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 2)*2 + 4].start = true;
60 break;
61 }
62 53
63 for (Pos pos : Randomizer2Core::CutEdges(p, 35, true)) { 54 for (Pos pos : Randomizer2Core::CutEdges(p, 35, true)) {
64 p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; 55 p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
@@ -66,6 +57,33 @@ void Randomizer2::RandomizeTutorial() {
66 57
67 _serializer.WritePuzzle(p, 0x295); 58 _serializer.WritePuzzle(p, 0x295);
68 } 59 }
60
61 { // Far left
62 Puzzle p;
63 p.NewGrid(10, 10);
64
65 p.grid[0][20].start = true;
66 p.grid[20][0].end = Cell::Dir::RIGHT;
67
68 for (Pos pos : Randomizer2Core::CutEdges(p, 96, true)) {
69 p.grid[pos.x][pos.y].gap = Cell::Gap::FULL;
70 }
71 _serializer.WritePuzzle(p, 0x2C2);
72 }
73
74 { // Back left
75 Puzzle p;
76 p.NewGrid(6, 6);
77
78 p.grid[0][12].start = true;
79 p.grid[12][0].end = Cell::Dir::RIGHT;
80 p.grid[12][12].end = Cell::Dir::RIGHT;
81
82 for (Pos pos : Randomizer2Core::CutEdges(p, 27, true)) {
83 p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK;
84 }
85 _serializer.WritePuzzle(p, 0xA3B5);
86 }
69} 87}
70 88
71void Randomizer2::RandomizeKeep() { 89void Randomizer2::RandomizeKeep() {