From 7a13ef0a94f6ed4989677530b1b37e1af0692fc7 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 18 Nov 2019 10:03:00 -0800 Subject: Done with most of tutorial --- Source/PuzzleSerializer.cpp | 2 ++ Source/Randomizer2.cpp | 42 ++++++++++++++++++++++++++++++------------ 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) : _mem Puzzle PuzzleSerializer::ReadPuzzle(int id) { int width = 2 * _memory->ReadEntityData(id, GRID_SIZE_X, 1)[0] - 1; int height = 2 * _memory->ReadEntityData(id, GRID_SIZE_Y, 1)[0] - 1; + if (width == 0) width = height; + if (height == 0) height = width; if (width < 0 || height < 0) return Puzzle(); // @Error: Grid size should be always positive? Looks like the starting panels break this rule, though. int numIntersections = _memory->ReadEntityData(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() { _serializer.WritePuzzle(p, 0x293); } - { + { // Center left Puzzle p; p.NewGrid(6, 6); @@ -48,17 +48,8 @@ void Randomizer2::RandomizeTutorial() { p.grid[p.width-1][Random::RandInt(0, p.height-1)].end = Cell::Dir::RIGHT; break; } - switch (Random::RandInt(1, 3)) { - case 1: // Horiz (6) [5/7][4/6/8] - p.grid[Random::RandInt(0, 1)*2 + 5][Random::RandInt(0, 2)*2 + 4].start = true; - break; - case 2: // Verti (6) [4/6/8][5/7] - p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 1)*2 + 5].start = true; - break; - case 3: // Inter (9) [4/6/8][4/6/8] - p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 2)*2 + 4].start = true; - break; - } + // [4/6/8][4/6/8] + p.grid[Random::RandInt(0, 2)*2 + 4][Random::RandInt(0, 2)*2 + 4].start = true; for (Pos pos : Randomizer2Core::CutEdges(p, 35, true)) { p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; @@ -66,6 +57,33 @@ void Randomizer2::RandomizeTutorial() { _serializer.WritePuzzle(p, 0x295); } + + { // Far left + Puzzle p; + p.NewGrid(10, 10); + + p.grid[0][20].start = true; + p.grid[20][0].end = Cell::Dir::RIGHT; + + for (Pos pos : Randomizer2Core::CutEdges(p, 96, true)) { + p.grid[pos.x][pos.y].gap = Cell::Gap::FULL; + } + _serializer.WritePuzzle(p, 0x2C2); + } + + { // Back left + Puzzle p; + p.NewGrid(6, 6); + + p.grid[0][12].start = true; + p.grid[12][0].end = Cell::Dir::RIGHT; + p.grid[12][12].end = Cell::Dir::RIGHT; + + for (Pos pos : Randomizer2Core::CutEdges(p, 27, true)) { + p.grid[pos.x][pos.y].gap = Cell::Gap::BREAK; + } + _serializer.WritePuzzle(p, 0xA3B5); + } } void Randomizer2::RandomizeKeep() { -- cgit 1.4.1