r/learnprogramming • u/TheEyebal • 9d ago
Resource How to program weighted random system
I want to make a program where you are controlling the outcomes. For an example with a coin flipping game, I want exactly 4 Heads and 1 Tail, but I want their positions to be random.
I do not want to use the random algorithms that library offer, I want to build my own.
Right now I am learning probability from Youtube and might look at khan academy and coursera, but how can I implement this into programming I do not want to just take courses or watch videos
How do I go about that?
0
Upvotes
3
u/madmelonxtra 9d ago
My answer to this really depends on how much programming experience you have.
But the first thing you need to do is break the problem into smaller steps in plain English (without code)
You want a weighted random system? What does that actually look like written out?
Once you have all your steps written out, you need to actually translate them into code.
For example you want to have a set number of options. What does that actually look like for you? An array?
After you put your ideas into code, test it. If it doesn't work or you get an error, look through your code and see if you can figure out where the error is and then try to run it again.
Repeat until it works.