top of page

One Click Marble Race Generator #1

Updated: Mar 30




I’ve been crafting an add-on for the Marble Race Kit, designed to take the hassle out of creating marble race courses and make it a breeze for creators. It’s a simple tool, but it has already proven to be quite useful for anyone looking to design their own courses with less effort. But why stop at “good enough”? I’ve been thinking about taking it a step further by adding a feature that could truly transform the experience—a One Click Generation function.


This feature could help users to:

  • Generating a complete track from scratch.

  • Customizing contestants for the race.

  • Animating a camera that dynamically follows the marbles.

  • Keeping tabs on contestant positions mid-race.

  • Producing a polished results diagram to wrap up the event.


What often takes hours to build might soon be possible in just one click. Of course, it’s a challenging goal, and I have a lot to learn and figure out along the way. But I’m excited to start working on it and see how this idea evolves.



First Step


To begin, I decided to keep things simple by focusing on three fundamental building blocks: straight, turn left, and turn right. The generator randomly selects from these blocks, connecting them one by one to form a continuous track.


However, one critical input was missing: the number of blocks to generate. To address this, I added a slider to the panel, allowing users to set the desired number of blocks. For example, if a user selects 20, the generator will create a track with 20 connected blocks.

Initial Implementation: Simple Track Generated with Three Basic Blocks
Initial Implementation: Simple Track Generated with Three Basic Blocks

Random but not truely random


One issue I encountered was that the generated track had too many turns, making it dizzying to watch. This problem arose because each of the three block types had an equal probability of being selected.


To address this, I categorized the blocks into two separate lists: the Straight Block List and the Turn Block List. I assigned a hierarchy value of 0.8 to the Straight Block List and 0.2 to the Turn Block List. In practice, this results in an 80% chance of generating a straight block and a 20% chance of generating either a left or right turn.


Now, I’m considering whether to allow users to adjust these hierarchy values themselves. Would that enhance user control or needlessly complicate the experience?

Adjusted Generation: Balanced Track with Fewer Turns for Improved Flow
Adjusted Generation: Balanced Track with Fewer Turns for Improved Flow

Increase Variety


After hours of coding and debugging, the system is finally running smoothly! With the groundwork complete, I can now add blocks of varying lengths and heights to the lists and see how they perform.


The results are promising, but a familiar issue has cropped up—there are too many steep slopes in the generated tracks. This causes the marbles to speed up excessively, and sometimes even fly off the track. To address this, I created a new list specifically for steep blocks and assigned it a smaller hierarchy value.

Before: Excessive Steep Slopes in Generated Track Causing Marble Instability
Before: Excessive Steep Slopes in Generated Track Causing Marble Instability
After: Adjusted Hierarchy with Reduced Steep Slopes for Smoother Performance
After: Adjusted Hierarchy with Reduced Steep Slopes for Smoother Performance

Overlap Detector


Avoiding overlapping tracks was no small challenge. Instead of agonizing over the perfect solution, I decided to jump in and try something straightforward first. I added a detector in the script to check whether the tracks' origins were overlapping. If an overlap was detected, the script would step back, re-generate the track, and try again. After a few attempts, if the overlap persisted, the script would stop entirely to prevent an endless loop that could crash the system.


This approach worked well enough for basic setups, but it quickly became apparent that it wouldn’t suffice as more blocks were added to the generator. These blocks came in various sizes and with different origin positions, so simply checking their origins wasn’t enough. We need a more robust solution to ensure their volumes don’t overlap.


There’s also another factor to address. Even if tracks don’t physically overlap, having them continuously pass under one another can create a visually jarring experience. Avoiding this kind of vertical overlap is equally important. For now, though, my overheated brain could use a break. I’ll tackle this challenge in the next phase with a clearer mind!


 

Next Mission


At the first attempt, the generator can already create a continuous track based on the requested number of blocks, which is fantastic! In the next phase, I’ll focus on tackling these tasks:

  • Ensure the overlap detector is fully functional.

  • Add more types of blocks for greater variety.

  • Include an option to add starting and ending blocks so the course feels complete.

  • Generate a path for camera tracking to enhance the viewing experience.


There’s still plenty of work to be done, but every small improvement brings the project closer to its full potential. I’m excited to see how it all comes together! Feel free to leave your comments or ideas. I’d love to hear your thoughts.




Comments


Alan Luk

Welcome toalanluk.art!! I’m a digital artist passionate about rolling ball sculptures and dynamic simulations. Explore my creative journey and discover art that combines motion, innovation, and imagination.

Follow Me

Instagram: @alan__luk
YouTube: @alan__luk

© 2025 by Alan Luk.

bottom of page