Skip to content
← Back to Community
Yahtzee!!! 🎲🎲🎲🎲🎲
Profile icon
Bookie0

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 ifstatement 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).


Screen Shot 2020-08-21 at 12.30.09 PM

I roll 100 times, and I’ve gotten six 4 Of A Kinds and nineteen 3 Of A Kinds, still no Yahtzee.

Screen Shot 2020-08-21 at 12.30.41 PM

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.

Screen Shot 2020-08-21 at 12.31.06 PM

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.

Screen Shot 2020-08-21 at 12.31.17 PM


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! =)

Voters
Profile icon
jayjay200
Profile icon
NDcoder
Profile icon
Dominicl645
Profile icon
user7865
Profile icon
DSADesmond
Profile icon
python88
Profile icon
DigitCommander
Profile icon
parmisss
Profile icon
AngelAyalaM
Profile icon
Name12
Comments
hotnewtop
Profile icon
[deleted]

Omg i so lucki :oooo
IMG_2852

Profile icon
VulcanWM
Profile icon
potatojs
Profile icon
firefish

@behavingEffort Wow your die must be biased

Profile icon
firefish

@behavingEffort I must admire, that your photo lokks quite legitimate (jk)

Profile icon
Bookie0
Profile icon
Leroy01010
Profile icon
ChezTacoz
Profile icon
k9chelsea2

:OOOOO how did you dewit @behavingEffort ?????

Profile icon
codeitfast

@behavingEffort There must be a HUGE bug XD.

Profile icon
codeitfast
Profile icon
[deleted]

@k9chelsea2 lucky!!!!!

Profile icon
k9chelsea2

lol thx

Profile icon
Name12
Profile icon
JBloves27
Profile icon
Jakman

I feel your skill improving

Profile icon
Bookie0

thanks! ;) @Jakman

Profile icon
gibbsfreenergy

Really? @Jakman

Profile icon
Jakman

@JosephSanthosh he's growing. It might have been a slower start than usual but he is growing. I can tell

Profile icon
gibbsfreenergy

Oh that's cool! @Jakman

Profile icon
gibbsfreenergy

@Jakman I'm growing too ... sideways btw.

Profile icon
Jakman

@JosephSanthosh you should get that checked out. Sounds like a bad case of diabetes

Profile icon
gibbsfreenergy

Haha! i'm like 110 pounds, that's why u shud never be a runner for cross country or track n field. @Jakman

Profile icon
Jakman

@JosephSanthosh my advice for you is to not go to prison anytime soon. You are very small.

Profile icon
gibbsfreenergy

@Jakman Thx! I'm a freshham

Profile icon
gibbsfreenergy

*Freshman @Jakman

Profile icon
gibbsfreenergy

Freshfish @Jakman

Profile icon
Jakman
Profile icon
Alice688

I LOVE this game. Also, please check out my account and maybe follow me. UwU

Profile icon
Bookie0

thanks! :) @Alice688

Profile icon
NDcoder

You rolled: [3, 3, 3, 3, 3]
Yahtzee!!!

Cool, plus great logic explanation.

Profile icon
JasonLiu19
Profile icon
Bookie0

@JasonLiu19 lol nice! :)

Profile icon
Ironwolfyyy

I rolled 800 times and got 2 Yahtzees. Is that lucky?

Profile icon
Bookie0

i guess lol nice! @HEROBRATT

Profile icon
Brooks2009

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!!!

Profile icon
Bookie0
Profile icon
Ironwolfyyy

image

Lmao 🤣🤣🤣🤣🤣🤣🤣🤣

Profile icon
Bookie0
Profile icon
Ironwolfyyy

image

🤣🤣🤣🤣🤣

Profile icon
Ironwolfyyy

@HEROBRATT I rolled 1000000000 times

Profile icon
Bookie0

lmao nice @HEROBRATT

Profile icon
python88

out of 10 i got 1 four of a kind ond 3 3of a kinds

Profile icon
python88

out of 10000 i got 9 yatzees

Profile icon
Bookie0

nice ;) @python88

Profile icon
EshaanAhuja

I got 3 in 1000

Profile icon
Bookie0
Profile icon
EshaanAhuja

I ate rolled 100 times and on The 72 time i got a yatgese

Profile icon
Bookie0
Profile icon
EshaanAhuja

I got a Yahtzee on my 108 try

Profile icon
Bookie0
Profile icon
VivaanSa

have you joined the language jam? (https://repl.it/jam)

Profile icon
Bookie0
Profile icon
VivaanSa
Profile icon
TinaChen4

I rolled 600 times to get 1 yahtzee is that lucky or unlucky?

Profile icon
DARIENAFZALBINM

@TinaChen4 Lucky!

Profile icon
python88

i got 80 yahtzees!

Profile icon
python88

i used automatic for 9999999999999999 times and...

Profile icon
DigitCommander

rolling 100000 times...

Profile icon
DigitCommander

@DigitCommander 74 Yahtzees

Profile icon
Bookie0
Profile icon
JSDRAGONCODER

This pretty cool! And i noticed if automatic and press random very very high number, it sort of like animation

Profile icon
Bookie0

lol thanks! @JSDRAGONCODER

Profile icon
LincolnMiddle
Profile icon
Bookie0

wow lol thats a lot! ;) @DSAEvan

Profile icon
Name12

to be honest, this is quite a simple code. but in compartment to your other posts, it's better. good job!

Profile icon
Bookie0

ok thanks! @Name12

Profile icon
Name12
Profile icon
[deleted]

So good! I really like this game. Good Job!

Profile icon
codeitfast

I rolled it 10 million times and got 466 yahtzees!

Profile icon
codeitfast

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".

Profile icon
Bookie0

ah ok, thanks for telling me ;) @codeitfast

Profile icon
codeitfast

@Bookie0 You're welcome. It doesn't really matter, tho

Profile icon
k9chelsea2
Profile icon
Bookie0

on how many rolls? @k9chelsea2

Profile icon
k9chelsea2

that was on the automatic roll thing and the number i did was one thousand

Profile icon
Bookie0

oh ok lol nice @k9chelsea2

Profile icon
k9chelsea2

i also inputted a massive number like 382473047028438- but after about an hour the program (or browser prolly teh latter) crashed

Profile icon
Bookie0
Profile icon
LTI2
Profile icon
Bookie0

lol well done ;) @LTI2

Profile icon
ChezTacoz

This game is 100% rigged

Profile icon
Bookie0
Profile icon
ChezTacoz

@Bookie0 I ran it for like an hour

Profile icon
Bookie0
Profile icon
ChezTacoz

@Bookie0 I have no life lol

Profile icon
Bookie0
Profile icon
SixBeeps

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.

Profile icon
Bookie0

@SixBeeps

Lmao yea so close 7777

Thanks :)

Profile icon
firefish

Just casually holding down my enter key for five minutes on normal mode
image

Profile icon
Bookie0

lmao nice! @firefish

Profile icon
firefish

@Bookie0 They were scrolling by really fast, had to stop and scroll up when I saw something green. Which probably wasn't the first one I got

Profile icon
Bookie0