From 76bcf9faffde81bf34ed5138db7b181694bce635 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Sat, 27 Oct 2018 17:18:43 -0700 Subject: Fix random order not working --- WitnessRandomizer/Panels.h | 62 ++++++------- WitnessRandomizer/WitnessRandomizer.cpp | 155 ++++++++++++++++---------------- WitnessRandomizer/WitnessRandomizer.h | 8 +- 3 files changed, 114 insertions(+), 111 deletions(-) (limited to 'WitnessRandomizer') diff --git a/WitnessRandomizer/Panels.h b/WitnessRandomizer/Panels.h index 747bbc7..9d4e88c 100644 --- a/WitnessRandomizer/Panels.h +++ b/WitnessRandomizer/Panels.h @@ -2,7 +2,7 @@ #include // Some of these (the puzzle ones) are duplicated elsewhere -const std::vector lasers = { +std::vector lasers = { 0x0360D, // Symmetry 0x03615, // Swamp 0x09DE0, // Bunker @@ -18,24 +18,24 @@ const std::vector lasers = { }; // Note: Some of these (non-desert) are duplicated elsewhere -const std::vector burnablePanels = { -// 0x17D9C, // Treehouse Yellow 7 -// 0x17DC2, // Treehouse Yellow 8 -// 0x17DC4, // Treehouse Yellow 9 -// 0x00999, // Swamp Discontinuous 1 -// 0x0099D, // Swamp Discontinuous 2 -// 0x009A0, // Swamp Discontinuous 3 -// 0x009A1, // Swamp Discontinuous 4 -// 0x00007, // Swamp Rotation Tutorial 1 -// 0x00008, // Swamp Rotation Tutorial 2 -// 0x00009, // Swamp Rotation Tutorial 3 -// 0x0000A, // Swamp Rotation Tutorial 4 -// 0x28AC7, // Town Blue 1 -// 0x28AC8, // Town Blue 2 -// 0x28ACA, // Town Blue 3 -// 0x28ACB, // Town Blue 4 -// 0x28ACC, // Town Blue 5 -// 0x17CF0, // Mill Discard +std::vector burnablePanels = { + 0x17D9C, // Treehouse Yellow 7 + 0x17DC2, // Treehouse Yellow 8 + 0x17DC4, // Treehouse Yellow 9 + 0x00999, // Swamp Discontinuous 1 + 0x0099D, // Swamp Discontinuous 2 + 0x009A0, // Swamp Discontinuous 3 + 0x009A1, // Swamp Discontinuous 4 + 0x00007, // Swamp Rotation Tutorial 1 + 0x00008, // Swamp Rotation Tutorial 2 + 0x00009, // Swamp Rotation Tutorial 3 + 0x0000A, // Swamp Rotation Tutorial 4 + 0x28AC7, // Town Blue 1 + 0x28AC8, // Town Blue 2 + 0x28ACA, // Town Blue 3 + 0x28ACB, // Town Blue 4 + 0x28ACC, // Town Blue 5 + 0x17CF0, // Mill Discard 0x00698, // Desert Surface 1 0x0048F, // Desert Surface 2 @@ -63,7 +63,7 @@ const std::vector burnablePanels = { // Note: Some of these (non-controls) are duplicated elsewhere // TODO: Gave up -const std::vector leftRightPanels = { +std::vector leftRightPanels = { 0x01A54, // Glass Factory Entry 0x00086, // Glass Factory Vertical Symmetry 1 0x00087, // Glass Factory Vertical Symmetry 2 @@ -77,7 +77,7 @@ const std::vector leftRightPanels = { }; // Note: Some of these (non-controls) are duplicated elsewhere -const std::vector upDownPanels = { +std::vector upDownPanels = { 0x0008D, // Glass Factory Rotational Symmetry 1 0x00081, // Glass Factory Rotational Symmetry 2 0x00083, // Glass Factory Rotational Symmetry 3 @@ -100,7 +100,7 @@ const std::vector upDownPanels = { }; // Note: Some of these (non-controls) are duplicated elsewhere -const std::vector leftForwardRightPanels = { +std::vector leftForwardRightPanels = { // 0x00075, // Symmetry Island Colored Dots 3 // 0x288EA, // UTM Perspective 1 // 0x288FC, // UTM Perspective 2 @@ -112,7 +112,7 @@ const std::vector leftForwardRightPanels = { 0x17E52, // Treehouse Green 4 }; -const std::vector pillars = { +std::vector pillars = { 0x0383D, // Mountain 3 Left Pillar 1 0x0383F, // Mountain 3 Left Pillar 2 0x03859, // Mountain 3 Left Pillar 3 @@ -126,7 +126,7 @@ const std::vector pillars = { // 0x1C319, // Challenge Right Pillar }; -const std::vector mountainMultipanel = { +std::vector mountainMultipanel = { 0x09FCC, // Mountain 2 Multipanel 1 0x09FCE, // Mountain 2 Multipanel 2 0x09FCF, // Mountain 2 Multipanel 3 @@ -135,7 +135,7 @@ const std::vector mountainMultipanel = { 0x09FD2, // Mountain 2 Multipanel 6 }; -const std::vector squarePanels = { +std::vector squarePanels = { 0x00064, // Tutorial Straight 0x00182, // Tutorial Bend 0x0A3B2, // Tutorial Back Right @@ -449,11 +449,12 @@ const std::vector squarePanels = { 0x00558, // UTM Blue Right Near 2 0x00567, // UTM Blue Right Near 3 0x006FE, // UTM Blue Right Near 4 + 0x0A16E, // UTM Challenge Entrance 0x039B4, // Tunnels Theater Catwalk 0x09E85, // Tunnels Town Shortcut }; -const std::vector shadowsPanels = { +std::vector shadowsPanels = { 0x198B5, // Shadows Tutorial 1 0x198BD, // Shadows Tutorial 2 0x198BF, // Shadows Tutorial 3 @@ -478,7 +479,7 @@ const std::vector shadowsPanels = { 0x19650, // Shadows Laser }; -const std::vector monasteryPanels = { +std::vector monasteryPanels = { 0x00B10, // Monastery Left Door 0x00290, // Monastery Exterior 1 0x00C92, // Monastery Right Door @@ -493,7 +494,7 @@ const std::vector monasteryPanels = { 0x17CA4, // Monastery Laser }; -const std::vector bunkerPanels = { +std::vector bunkerPanels = { 0x09F7D, // Bunker Tutorial 1 0x09FDC, // Bunker Tutorial 2 0x09FF7, // Bunker Tutorial 3 @@ -514,7 +515,7 @@ const std::vector bunkerPanels = { 0x0A079, // Bunker Elevator }; -const std::vector junglePanels = { +std::vector junglePanels = { 0x002C4, // Jungle Waves 1 0x00767, // Jungle Waves 2 0x002C6, // Jungle Waves 3 @@ -533,7 +534,7 @@ const std::vector junglePanels = { }; // There might be something to do with these, I haven't decided yet. -const std::vector nothingPanels = { +std::vector nothingPanels = { // Doors & Shortcuts & Shortcut doors & Door controls 0x0C339, // Desert Surface Door 0x0A249, // Desert Pond Exit Door @@ -664,7 +665,6 @@ const std::vector nothingPanels = { // 0x3C114, // Mountain 3 Right Open Door 0x09F7F, // Mountaintop Laser Box 0x17C34, // Mountaintop Perspective - 0x0A16E, // UTM Challenge Entrance // 0x334E1, // UTM Secret Door Control // 0x2773D, // Tunnels Desert Shortcut // 0x27732, // Tunnels Theater Shortcut diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp index 6ce0256..0135cc9 100644 --- a/WitnessRandomizer/WitnessRandomizer.cpp +++ b/WitnessRandomizer/WitnessRandomizer.cpp @@ -13,6 +13,8 @@ ** Think about: Jungle ** Hard: Monastery ** Do: Challenge + * Block swamp snipe w/ distance gate + * Turn off shadows 8 * Randomize audio logs * Swap sounds in jungle (along with panels) -- maybe impossible * Make orange 7 (all of oranges?) hard. Like big = hard. @@ -44,88 +46,89 @@ int main(int argc, char** argv) if (argc == 2) { srand(atoi(argv[1])); // Seed from the command line } else { - int seed = time(nullptr) % (1 << 16); // Seed from the time in milliseconds + srand(static_cast(time(nullptr))); + int seed = rand() % (1 << 16); // Seed from the time in milliseconds std::cout << "Selected seed: " << seed << std::endl; srand(seed); } -// randomizer.SwapPanels(0x28AC7, 0x00698, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 1 -// randomizer.SwapPanels(0x28AC8, 0x0048F, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 2 -// randomizer.SwapPanels(0x28ACA, 0x09F92, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 3 -// randomizer.SwapPanels(0x28ACB, 0x0A036, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 4 -// randomizer.SwapPanels(0x28ACC, 0x09DA6, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 5 -// 0x00079; // Symmetry Island Colored Dots 6 -// -// 0x0005D; // Outside Tutorial Dots Tutorial 1 -// 0x0005E; // Outside Tutorial Dots Tutorial 2 -// 0x0005F; // Outside Tutorial Dots Tutorial 3 -// 0x00060; // Outside Tutorial Dots Tutorial 4 -// 0x00061; // Outside Tutorial Dots Tutorial 5 - - - - // Content swaps -- must happen before squarePanels - randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE); - randomizer.Randomize(leftForwardRightPanels, SWAP_LINES); - - randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE); - - // Frame swaps -- must happen after squarePanels - randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE); - - // Target swaps, can happen whenever - randomizer.Randomize(lasers, SWAP_TARGETS); - // Read the target of keep front laser, and write it to keep back laser. - std::vector keepFrontLaserTarget = randomizer.ReadPanelData(0x0360E, TARGET, 1); - randomizer.WritePanelData(0x03317, TARGET, keepFrontLaserTarget); - - std::vector randomOrder; - - /* Jungle - randomOrder = std::vector(junglePanels.size(), 0); - std::iota(randomOrder.begin(), randomOrder.end(), 0); - // Randomize Waves 2-7 - // Waves 1 cannot be randomized, since no other panel can start on - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); - // Randomize Pitches 1-6 onto themselves - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13); - randomizer.ReassignTargets(junglePanels, randomOrder); - */ + randomizer.SwapPanels(0x28AC7, 0x00698, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 1 + randomizer.SwapPanels(0x28AC8, 0x0048F, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 2 + randomizer.SwapPanels(0x28ACA, 0x09F92, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 3 + randomizer.SwapPanels(0x28ACB, 0x0A036, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 4 + randomizer.SwapPanels(0x28ACC, 0x09DA6, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 5 + 0x00079; // Symmetry Island Colored Dots 6 - /* Bunker */ - randomOrder = std::vector(bunkerPanels.size(), 0); - std::iota(randomOrder.begin(), randomOrder.end(), 0); - // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 - // Tutorial 1 cannot be randomized, since no other panel can start on - // Glass 1 will become door + glass 1, due to the targetting system - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10); - // Randomize Glass 1-3 into everything after the door - const size_t glassDoorIndex = find(randomOrder, 9) + 1; - randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12); - randomizer.ReassignTargets(bunkerPanels, randomOrder); + 0x0005D; // Outside Tutorial Dots Tutorial 1 + 0x0005E; // Outside Tutorial Dots Tutorial 2 + 0x0005F; // Outside Tutorial Dots Tutorial 3 + 0x00060; // Outside Tutorial Dots Tutorial 4 + 0x00061; // Outside Tutorial Dots Tutorial 5 - /* Shadows */ - randomOrder = std::vector(shadowsPanels.size(), 0); - std::iota(randomOrder.begin(), randomOrder.end(), 0); - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow - randomizer.ReassignTargets(shadowsPanels, randomOrder); - // Turn off original starting panel - randomizer.WritePanelData(shadowsPanels[0], POWER, {0.0f, 0.0f}); - // Turn on new starting panel - randomizer.WritePanelData(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); - /* Monastery - randomOrder = std::vector(monasteryPanels.size(), 0); - std::iota(randomOrder.begin(), randomOrder.end(), 0); - randomizer.RandomizeRange(randomOrder, SWAP_NONE, 2, 6); // outer 2 & 3, inner 1 - // Once outer 3 and right door are solved, inner 2-4 are accessible - int innerPanelsIndex = max(find(randomOrder, 2), find(randomOrder, 4)); - randomizer.RandomizeRange(randomOrder, SWAP_NONE, innerPanelsIndex, 9); // Inner 2-4 - randomizer.ReassignTargets(monasteryPanels, randomOrder); - */ +// // Content swaps -- must happen before squarePanels +// randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE); +// randomizer.Randomize(leftForwardRightPanels, SWAP_LINES); +// +// randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE); +// +// // Frame swaps -- must happen after squarePanels +// randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE); +// +// // Target swaps, can happen whenever +// randomizer.Randomize(lasers, SWAP_TARGETS); +// // Read the target of keep front laser, and write it to keep back laser. +// std::vector keepFrontLaserTarget = randomizer.ReadPanelData(0x0360E, TARGET, 1); +// randomizer.WritePanelData(0x03317, TARGET, keepFrontLaserTarget); +// +// std::vector randomOrder; +// +// /* Jungle +// randomOrder = std::vector(junglePanels.size(), 0); +// std::iota(randomOrder.begin(), randomOrder.end(), 0); +// // Randomize Waves 2-7 +// // Waves 1 cannot be randomized, since no other panel can start on +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); +// // Randomize Pitches 1-6 onto themselves +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13); +// randomizer.ReassignTargets(junglePanels, randomOrder); +// */ +// +// /* Bunker */ +// randomOrder = std::vector(bunkerPanels.size(), 0); +// std::iota(randomOrder.begin(), randomOrder.end(), 0); +// // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 +// // Tutorial 1 cannot be randomized, since no other panel can start on +// // Glass 1 will become door + glass 1, due to the targetting system +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10); +// // Randomize Glass 1-3 into everything after the door +// const size_t glassDoorIndex = find(randomOrder, 9) + 1; +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12); +// randomizer.ReassignTargets(bunkerPanels, randomOrder); +// +// /* Shadows */ +// randomOrder = std::vector(shadowsPanels.size(), 0); +// std::iota(randomOrder.begin(), randomOrder.end(), 0); +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow +// randomizer.ReassignTargets(shadowsPanels, randomOrder); +// // Turn off original starting panel +// randomizer.WritePanelData(shadowsPanels[0], POWER, {0.0f, 0.0f}); +// // Turn on new starting panel +// randomizer.WritePanelData(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); +// +// /* Monastery +// randomOrder = std::vector(monasteryPanels.size(), 0); +// std::iota(randomOrder.begin(), randomOrder.end(), 0); +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 2, 6); // outer 2 & 3, inner 1 +// // Once outer 3 and right door are solved, inner 2-4 are accessible +// int innerPanelsIndex = max(find(randomOrder, 2), find(randomOrder, 4)); +// randomizer.RandomizeRange(randomOrder, SWAP_NONE, innerPanelsIndex, 9); // Inner 2-4 +// +// randomizer.ReassignTargets(monasteryPanels, randomOrder); +// */ } WitnessRandomizer::WitnessRandomizer() @@ -149,12 +152,12 @@ WitnessRandomizer::WitnessRandomizer() WritePanelData(0x002C2, CURSOR_SPEED_SCALE, {1.0}); } -void WitnessRandomizer::Randomize(const std::vector& panels, int flags) { +void WitnessRandomizer::Randomize(std::vector& panels, int flags) { return RandomizeRange(panels, flags, 0, panels.size()); } // Range is [start, end) -void WitnessRandomizer::RandomizeRange(std::vector panels, int flags, size_t startIndex, size_t endIndex) { +void WitnessRandomizer::RandomizeRange(std::vector &panels, int flags, size_t startIndex, size_t endIndex) { if (panels.size() == 0) return; if (startIndex >= endIndex) return; if (endIndex >= panels.size()) endIndex = panels.size(); diff --git a/WitnessRandomizer/WitnessRandomizer.h b/WitnessRandomizer/WitnessRandomizer.h index 0c73b89..bb9db44 100644 --- a/WitnessRandomizer/WitnessRandomizer.h +++ b/WitnessRandomizer/WitnessRandomizer.h @@ -1,7 +1,7 @@ #pragma once -//#define GLOBALS 0x5B28C0 -#define GLOBALS 0x62A080 +#define GLOBALS 0x5B28C0 +// #define GLOBALS 0x62A080 int SWAP_NONE = 0x0; int SWAP_TARGETS = 0x1; @@ -12,8 +12,8 @@ class WitnessRandomizer { public: WitnessRandomizer(); - void Randomize(const std::vector& panels, int flags); - void RandomizeRange(std::vector panels, int flags, size_t startIndex, size_t endIndex); + void Randomize(std::vector& panels, int flags); + void RandomizeRange(std::vector &panels, int flags, size_t startIndex, size_t endIndex); void SwapPanels(int panel1, int panel2, int flags); void ReassignTargets(const std::vector& panels, const std::vector& order); -- cgit 1.4.1