Math questions

Oh, Thanks! I didn’t think it was that much honestly. I did all that even before doing any programming course :sweat_smile:

You should see what others have done here.


In any case.
The game rules are that every player makes a prediction: greater or lower than 1-to-20
or equal to 1-to-20
Each player turns a cup with one 20 dice and the closest one to the prediction wins. Just a simple game.

The code just randomizes the other player’s predictions (with some leeway) and randomizes the roll dice of everyone.
Then compares and gets if there is a true prediction, or if there are ties of 2, 3 or 4 players
Then also compares if there is any prediction closer that wins over the ties.
Then gets the winner and adds up the points to the score variables.

It might seem complex in the code, but once you split it into smaller parts it gets easier.
That’s like the basics of coding. Separate the functions into small chunks, then make it work with other small chunks and you can build big stuff without even knowing.

2 Likes