Skip to content

Commit

Permalink
Updated randomizer with new features
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Dec 8, 2023
1 parent 416251e commit 75cfa3b
Show file tree
Hide file tree
Showing 17 changed files with 30,933 additions and 30,856 deletions.
91 changes: 84 additions & 7 deletions VortexEngine/src/Menus/MenuList/Randomizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,26 @@ PatternID Randomizer::rollMultiPatternID(Random &ctx)
return (PatternID)ctx.next8(PATTERN_MULTI_FIRST, PATTERN_MULTI_LAST);
}

#define NUM_MAPS (sizeof(maps) / sizeof(maps[0]))

LedMap maps[] = {
MAP_ALL_FACE,
MAP_ALL_BOT,
MAP_ALL_TOP,
MAP_LINE_1,
MAP_LINE_2,
MAP_QUADRANT_1,
MAP_QUADRANT_2,
MAP_QUADRANT_3,
MAP_QUADRANT_4,
MAP_RINGS_EVEN,
MAP_RINGS_ODD,
MAP_RING_INNER,
MAP_RING_MIDDLE,
MAP_RING_OUTER,
MAP_RING_EDGE
};

bool Randomizer::reRoll()
{
MAP_FOREACH_LED(m_targetLeds) {
Expand Down Expand Up @@ -326,18 +346,75 @@ bool Randomizer::reRoll()
}
}
if (m_targetLeds == MAP_LED(LED_MULTI)) {
// choose if the result is comprised of multiple single-led patterns
// or a single mutliled pattern
bool splitMultiRandomize = m_multiRandCtx.next8() > 128;
LedMap randomMap;
LedMap inverseMap;
if (splitMultiRandomize) {
m_previewMode.clearPattern();
// choose a random led map
randomMap = maps[m_multiRandCtx.next8(0, (NUM_MAPS - 1))];
inverseMap = MAP_INVERSE(randomMap);
}
if (m_flags & RANDOMIZE_PATTERN) {
// TODO: Advanced multi led patterns?
if (!m_previewMode.setPattern(rollMultiPatternID(m_multiRandCtx), LED_MULTI)) {
ERROR_LOG("Failed to roll new pattern");
return false;
if (splitMultiRandomize) {
// roll a first pattern
PatternID firstPattern = rollPatternID(m_multiRandCtx);
// set each led in the map to the pattern
MAP_FOREACH_LED(randomMap) {
if (!m_previewMode.setPattern(firstPattern, pos)) {
ERROR_LOG("Failed to roll new pattern");
return false;
}
}
// roll a second pattern and reverse the led map
PatternID secondPattern = rollPatternID(m_multiRandCtx);
// set the remaining leds to the 2nd pattern
MAP_FOREACH_LED(inverseMap) {
if (!m_previewMode.setPattern(secondPattern, pos)) {
ERROR_LOG("Failed to roll new pattern");
return false;
}
}
} else {
if (m_advanced) {
// dynamically generate parameters for mutli led pattern ids
//if (!rollMultiPattern(m_multiRandCtx, &m_previewMode)) {
// ERROR_LOG("Failed to roll new pattern");
// return false;
//}
} else {
// randomly select a multi led pattern id
if (!m_previewMode.setPattern(rollMultiPatternID(m_multiRandCtx), LED_MULTI)) {
ERROR_LOG("Failed to roll new pattern");
return false;
}
}
}
}
if (m_flags & RANDOMIZE_COLORSET) {
// roll a new colorset
if (!m_previewMode.setColorset(rollColorset(m_multiRandCtx), LED_MULTI)) {
ERROR_LOG("Failed to roll new colorset");
return false;
if (splitMultiRandomize) {
Colorset firstSet = rollColorset(m_multiRandCtx);
Colorset secondSet = rollColorset(m_multiRandCtx);
MAP_FOREACH_LED(randomMap) {
if (!m_previewMode.setColorset(firstSet, pos)) {
ERROR_LOG("Failed to roll new colorset");
return false;
}
}
MAP_FOREACH_LED(inverseMap) {
if (!m_previewMode.setColorset(secondSet, pos)) {
ERROR_LOG("Failed to roll new colorset");
return false;
}
}
} else {
if (!m_previewMode.setColorset(rollColorset(m_multiRandCtx), LED_MULTI)) {
ERROR_LOG("Failed to roll new colorset");
return false;
}
}
}
}
Expand Down
378 changes: 189 additions & 189 deletions VortexEngine/tests/tests_general/0024_Randomize_Front_Bulb.test

Large diffs are not rendered by default.

Large diffs are not rendered by default.

5,706 changes: 2,853 additions & 2,853 deletions VortexEngine/tests/tests_general/0026_Start_Auto-randomizer_Front_Bulb.test

Large diffs are not rendered by default.

8,852 changes: 4,426 additions & 4,426 deletions VortexEngine/tests/tests_general/0027_Stop_Auto-randomizer_Front_Bulb.test

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6,000 changes: 3,000 additions & 3,000 deletions VortexEngine/tests/tests_general/0050_Stop_Color_Only_Auto-randomizer_Front_Bulb.test

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10,002 changes: 5,001 additions & 5,001 deletions VortexEngine/tests/tests_general/0053_Start_Pattern_Only_Auto-randomizer_Front_Bulb.test

Large diffs are not rendered by default.

12,006 changes: 6,003 additions & 6,003 deletions VortexEngine/tests/tests_general/0054_Stop_Pattern_Only_Auto-randomizer_Front_Bulb.test

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 75cfa3b

Please sign in to comment.