Daddy needs a new pair of RAM!
edit: the fps are way better in smaller terminal windows with lower character count but then it's hard to make out the dice. D:
edit2: code here (expires in 2 weeks)
https://files.catbox.moe/8rz9m7.mp4
Daddy needs a new pair of RAM!
edit: the fps are way better in smaller terminal windows with lower character count but then it's hard to make out the dice. D:
edit2: code here (expires in 2 weeks)
93 Comments
oce@jlai.lu · 33 pts · 21h
I'm curious why it seems the time slows down at the end compared to reality? Because more computation is needed to check if it's a stable state?
Pudutr0n@lemmy.world · 30 pts · 20h
the final resolution stage was a huge headache and as you can see, one I didn't fully solve. Basically when the dice finally settle, particularly those with more sides, lots and lots of micro collisions happen in close sequence, each one having to apply friction and bounce back. As velocities come close to be rounded to 0, the bounce back effect and force of gravity no longer provide movement, but the final angle of the bottom face may not be fully settled on the floor. So basically if i don't ignore all these tiny collisions I get the frame rate drop you see and if I do, I can arrive at not fully settled states which can become ambiguous result-wise in, say, the 20-sided die.
hirihit640@sh.itjust.works · 9 pts · 19h
Can you predict the resolution when it is close enough to settled? Worst case maybe have an algorithm that estimates the probability of each face ending up on top, and if one face is overwhelmingly more probably, choose it. Otherwise let it settle using your physics engine
Pudutr0n@lemmy.world · 9 pts · 19h
I can easily check for when motion stops, but checking for when any particular face is both parallel to the floor and at the same level can be computationally expensive, particularly in the dice with more sides. What you're suggesting is likely a good idea, but I wouldn't know how to get probabilities without doing what I just mentioned. I'm sure there's an optimization i can do with this that I can't think of rn.
hirihit640@sh.itjust.works · 8 pts · 19h
maybe just "if velocity < 0.01, find which side is closest to the floor, and if its within 1mm of the floor, take the opposite side (the one facing up) as the answer"
The only edge case I can think of is if it gets close to balancing on an edge, and then finally tips over to one side or the other. But in that case I don't think the face closest to the floor would be within 1mm of the floor, so it should still work.
Pudutr0n@lemmy.world · 6 pts · 19h
that's how it's implemented, mostly, but sometimes dice "stop" while they're still tilted and standing on a corner (and then roll back down, possibly going back more than 1 face) so there's also that.
hirihit640@sh.itjust.works · 3 pts · 15h
Ok well there's probably a dozen different ways to tackle this issue but I'll let you explore them since that's part of the fun (and I'm lazy lol)
Cethin@lemmy.zip · 2 pts · 5h
Since you're rolling on a plane, can't you simplify the collisions to only check the corners? I think that should be all that's needed. There shouldn't be a time where the edges or faces are below the lowest corner on a plane, so they can be skipped I believe.
Pudutr0n@lemmy.world · 1 pts · 4h
i need to check the corner collisions but when the die start settling and an entire edge comes close to the floor, gravity keeps pulling back on several of them making them bounce back just a tiny bit, not reaching the velocity that gets rounded to zero.
I fixed that on the current version doe!
glizzyguzzler@piefed.blahaj.zone · 29 pts · 19h
Get this on the berg I wanna render my dice rolls over SSH stat
Pudutr0n@lemmy.world · 13 pts · 19h
lol but it's not finished and everyone will see how stupid my code (and brain) is D:
GeirGrusom@lemmy.world · 21 pts · 16h
It's bash. Everyone is expecting nightmare code, and that's why it's fun!
CrazyLikeGollum@lemmy.world · 12 pts · 18h
Pudutr0n@lemmy.world · 2 pts · 10h
I forgot to tell you how much I appreciate this meme. heh. thanks!
promitheas@programming.dev · 9 pts · 18h
My suggestion is do it. Its a cool project, and clearly there is interest from others who could contribute to the project by suggestions, bug fixing, or general collaboration, helping you learn. Just add some kind of disclaimer in the project that its not ready yet, and that youre still learning and it should be fine.
Pudutr0n@lemmy.world · 6 pts · 16h
you make good points
Pudutr0n@lemmy.world · 1 pts · 6h
i'm just gonna pastebin it for now but yeah, thanks for the encouragement.
BasedMaquisEddington@lemmy.dbzer0.com · 8 pts · 17h
I hope you change your mind.
Most people care about features, not the implementation.
Those who dislike your code are probably going to generally dislike others’ code anyways, so in a sense they don’t even need to see your code to already disapprove of it 🤷♀️
Pudutr0n@lemmy.world · 6 pts · 16h
Well, you guys are making some p good points. I'll probably end up sharing it, but'll give it a clean up, try to fix some bugs and improve my comments before posting it publicly. For now whoever really wants it (including you) can just ask and I'll dm it, understanding it will be a hard read and still has bugs.
Pudutr0n@lemmy.world · 3 pts · 6h
I changed my mind.
BasedMaquisEddington@lemmy.dbzer0.com · 2 pts · 2h
Thanks fam. Can’t wait to use this for dramatic and comedic effect during pair programming 🤣
Pudutr0n@lemmy.world · 1 pts · 2h
Go nuts! haha. All yours.
prole@lemmy.blahaj.zone · 7 pts · 12h
Cut yourself some slack. These days, most people would have just pasted LLM outputs
Pudutr0n@lemmy.world · 3 pts · 11h
lazy
KeenFlame@feddit.nu · 6 pts · 13h
The only way to do it is to do it - me, 2026
Nah, but seriously, that insecurity is a disease that will actually make you produce embarrassing code. As soon as you feel confidence feedback take off, you will paint the functions brilliant once you de-neuter your inner codebeast. It wants to fuck. Let it.
KeenFlame@feddit.nu · 4 pts · 13h
I fucked that sentence up, but you understand what I mean! ∆<3
Pudutr0n@lemmy.world · 1 pts · 6h
I did and I appreciate it. here's the code if you're interested.
Pudutr0n@lemmy.world · 2 pts · 10h
Thank you for your inspiration <3
glizzyguzzler@piefed.blahaj.zone · 2 pts · 9h
Haha there is no shame in shell code, it’s already monstrous to start!
I’ve written things in shell that would look sooo nice and concise in any other language, but it became a Cthulu-ass demigorgon so quick in shell! Have no fear, fear is the mind killer, the little death!
Pudutr0n@lemmy.world · 5 pts · 6h
psst... here ya go
glizzyguzzler@piefed.blahaj.zone · 2 pts · 3h
When I opened the code I immediately scrolled to the bottom to see how many lines, and hell yeah. I read through it and I'm horrified, but I'm even more horrified it works. This is truly an chievement
Here it is running over SSH https://files.catbox.moe/qkwd4q.mp4 what more could I ask for, thank you for making this insane thing and sharing it!
Pudutr0n@lemmy.world · 2 pts · 3h
holy shit, I'm so flattered! Thank you for your kind support and encouragement!
It's crazy that it looks okaish right? quaternions, dude. I have implemented them in 3 projects and still have no fucking idea how they work.
Also, you can run it in --quality low if you're struggling with framerate. :)
glizzyguzzler@piefed.blahaj.zone · 2 pts · 1h
It's insane how many features this has for being insane in of itself!
Edit: that was running on anemic "1 core" (1 very shared core) VPS, bumping it up to 4, hooboy do those dice fly
Pudutr0n@lemmy.world · 2 pts · 44m
nice! I'm still working on and have kept adding features. the encouragement was really motivating, so now I'm finishing multi-dice rolls that later add the result of all rolls.
If you want an updated version later on, would be glad to share w you. :)
glizzyguzzler@piefed.blahaj.zone · 2 pts · 36m
Sign me up!
Pudutr0n@lemmy.world · 1 pts · 14m
'ere ya go. hope you like.
AnarchistArtificer@lemmy.world · 28 pts · 10h
One of my favourite things in the entire world is what I call "high effort shitposts". Running DOOM on absurd devices like pregnancy tests is the archetypical example I use when explaining this.
Well, congrats, because this is absurd enough that this makes the list too. You are ridiculous and delightful, and I am glad that you exist to create impressive horrors like this.
Pudutr0n@lemmy.world · 11 pts · 10h
Thank you so much! I love high effort shitposts too!
And if you liked that, you're going to love this: A while ago I also wrote a 3d renderer from scratch inside the picotron, an emulated fantasy console that never existed, to display a 3d model of a pudu.
I have a few more of these you might appreciate, non 3d related.
farmgineer@nord.pub · 20 pts · 19h
Are you often described as a masochist?
It looks neat. I can't imagine wanting to write it in bash, though, heh.
Pudutr0n@lemmy.world · 16 pts · 19h
XD I am! And it was a complete nightmare. hahaha
MonkderVierte@lemmy.zip · 16 pts · 18h
(hopefully) Constructive critique:
Pudutr0n@lemmy.world · 15 pts · 18h
Thanks! Yeah, there's definitely A LOT of room for improvement. collisions are handled per vertex, but torque is applied to angular impulse to the dice as a whole (like a ball I guess). The settling is a huge issue, yes. the visual glitches I've been trying to get rid of but man... fix one and then another one pops up in a different case. Thanks for your critique. :)
Atherel@lemmy.dbzer0.com · 6 pts · 16h
I first read it as "there's a lot of DOOM for improvement" but as the rest of your comment confirmed this, I'll keep it that way in my head!
RheumatoidArthritis@mander.xyz · 16 pts · 21h
Haha nice! How long did it take you? Integer-only math?
SpaceNoodle@lemmy.world · 23 pts · 21h
All computer math is integer math if you go deep enough
RheumatoidArthritis@mander.xyz · 9 pts · 21h
I'm sure implementing floating point directly in bash would work great
RheumatoidArthritis@mander.xyz · 17 pts · 20h
I didn't have the patience to do it myself bit wanted to see just how complex it would get:
RheumatoidArthritis@mander.xyz · 15 pts · 20h
1440 multiplications per second on my computer!
Womble@piefed.world · 18 pts · 20h
Wow, over a kiloflop!
Pudutr0n@lemmy.world · 7 pts · 19h
hahaha you seem to be familiar with the issues I ran across
tabular@lemmy.world · 4 pts · 16h
Invert the gravity value and then all the dice will be floating point 🫣
Pudutr0n@lemmy.world · 14 pts · 19h
Jebus I don't even know how long I've been working on this. It started out as a way to teach myself bash, combined with my long obsession with rendering platonic solids. I previously coded a huge galaxy of hundreds of thousands of polyhedra you could fly across in python with opengl shaders and got to reuse/translate a lot of that code. The quaternion stuff I was grateful to not have to rethink that much again. haha. And yes, integer-only! Some params are "floating point" but i just parse them and add a bunch of zeroes so i can later do all the operations with equally blown up values of pi and trig stuff from "lookup tables" (case matching).
MonkderVierte@lemmy.zip · 6 pts · 18h
Btw, you could pipe it to
bcfor the odd float. Or even some complex math. Just in case you didn't know.Pudutr0n@lemmy.world · 6 pts · 18h
yeah, I was trying to stay as pure-bash as possible, but thanks!
RheumatoidArthritis@mander.xyz · 4 pts · 18h
Strong Amiga coding vibes.
thingsiplay@lemmy.ml · 14 pts · 15h
I just woke up and this is the first thing I see. Did I really woke up?
dejected_warp_core@lemmy.world · 7 pts · 13h
https://www.youtube.com/watch?v=TQhyDYQ081U
Crackhappy@lemmy.world · 5 pts · 11h
Oh my God that's amazing.
thingsiplay@lemmy.ml · 5 pts · 12h
A banger to wake up to, as alarm clock song. :D
Aqivex@fedinsfw.app · 13 pts · 11h
@Pudutr0n@lemmy.world - You are certifiably insane. There are a million more effective ways to achieve this, with less resources... I LOVE IT.
Pudutr0n@lemmy.world · 8 pts · 11h
This is exactly the kind of flattery that truly touches my heart. <3
adhocfungus@midwest.social · 12 pts · 15h
Absolutely insane. Part of me wants to see the source code, but part of me is terrified of how complex it must be. Plus I've only been writing bash for 20 years, so it would probably look incomprehensible to me.
alphabethunter@lemmy.world · 12 pts · 19h
This is beautiful, and insane! But truly beautiful hahaha
Pudutr0n@lemmy.world · 6 pts · 19h
Thank you! haha
spacegoat@lemmy.world · 10 pts · 5h
Do you think God stays in heaven because he too lives in fear of what he's created?
Pudutr0n@lemmy.world · 8 pts · 4h
mike_wooskey@lemmy.thewooskeys.com · 8 pts · 17h
I'm viewing this thread in Lemmy and am unable to find any mention of a link to the source code or a demo, and I can't see the attached media (genetic image icon - is it an animated gif or a video?).
Based on all the comments, I appear to be in the [significant] minority. Would you mind posting a link to your source or demo or image/video?
Pudutr0n@lemmy.world · 18 pts · 17h
I haven't shared the source code yet because criticism is terrifying and I'm a horrible coder, but with the encouragement of the the community I might give it a shot. I don't even have a codeberg account yet though.
The post contains these two video links: https://files.catbox.moe/8rz9m7.mp4 https://files.catbox.moe/5d3n2k.mp4
If you still can't see them, maybe you can suggest a different hosting service, one that works for you? Or if you really really want the source code I suppose I could send it by DM on the meantime.
oce@jlai.lu · 10 pts · 17h
There are millions of professional coders who couldn't do what you did there.
vrek@programming.dev · 6 pts · 16h
Just letting you know the original post video didn't load and gave a 500 error in jerboa but those two links work. Looks impressive but I'm confused on how to read the die. Yes there is a giant banner telling me the value it chose but I'm struggling to figure out how the visuals map to those values, can you give some details on how to read the die?
Pudutr0n@lemmy.world · 6 pts · 16h
Yes, the values are rendered on top of each face with "pixel" maps (ascii art) that have the character of the digit they represent as each pixel. These are later manipulated by the perspective projection.
For example on this d6 you can see the top face has 1s written down (in the shape of a sideways one) and the front one has 4s written down in the shape of a skewed and sideways 4.
In this specific color scheme there's not a lot of contrast between the values, but even in the palettes with better contrast, good readability is something I'm kind of giving up on solving well.
edit: might be clearer here:
vrek@programming.dev · 2 pts · 7h
In the second picture (with the d20) I'm guessing the face with "999" is actually a 9 but what is the value of the face with "999#111"...there is no value of 91 on a d20 :)
Pudutr0n@lemmy.world · 1 pts · 6h
actually I was working on the code and realized i got the textures mirrored due to negative-positive mix up. so it was reflecting the mirror image of 19
vrek@programming.dev · 2 pts · 6h
Ah that makes sense. Overall looks impressive, was just confused on my end.
Pudutr0n@lemmy.world · 1 pts · 6h
thanks! :D
mike_wooskey@lemmy.thewooskeys.com · 3 pts · 11h
That's pretty darn cool! Thanks for sharing. Ik forward to cloning your repo someday.
Pudutr0n@lemmy.world · 2 pts · 6h
here ya go
Pudutr0n@lemmy.world · 1 pts · 11h
I'll do a follow up post when I upload
SystemDisc@feddit.org · 2 pts · 12h
Pudutr0n@lemmy.world · 1 pts · 11h
what video hosting service works for you?
SystemDisc@feddit.org · 2 pts · 42m
I have no idea. I self-host a lot
Pudutr0n@lemmy.world · 1 pts · 40m
well i don't know how to deliver the media to you then D: sry. you can snag the code from pastebin though. I linked on my last edit.
SystemDisc@feddit.org · 2 pts · 26m
No worries. That service is just refusing the connection or 500ing for people.
Pudutr0n@lemmy.world · 3 pts · 6h
here's the source code. :)
Gsus4@mander.xyz · 8 pts · 18h
3D dice rolling...ok...😐 ... in bash ...🤨 !?
PS: I remember seeing something vaguely like this recently...this you?
Pudutr0n@lemmy.world · 2 pts · 6h
no, but I LOVE that guy
cristian64@reddthat.com · 7 pts · 17h
I didn't know I needed this.
Pudutr0n@lemmy.world · 2 pts · 6h
and now you have it
albbi@piefed.ca · 6 pts · 18h
Looks like a great
slreplacement! Gonna need this on every machine.Pudutr0n@lemmy.world · 2 pts · 6h
if you want it on yours, here it is. Thanks for your support. :)
bridgeenjoyer@sh.itjust.works · 6 pts · 14h
Holy crap how cool
HeHoXa@lemmy.zip · 2 pts · 59m
I think I might love you
Pudutr0n@lemmy.world · 2 pts · 41m
ily2 bb <3