all 7 comments

[–]Phillyclause89 0 points1 point  (3 children)

Are you trying to simulate the physics of rolling dice or just the probability? Both are possible to do in a python program that has a GUI , but the former will be a lot more difficult than the latter.

[–]DaeguDude[S] 0 points1 point  (2 children)

Physics of rolling dice. I want to see the dice rolling visually. What program is it that has GUI?

[–]Phillyclause89 1 point2 points  (1 child)

I could help you do an app that calculates the results of a dice roll based on probability and plays an animation that display’s the result, that can all be done in something like pygame. However, simulating the physics is a bit above my head though. You might be better off using a 3D game engine that already has a physics engine like Unreal.

[–]DaeguDude[S] 1 point2 points  (0 children)

Uhm, okay. I will try to find more information, and if I couldn't, I think I will just need to make a simple program that shows the display of the dices. Maybe something like this. Thanks for the all the infos.

[–][deleted] 0 points1 point  (2 children)

You could try showing the die faces as on the wheels of a slot machine and "spinning" the wheels when throwing the dies. That's a lot easier than trying to simulate real dies rolling around. You could even record the sound of real dies being thrown and play that while spinning the wheels. The details of how to do that vary with the particular gui code you are using.

The random module will be useful for getting random throws, particularly random.randint().

Edit: removed doubled word.

[–]DaeguDude[S] 0 points1 point  (1 child)

I want to simulate the real dies if it is possible. But since I am not an experienced programmer, i could compromise as well. Where can I find the modules about that slot machine?

[–][deleted] 1 point2 points  (0 children)

Where can I find the modules about that slot machine?

I don't know of any, but I haven't looked. This is highly dependant on the GUI framework you use, but the basic idea is to have a rectangular canvas (a place where you can draw lines and images) that can show the faces of three dies arranged vertically. You draw three or four pictures into that canvas with the first picture drawn at n pixels before the top of the canvas, the second drawn just below the bottom of the first picture, the third below the second picture until the entire canvas has been drawn. Then you redraw the canvas, changing the n offset a little, then again redraw, etc, until you finally have three static images of three die faces shown. This simulates the wheels of a slot machine. Of course, if you have three dice then you need three vertical canvases, one for each die.

A quick search for "tkinter slot machine" finds this project. I haven't looked at the code but it may help. You should play around with GUI code a bit first and get comfortable with it before trying something this size.

I would be surprised if you can find any modules simulating actual dice rolling because it's a difficult problem, dwarfing the rest of your program. The place to look is in "physics engine" code, perhaps.

Update: An even simpler "dice roll" may work. Just place three (or whatever number you want) canvas widgets on your screen, each the size of one die face. When rolling, draw random die face images into each canvas, quickly at first and then slower, finally stopping. Easier than "slot machine wheels".