about summary refs log tree commit diff stats
path: root/WitnessRandomizer/WitnessRandomizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WitnessRandomizer/WitnessRandomizer.cpp')
-rw-r--r--WitnessRandomizer/WitnessRandomizer.cpp155
1 files changed, 79 insertions, 76 deletions
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 @@
13 ** Think about: Jungle 13 ** Think about: Jungle
14 ** Hard: Monastery 14 ** Hard: Monastery
15 ** Do: Challenge 15 ** Do: Challenge
16 * Block swamp snipe w/ distance gate
17 * Turn off shadows 8
16 * Randomize audio logs 18 * Randomize audio logs
17 * Swap sounds in jungle (along with panels) -- maybe impossible 19 * Swap sounds in jungle (along with panels) -- maybe impossible
18 * Make orange 7 (all of oranges?) hard. Like big = hard. 20 * Make orange 7 (all of oranges?) hard. Like big = hard.
@@ -44,88 +46,89 @@ int main(int argc, char** argv)
44 if (argc == 2) { 46 if (argc == 2) {
45 srand(atoi(argv[1])); // Seed from the command line 47 srand(atoi(argv[1])); // Seed from the command line
46 } else { 48 } else {
47 int seed = time(nullptr) % (1 << 16); // Seed from the time in milliseconds 49 srand(static_cast<unsigned int>(time(nullptr)));
50 int seed = rand() % (1 << 16); // Seed from the time in milliseconds
48 std::cout << "Selected seed: " << seed << std::endl; 51 std::cout << "Selected seed: " << seed << std::endl;
49 srand(seed); 52 srand(seed);
50 } 53 }
51 54
52// randomizer.SwapPanels(0x28AC7, 0x00698, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 1 55 randomizer.SwapPanels(0x28AC7, 0x00698, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 1
53// randomizer.SwapPanels(0x28AC8, 0x0048F, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 2 56 randomizer.SwapPanels(0x28AC8, 0x0048F, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 2
54// randomizer.SwapPanels(0x28ACA, 0x09F92, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 3 57 randomizer.SwapPanels(0x28ACA, 0x09F92, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 3
55// randomizer.SwapPanels(0x28ACB, 0x0A036, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 4 58 randomizer.SwapPanels(0x28ACB, 0x0A036, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 4
56// randomizer.SwapPanels(0x28ACC, 0x09DA6, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 5 59 randomizer.SwapPanels(0x28ACC, 0x09DA6, SWAP_LINES | SWAP_STYLE); // Symmetry Island Colored Dots 5
57// 0x00079; // Symmetry Island Colored Dots 6 60 0x00079; // Symmetry Island Colored Dots 6
58//
59// 0x0005D; // Outside Tutorial Dots Tutorial 1
60// 0x0005E; // Outside Tutorial Dots Tutorial 2
61// 0x0005F; // Outside Tutorial Dots Tutorial 3
62// 0x00060; // Outside Tutorial Dots Tutorial 4
63// 0x00061; // Outside Tutorial Dots Tutorial 5
64
65
66
67 // Content swaps -- must happen before squarePanels
68 randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE);
69 randomizer.Randomize(leftForwardRightPanels, SWAP_LINES);
70
71 randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE);
72
73 // Frame swaps -- must happen after squarePanels
74 randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE);
75
76 // Target swaps, can happen whenever
77 randomizer.Randomize(lasers, SWAP_TARGETS);
78 // Read the target of keep front laser, and write it to keep back laser.
79 std::vector<int> keepFrontLaserTarget = randomizer.ReadPanelData<int>(0x0360E, TARGET, 1);
80 randomizer.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
81
82 std::vector<int> randomOrder;
83
84 /* Jungle
85 randomOrder = std::vector(junglePanels.size(), 0);
86 std::iota(randomOrder.begin(), randomOrder.end(), 0);
87 // Randomize Waves 2-7
88 // Waves 1 cannot be randomized, since no other panel can start on
89 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 7);
90 // Randomize Pitches 1-6 onto themselves
91 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13);
92 randomizer.ReassignTargets(junglePanels, randomOrder);
93 */
94 61
95 /* Bunker */ 62 0x0005D; // Outside Tutorial Dots Tutorial 1
96 randomOrder = std::vector(bunkerPanels.size(), 0); 63 0x0005E; // Outside Tutorial Dots Tutorial 2
97 std::iota(randomOrder.begin(), randomOrder.end(), 0); 64 0x0005F; // Outside Tutorial Dots Tutorial 3
98 // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 65 0x00060; // Outside Tutorial Dots Tutorial 4
99 // Tutorial 1 cannot be randomized, since no other panel can start on 66 0x00061; // Outside Tutorial Dots Tutorial 5
100 // Glass 1 will become door + glass 1, due to the targetting system
101 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10);
102 // Randomize Glass 1-3 into everything after the door
103 const size_t glassDoorIndex = find(randomOrder, 9) + 1;
104 randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12);
105 randomizer.ReassignTargets(bunkerPanels, randomOrder);
106 67
107 /* Shadows */
108 randomOrder = std::vector(shadowsPanels.size(), 0);
109 std::iota(randomOrder.begin(), randomOrder.end(), 0);
110 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial
111 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid
112 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow
113 randomizer.ReassignTargets(shadowsPanels, randomOrder);
114 // Turn off original starting panel
115 randomizer.WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f});
116 // Turn on new starting panel
117 randomizer.WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});
118 68
119 /* Monastery
120 randomOrder = std::vector(monasteryPanels.size(), 0);
121 std::iota(randomOrder.begin(), randomOrder.end(), 0);
122 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 2, 6); // outer 2 & 3, inner 1
123 // Once outer 3 and right door are solved, inner 2-4 are accessible
124 int innerPanelsIndex = max(find(randomOrder, 2), find(randomOrder, 4));
125 randomizer.RandomizeRange(randomOrder, SWAP_NONE, innerPanelsIndex, 9); // Inner 2-4
126 69
127 randomizer.ReassignTargets(monasteryPanels, randomOrder); 70// // Content swaps -- must happen before squarePanels
128 */ 71// randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE);
72// randomizer.Randomize(leftForwardRightPanels, SWAP_LINES);
73//
74// randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE);
75//
76// // Frame swaps -- must happen after squarePanels
77// randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE);
78//
79// // Target swaps, can happen whenever
80// randomizer.Randomize(lasers, SWAP_TARGETS);
81// // Read the target of keep front laser, and write it to keep back laser.
82// std::vector<int> keepFrontLaserTarget = randomizer.ReadPanelData<int>(0x0360E, TARGET, 1);
83// randomizer.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
84//
85// std::vector<int> randomOrder;
86//
87// /* Jungle
88// randomOrder = std::vector(junglePanels.size(), 0);
89// std::iota(randomOrder.begin(), randomOrder.end(), 0);
90// // Randomize Waves 2-7
91// // Waves 1 cannot be randomized, since no other panel can start on
92// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 7);
93// // Randomize Pitches 1-6 onto themselves
94// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13);
95// randomizer.ReassignTargets(junglePanels, randomOrder);
96// */
97//
98// /* Bunker */
99// randomOrder = std::vector(bunkerPanels.size(), 0);
100// std::iota(randomOrder.begin(), randomOrder.end(), 0);
101// // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1
102// // Tutorial 1 cannot be randomized, since no other panel can start on
103// // Glass 1 will become door + glass 1, due to the targetting system
104// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10);
105// // Randomize Glass 1-3 into everything after the door
106// const size_t glassDoorIndex = find(randomOrder, 9) + 1;
107// randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12);
108// randomizer.ReassignTargets(bunkerPanels, randomOrder);
109//
110// /* Shadows */
111// randomOrder = std::vector(shadowsPanels.size(), 0);
112// std::iota(randomOrder.begin(), randomOrder.end(), 0);
113// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial
114// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid
115// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow
116// randomizer.ReassignTargets(shadowsPanels, randomOrder);
117// // Turn off original starting panel
118// randomizer.WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f});
119// // Turn on new starting panel
120// randomizer.WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});
121//
122// /* Monastery
123// randomOrder = std::vector(monasteryPanels.size(), 0);
124// std::iota(randomOrder.begin(), randomOrder.end(), 0);
125// randomizer.RandomizeRange(randomOrder, SWAP_NONE, 2, 6); // outer 2 & 3, inner 1
126// // Once outer 3 and right door are solved, inner 2-4 are accessible
127// int innerPanelsIndex = max(find(randomOrder, 2), find(randomOrder, 4));
128// randomizer.RandomizeRange(randomOrder, SWAP_NONE, innerPanelsIndex, 9); // Inner 2-4
129//
130// randomizer.ReassignTargets(monasteryPanels, randomOrder);
131// */
129} 132}
130 133
131WitnessRandomizer::WitnessRandomizer() 134WitnessRandomizer::WitnessRandomizer()
@@ -149,12 +152,12 @@ WitnessRandomizer::WitnessRandomizer()
149 WritePanelData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0}); 152 WritePanelData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0});
150} 153}
151 154
152void WitnessRandomizer::Randomize(const std::vector<int>& panels, int flags) { 155void WitnessRandomizer::Randomize(std::vector<int>& panels, int flags) {
153 return RandomizeRange(panels, flags, 0, panels.size()); 156 return RandomizeRange(panels, flags, 0, panels.size());
154} 157}
155 158
156// Range is [start, end) 159// Range is [start, end)
157void WitnessRandomizer::RandomizeRange(std::vector<int> panels, int flags, size_t startIndex, size_t endIndex) { 160void WitnessRandomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex) {
158 if (panels.size() == 0) return; 161 if (panels.size() == 0) return;
159 if (startIndex >= endIndex) return; 162 if (startIndex >= endIndex) return;
160 if (endIndex >= panels.size()) endIndex = panels.size(); 163 if (endIndex >= panels.size()) endIndex = panels.size();