summary refs log tree commit diff stats
path: root/Source/Randomizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r--Source/Randomizer.cpp50
1 files changed, 19 insertions, 31 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 75b3cf7..b8462e5 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp
@@ -6,7 +6,6 @@
6 This seems to cause crashes when pivots appear elsewhere in the world. 6 This seems to cause crashes when pivots appear elsewhere in the world.
7 * Some panels are impossible casually: (idc, I think) 7 * Some panels are impossible casually: (idc, I think)
8 ** Town Stars, Invisible dots 8 ** Town Stars, Invisible dots
9 * Shadows burn marks are not appearing
10 * Something is wrong with jungle re: softlocks 9 * Something is wrong with jungle re: softlocks
11 * FEATURES: 10 * FEATURES:
12 * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?) 11 * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?)
@@ -37,34 +36,23 @@ size_t find(const std::vector<T> &data, T search, size_t startIndex = 0) {
37 exit(-1); 36 exit(-1);
38} 37}
39 38
40int main(int argc, char** argv) 39void Randomizer::Randomize(int seed)
41{ 40{
42 Randomizer randomizer = Randomizer();
43
44 if (argc == 2) {
45 srand(atoi(argv[1])); // Seed from the command line
46 } else {
47 srand(static_cast<unsigned int>(time(nullptr)));
48 int seed = rand() % (1 << 16); // Seed from the time in milliseconds
49 std::cout << "Selected seed: " << seed << std::endl;
50 srand(seed);
51 }
52
53 // Content swaps -- must happen before squarePanels 41 // Content swaps -- must happen before squarePanels
54 randomizer.Randomize(tallUpDownPanels, SWAP_LINES | SWAP_STYLE); 42 Randomize(tallUpDownPanels, SWAP_LINES | SWAP_STYLE);
55 randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE); 43 Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE);
56 randomizer.Randomize(leftForwardRightPanels, SWAP_LINES); 44 Randomize(leftForwardRightPanels, SWAP_LINES);
57 45
58 randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE); 46 Randomize(squarePanels, SWAP_LINES | SWAP_STYLE);
59 47
60 // Frame swaps -- must happen after squarePanels 48 // Frame swaps -- must happen after squarePanels
61 randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE); 49 Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE);
62 50
63 // Target swaps, can happen whenever 51 // Target swaps, can happen whenever
64 randomizer.Randomize(lasers, SWAP_TARGETS); 52 Randomize(lasers, SWAP_TARGETS);
65 // Read the target of keep front laser, and write it to keep back laser. 53 // Read the target of keep front laser, and write it to keep back laser.
66 std::vector<int> keepFrontLaserTarget = randomizer.ReadPanelData<int>(0x0360E, TARGET, 1); 54 std::vector<int> keepFrontLaserTarget = ReadPanelData<int>(0x0360E, TARGET, 1);
67 randomizer.WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget); 55 WritePanelData<int>(0x03317, TARGET, keepFrontLaserTarget);
68 56
69 std::vector<int> randomOrder; 57 std::vector<int> randomOrder;
70 58
@@ -77,7 +65,7 @@ int main(int argc, char** argv)
77 // Randomize Pitches 1-6 onto themselves 65 // Randomize Pitches 1-6 onto themselves
78 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13); 66 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13);
79 randomizer.ReassignTargets(junglePanels, randomOrder); 67 randomizer.ReassignTargets(junglePanels, randomOrder);
80 */ 68 */
81 69
82 /* Bunker */ 70 /* Bunker */
83 randomOrder = std::vector(bunkerPanels.size(), 0); 71 randomOrder = std::vector(bunkerPanels.size(), 0);
@@ -85,23 +73,23 @@ int main(int argc, char** argv)
85 // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 73 // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1
86 // Tutorial 1 cannot be randomized, since no other panel can start on 74 // Tutorial 1 cannot be randomized, since no other panel can start on
87 // Glass 1 will become door + glass 1, due to the targetting system 75 // Glass 1 will become door + glass 1, due to the targetting system
88 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10); 76 RandomizeRange(randomOrder, SWAP_NONE, 1, 10);
89 // Randomize Glass 1-3 into everything after the door 77 // Randomize Glass 1-3 into everything after the door
90 const size_t glassDoorIndex = find(randomOrder, 9) + 1; 78 const size_t glassDoorIndex = find(randomOrder, 9) + 1;
91 randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12); 79 RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12);
92 randomizer.ReassignTargets(bunkerPanels, randomOrder); 80 ReassignTargets(bunkerPanels, randomOrder);
93 81
94 /* Shadows */ 82 /* Shadows */
95 randomOrder = std::vector(shadowsPanels.size(), 0); 83 randomOrder = std::vector(shadowsPanels.size(), 0);
96 std::iota(randomOrder.begin(), randomOrder.end(), 0); 84 std::iota(randomOrder.begin(), randomOrder.end(), 0);
97 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial 85 RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial
98 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid 86 RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid
99 randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow 87 RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow
100 randomizer.ReassignTargets(shadowsPanels, randomOrder); 88 ReassignTargets(shadowsPanels, randomOrder);
101 // Turn off original starting panel 89 // Turn off original starting panel
102 randomizer.WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); 90 WritePanelData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f});
103 // Turn on new starting panel 91 // Turn on new starting panel
104 randomizer.WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); 92 WritePanelData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});
105 93
106 /* Monastery 94 /* Monastery
107 randomOrder = std::vector(monasteryPanels.size(), 0); 95 randomOrder = std::vector(monasteryPanels.size(), 0);