Yahtzee!!! 🎲🎲🎲🎲🎲
Yahtzee
Hello hello hello!
I made Yahtzee! (Kinda)
So what is Yahtzee?
Yahtzee is a popular dice game where you have 5 dice (each dice having 6 sides, and the numbers 1 - 6 written on the sides. Just normal dice). The aim of the game is to roll those dice and to try to get at least 3 dice of the same value. The full game has a few more stuff, what I have done is a bit more simplified. Rolling all five dice with the same number (like all of them have the number 2) gets you the most points possible. That is called Yahtzee. (I think you’re supposed to shout that out loud if you get it xDD)
My version
So like I said earlier, what I did is a simplified version of the game. Mine is kinda a simulation.
-
You will be able to either roll the dice manually (by pressing enter) or by doing it automatically for a number of times set by you (careful not to put a value too big or it’ll crash!).
-
At the end of the simulations, you will be given a summary with how many rolls you did, how much times you got 3 Of A Kinds/4 Of A Kinds/Yahtzees, and your total points. In this version, I put 3 Of A Kinds at 6 pts, 4 Of A Kinds at 12 pts, and Yahtzees at 50 pts.
How this was made
Ok, so first of all, I have my list containing 5 dice. I then rolled a random number from 1 to 6 for each of the 5 dice. remember that lists start at index 0.
Next, instead of using loads and loads of if
statements to check if the numbers are the same, I just used the sort()
. This sorts the dice from smallest to largest.
So for example, if I rolled [5] [6] [5] [5] [1]
, the sort()
will sort them like this: [1] [5] [5] [5] [6]
. As you can see, I have a 3 Of A Kind.
Next, I use a bit of conditionals to determine if I scored anything. Like if I scored a Yahtzee, that would mean that all the dice are the same. So I can just do if dice[0] == dice[4]:
which checks if the 1st dice equals the last dice. Since the dice are already arranged from smallest to largest, then it sees that I got a Yahtzee!
Lets go back to my 1st example.
These are my dice: [1] [5] [5] [5] [6]
and they are sorted from smallest to largest. The first if
statement checks if there is Yahtzee. Is the first index equal to the last one? No, so no Yahtzee.
Then, it checks if its a 4 Of A Kind like this:
elif dice[0] == dice[3] or dice[1] == dice[4]:
Again, that condition isn’t verified.
Last conditional, it checks if there is a 3 Of A Kind:
elif dice[0] == dice[2] or dice[1] == dice[3] or dice[2] == dice[4]:
Aha! So we can see that dice[1] == dice[3]
which means that the dice at index 1 = the dice at the index 3. This means that I have scored a 3 Of A Kind!
(I hope that wasn’t too long/unnecessarily boring or complicated ;)
Chances of getting a Yahtzee
Planning on getting those 50 points? You’ll have to be very, very, very, very lucky. Lets do the math:
There are 5 dice, each with 6 sides. This means there are 6 x 6 x 6 x 6 x 6 = 6^5 = 7776 possible different combinations. A lot.
So if you want all the dice to have the same numbers; you have 6 possibilities (five 1s, five 2s, five 3s, etc.).
Next, we divide the number of possible Yahtzees (6) by the total possible rolls (7776), you get 6/7776 = 1/1296.
Yep, the odds of getting a Yahtzee is 1 chance over 1296. That’s about 0.08 percent.
Some gameplay
As you can see, I’ve rolled 10 times, and only gotten one 3 Of A Kind, no Yahtzee (duh).
I roll 100 times, and I’ve gotten six 4 Of A Kinds and nineteen 3 Of A Kinds, still no Yahtzee.
I roll 1000 times, twenty-two 4 Of A Kinds and one hundred and eighty eight 3 Of A Kinds, and still no Yahtzees again.

But now I rolled 10000 times, and I’ve finally gotten 4 Yahtzees with almost two hundred 4 Of A Kinds and almost two thousand 3 Of A Kinds.

Well, that’s all I think. Try this out and tell me what you think. I find it mind boggling how many possibilities there are in only 5 dice, and how hard it is to get a Yahtzee.
So if y’all every play the actual game, just know that you’ll have to throw dice a few thousand times to get some Yahtzees!
Everyone have an amazing day! =)
I feel your skill improving
Really? @Jakman
@JosephSanthosh he's growing. It might have been a slower start than usual but he is growing. I can tell
Oh that's cool! @Jakman
@Jakman I'm growing too ... sideways btw.
@JosephSanthosh you should get that checked out. Sounds like a bad case of diabetes
Haha! i'm like 110 pounds, that's why u shud never be a runner for cross country or track n field. @Jakman
@JosephSanthosh my advice for you is to not go to prison anytime soon. You are very small.
@Jakman Thx! I'm a freshham
*Freshman @Jakman
Freshfish @Jakman
@JosephSanthosh lol. ok
You rolled: [3, 3, 3, 3, 3]
Yahtzee!!!
Cool, plus great logic explanation.
@JasonLiu19 lol nice! :)
I rolled 800 times and got 2 Yahtzees. Is that lucky?
i guess lol nice! @HEROBRATT
You rolled: 1 times
You got:
[0] Yahtzees (0 points)
[0] 4 Of A Kinds (0 points)
[1] 3 Of A Kinds (6 points)
Total points: 6
LUCKY!!!
Nice! @Brooks2009
@HEROBRATT I rolled 1000000000 times
lmao nice @HEROBRATT
out of 10 i got 1 four of a kind ond 3 3of a kinds
I got 3 in 1000
nice ;) @EshaanAhuja
I ate rolled 100 times and on The 72 time i got a yatgese
ok nice @EshaanAhuja
I got a Yahtzee on my 108 try
lol nice @EshaanAhuja
have you joined the language jam? (https://repl.it/jam)
I rolled 600 times to get 1 yahtzee is that lucky or unlucky?
@TinaChen4 Lucky!
i got 80 yahtzees!
i used automatic for 9999999999999999 times and...
rolling 100000 times...
@DigitCommander 74 Yahtzees
This pretty cool! And i noticed if automatic and press random very very high number, it sort of like animation
lol thanks! @JSDRAGONCODER
So good! I really like this game. Good Job!
I rolled it 10 million times and got 466 yahtzees!
Nice! fyi, When you ask how many times to roll the dice, you asked how much times you should do it. The correct grammar for counting is "many".
ah ok, thanks for telling me ;) @codeitfast
@Bookie0 You're welcome. It doesn't really matter, tho
on how many rolls? @k9chelsea2
that was on the automatic roll thing and the number i did was one thousand
oh ok lol nice @k9chelsea2
i also inputted a massive number like 382473047028438- but after about an hour the program (or browser prolly teh latter) crashed
This game is 100% rigged
nice @ChezTacoz
I find it mind boggling how many possibilities there are in only 5 dice, and how hard it is to get a Yahtzee.
So I did the math and the answer kinda angers me. There are 6 faces on a die, and there are 5 dice, so the answer is 6^5
Which is 7776
Which is soooo close to 7777, but isn't.
Good work on this btw.
Omg i so lucki :oooo

lol @behavingEffort
@behavingEffort
XD
@behavingEffort Wow your die must be biased
@behavingEffort I must admire, that your photo lokks quite legitimate (jk)
lmaoo @behavingEffort
lol @behavingEffort
@behavingEffort epic
:OOOOO how did you dewit @behavingEffort ?????
@behavingEffort There must be a HUGE bug XD.
@codeitfast XD
@k9chelsea2 lucky!!!!!
lol thx
lol @behavingEffort
Lol @behavingEffort