-
-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Game of Life Memory Leak Fix + Other Changes #133
Conversation
Removed gameoflife struct.
Blurs dead cells instead of immediately turning off depending on slider value. Blur is disabled when using overlay.
Uses .step now to pause.
General cleanup.
Recolors all live cells on palette/color change. Before you needed a game restart or mutation over time.
Every 4 ticks of speed adds 1 update per second. 1 - 64.
Please look over palette change code and game speed. |
Hi, thanks for this update.
You could use But your "cheat" is OK for me, too. It doesn't need to be a perfect solution. |
Some how overlooked this. Didn't think about palettes that change overtime, keeping the first color would work better for those. Each method seems to have a slight drawback, implementing both would be overkill. I'll have to test out those special palettes. I have a few more changes I've made in StarLeds that I need to convert to WLED and push. Finally figured out a way to make blending look better when a game starts repeating. |
Blur now fades while game is paused. New blur mode when blur slider is >220 Added variables to make code easier to follow instead of check1 custom1 etc. (not needed) Removed % with random8 calls. Misc changes
I'll post videos when I get a chance later. Code is a bit more complicated, especially the new redraw loop. Added new blend option when blur slider >220. There is an unintended effect when you have two segments and overlay off. Looks really good on high game speeds, but breaks (flashes) on lower ones. Tried a few ways to get it working on lower speeds but no luck. Default parameters don't seem to be working. May just be using progmem incorrectly. Edit: It works, just had WLED setting enabled that ignores default. futureCells is technically not needed to be stored in memory. It is only needed when game updates occur. @softhack007 I ended going with your suggestion with storing palette index. It looks nicer with palettes that cycle. Only downside is if using single/gradient color wheel options they don't instantly switch. Still works overtime though, so not a huge deal. |
Short video showing the new options.
Edit: Fixed flicker issue. Can now swap between overlay types. GoLBlurOverlay.mp4 |
Flicker fixed by always redrawing dead cells if overlay unchecked. Can swap between overlay types by checking/unchecking overlayBG.
Fixed overlooked data allocation after switching gliderLength to uint16.
Stress tested on a 64x32 matrix with 4 pins. Showing 30 FPS with max game speed. 40+ when updating is set to 20/sec. 32x64GoL.mp432x64GoLOverlay.mp4Rainbow Background Overlay a bit higher FPS around 33. Opposite "overlay" 24 FPS. |
Wrap is disabled if only 5 remaining alive cells (Glider).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for the update.
i've tested your new code quickly, and it works for me.
Below some recommendations that could slightly improve speed.
wled00/FX.cpp
Outdated
if (!SEGMENT.check2) SEGMENT.setPixelColorXY(x,y, !SEGMENT.check1?backgroundColor : RGBW32(backgroundColor.r, backgroundColor.g, backgroundColor.b, 0)); | ||
setBitValue(futureCells, cIndex, false); | ||
// Blur/turn off dying cells | ||
if (!overlayBG) SEGMENT.setPixelColorXY(x,y, blend(SEGMENT.getPixelColorXY(x,y), bgColor, bgBlendMode ? bgBlur : blur)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optimization: try to use color_blend() instead of blend()
Is this a known issue regarding overlays "breaking"? Normal overlay: SoapNormal.mp4Glitched overlay: SoapGlitched.mp4Seems like the segments start sharing colors instead of keeping them separate. It allows for some neat effects. Just makes debugging annoying when I don't want it to happen. GoLGlitchedOverlay.mp4 |
Other small changes.
Normally not - only two exceptions that I know about
|
Remove redundant check
@softhack007 I think I made all your recommended changes. Although I am not sure when to use There is one last thing I'd like to add to ease transition between games. It doesn't seem to want to cooperate with all options yet though. |
Starting alive cells are randomly colored in and bg fades on game start.
Merged generation == 1 checks into standard checks.
Finally got alive cells to spawn in randomly on game start working on everything, but overlayBG. Had a small flicker on start so decided to remove it. Looks a lot better with transition between games. The redraw loop is even more complicated now unfortunately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good 👍
Just tell once you're happy with the code, and i'll merge it into mdev.
Sounds good, I'll play around with it some more for a day or two to make sure everything is working normally and no bugs pop up. I'll let you know soon. |
@softhack007 Haven't run into any bugs on my setup so far. Feel free to merge whenever. |
Fixed memory leak using new. Removed gameoflife struct and reverted back to using pointers to segenv.data (similar to starLeds version).
Added Blur slider. Blurs dead cells slowly to bgColor depending on slider instead of immediately dying. Doesn't effect game logic.
Removed confusing pauseFrames, uses .step to pause now.
Keeps track of last palette used and immediately recolors cells if new palette/color selected. Can be improved.
Changes gameSpeed slider to be more consistent. Speed = updates/second now in increments of 4.