Probability – What is the optimal amount of dice to roll a yahtzee in a throw?

In Yahtzee game, 5 dice are rolled to get a score. One of the resulting roles is called Yahtzee.

To roll a Yahtzee, you must have 5 of a kind. (5 1’s or 5 2’s or 5 3’s etc.).

In Yahtzee game, you can only have 5 dice. However, for the purpose of this question, I would like to add more cubes to the equation. Therefore I would like to define a Yahtzee as follows:

To roll a yahtzee, you must have exactly 5 of a kind, no more or no less. (5 1’s or 5 2’s or 5 3’s etc.).

For example, the following 6 dice rolls would be a Yahtzee:

1 1 1 1 1 4

6 3 3 3 3 3

The following throws with 6 dice would not be a yahtzee:

1 1 1 3 3 3

1 1 1 1 5 3

1 1 1 1 1 1

Note that the last roll contains 5 ones technically. However, since the entire throw contains 6 ones, it is not a Yahtzee.

This leads to the question in the title of this article.

What is the optimal amount of dice to roll a yahtzee in a throw?

A more general form of the question is as follows: What is the probability with n dice to throw a yahtzee of length y in a throw?

dnd 5e – Mechanical effects of a long pause in restoring all hit dice

Are there mechanical consequences, apart from the fact that players can heal more during a short break in order to be able to restore all hit dice per long break?

We recently lost our cleric, so I introduced the Healing Wave so they could spend hit dice as an action in combat to heal themselves. It is used more often than they have rested before, but they are a bit of a hassle because they only recover so much during a long break. (Currently level 6).

Dice – Why do most people consider a "00" and a "0" on a percentile roll to be 100?

Assuming the results of a percentile roll range from 1 to 100, why would the results of a "00" and "0" roll read as "100"?

In any other context outside of a percentile cube, the "0" on a d10 is interpreted as "10". In addition, the "00" is read as "0" in every second role of the d100. But especially for "00" and "0" there is a "100".

This means that the possible results of a "00" throw with any d10 throw are 1, 2, 3, 4, 5, 6, 7, 8, 9 and 100,

This raises an additional question as to why a "0" on a d10 is treated as "0" in the context of a percentile cube.

Is this easy to make reading the percentile roll easier, or just to make it so that a 100 does not require unsightly "90" and "0" instead of the more visually appealing "00" and "0"?

BBC Code Dice Roller in PHP

I don't program PHP too often. I wanted to write a dice roller BBC code parser for my forum. What do you see that can be improved?

You can see the code live here:


  • Basic Rolls: NdM: Roll N dice with M sides. i.e. 3d20 rolls three twenty sided dice.
  • Add Modifiers: 1d20+1 or 1d20-5: Add (or subtract) the indicated amount from the roll
  • Reroll Low Results: 1d20r3: Roll 1d20, but keep re-rolling if the result is 3 or lower.
  • Keep Highest Rolls: 4d6^3: Roll 4d6, but keep only the 3 highest results, discarding the remainder.
  • Keep Lowest Rolls: 4d6v3: Roll 4d6, but keep only the 3 lowest results, discarding the remainder.
  • Note: You cannot have ^ and v in the same roll -- 3d6^1v1 is invalid.
  • Compound Rolls are OK: 3d6-2d6-5+3: Roll 3d6, subtract 2d6, subtract 5, add 3
  • Whitespace is ignored: 1 d 6 and 1d6 are the same thing. '1 d 2 0' will work too, all white space is completely ignored
  • Syntax Errors Any syntax errors cause the entire roll to be considered invalid.


"; } ?> = 2 && $capture(1)) ? $capture(1) : 0; preg_match('/v(d+)/', $rollToken, $capture); $keepLowCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; preg_match('/^(d+)/', $rollToken, $capture); $keepHighCount = (sizeof($capture) >= 2 && $capture(1)) ? $capture(1) : 0; $detailText .= (empty($detailText) ? "" : "
") . "" . ($rollSign == -1 ? "-" : "") . "$rollToken Results: "; $subTotal = 0; $rollResults = array(); if ($rerollThreshold >= $diceType) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } for ($k = 0; $k < $numberOfDice; $k++) { array_push ($rollResults, rand($rerollThreshold+1, $diceType)); } if ($keepHighCount > 0 || $keepLowCount > 0) { if ($keepHighCount > 0) { $keepCount = $keepHighCount; $selectorFunction = "max"; } else { $keepCount = $keepLowCount; $selectorFunction = "min"; } if ($keepCount > $numberOfDice) { $detailText = $INVALID_ROLL_ERROR; break; //Future note: This should break out of the big foreach ($rollTokens) loop } $keep = array(); $discard = array(); foreach ($rollResults as $key => $val) { $discard($key) = $val; } for ($k = 0; $k < $keepCount; $k++) { $highest = call_user_func($selectorFunction, $discard); $highestIndex = array_search($highest, $discard); array_push($keep, $highest); unset($discard($highestIndex)); } foreach ($rollResults as $roll) { $keepIndex = array_search($roll, $keep); $discardIndex = array_search($roll, $discard); if ($keepIndex !== False) { $detailText .= "$roll "; $subTotal += $roll; unset($keep($keepIndex)); } else { $detailText .= "$roll "; unset($discard($discardIndex)); } } } else { foreach ($rollResults as $rollResult) { $detailText .= "$rollResult "; $subTotal += $rollResult; } } $subTotal *= $rollSign; $detailText .= " (Total = $subTotal)"; $rollTotal += $subTotal; } } } else { $detailText = $INVALID_ROLL_ERROR; $rollTotal = "0"; } $detailText .= "
Total: " . $rollTotal; $detailText = "Dice Roll: " . $inputClean . "
$detailText"; return array('input'=>$inputText, 'total'=>$rollTotal, 'detailText'=>$detailText); } ?>

dnd 5e – Do monsters get maximum HP when they get hit dice?

From introduction to Monster Manual for hit points (p. 7):

The hit points of a monster are shown both as a cube expression and as an average number. (…)

A monster's constitution modifier also affects the number of its hit points. Its constitution modifier is multiplied by the number of its hit cubes and the result is added to its hit points.

Hit dice and the actual hit points are therefore two identical expressions. When the creature receives hit cubes, it also increases the maximum number of hit points.

For the specific example, the Nabassu function (highlighting mine) contains:

Roll the dice and increase The hit points of the Nabassu were rolled by numbers.

This gives an explicit explanation of how the new hit cubes affect the number of hit points. Note that "increase" is displayed and not that hit points are restored. This means that the number of hit points should be increased, regardless of whether hit points were previously lost.

Unit – Check which player has the highest number of dice

I am playing a Ludo game and at the moment I have to check which player has the highest number of dice and the player who has the highest number goes to the starting position. I have currently created this method to check which player has the highest number. The player with the highest numbers executes the MovePlayer () method.

public void FirstTurn(){
    player1Steps = GameObject.Find("Player1").GetComponent().randomNumberSteps;
    player2Steps = GameObject.Find("Player2").GetComponent().randomNumberSteps;

    if(NetworkManager.MyGamePlayerId == "Player1" && player2Played == true)
    } else if(NetworkManager.MyGamePlayerId == "Player2" && player1Played == true)
        if(player2Steps > player1Steps)

I am using the Photon Cloud Service as this is a multiplayer game
Many thanks

Performance – frequency analysis for simultaneous dice rolls

My professor told me to tweak my Perl code, but he would not tell me exactly what – just do it.

I changed a few things, but nothing big. Do I miss something?

The task was:

Perl program that allows the user to simulate the Simultaneous
throw several dice. The simulation result is then a sum
Number of points resulting from the sum of the numbers
in individual litters. When many of these throws are performed with multiple ones
Dice is the frequency distribution for the total number of eyes
calculated. This frequency distribution should be in the console
Window in the form of a table and as a simple summary table.

At the beginning the following entries should be requested from the

  • the number of dice he wants to roll.
  • The number of throws he wants to make with the selected number of dice.

The frequency distribution for the total number of eye sets should be
displayed in two different ways:

  • Tabular representation as a comparison of the number of points obtained and the associated frequency, both absolute values ​​of
    the frequency and the normalized values ​​leading to the division
    the absolute values ​​that result from the total number of throws are
  • Graphical representation as a simple bar chart (inclined by 90 degrees) (eg corresponding number of *)

Use subroutines.

use warnings;                   
use diagnostics;                
use GD::Graph::hbars;        
use GD;
use List::Util qw(max);
my $number_of_dice = 0;   
my $number_of_rolls  = 0;     
my $sum_of_throw = 0;     
my @total_sum_of_eyes;       
my @single_sum_of_eyes;   
my @frequency;            
my %count;                   
my $count =0;                 
my $number =0;                

print "n Please insert the number_of_dice: ";   
print "n Please instert the number_of_rolls: ";

while ($count< $number_of_rolls) {                  
representation ();

sub roll{ 
    $sum_of_throw = 0;
    for($i = 0; $i< $number_of_dice; $i++)      
        $number = int(rand(6) +1);                  

sub frequency{
    foreach my $eyes(sort{$a <=> $b} @total_sum_of_eyes){                       
sub representation{
    #Tabular representation
    print "n the frequencys-distribution is: n";
    print "n total_sum_of_eyest frequencyt frequencys-distribution in %n";
    foreach my $eyes (sort{$a <=> $b} keys %count){         
        push(@frequency, $count{$eyes});                #data for the bar chart     
        push(@single_sum_of_eyes, $eyes);               #data for the bar chart         
        printf "nt $eyesttt  $count{$eyes}tt%g",($count{$eyes}/$number_of_rolls)*100;
    print "n";
    #bar chart
    my $graph = GD::Graph::hbars->new(1600, 600);       
    x_label             => 'total_sum_of_eyes',         
    y_label             => 'frequency',             
    title               => 'frequencys-distribution',   
    y_max_value         =>  max(@frequency)+1,          
    y_min_value         =>  0,                          
    y_tick_number       => 8,                           
    transparent         => 0,                           
    bgclr               => 'white',                     
    long_ticks          => 1,                           
) or die $graph->error;                                 
my @data = (@single_sum_of_eyes,@frequency);      
$graph->set( dclrs => ( qw(green) ) );   
my $gd = $graph->plot(@data) or die $graph->error;  
open(IMG, '>gd_bars.gif') or die $!;
binmode IMG;
print IMG $gd->gif;

What should I do if I suspect that a player uses weighted dice?

Ask if you can keep his dice between game sessions, and test them yourself to see if he agrees, or lend him a set of dice to use while playing at your table.

You can test whether a dice set is weighted for a particular outcome by using the test given in this question. It will take a bit of Epsom salts and a few hours of time, but if you're ready, the test can pretty easily determine a die bias (as long as it's not a D4 anyway).

This method does NOT determine certain types of solid cubes, such as: For example, shaved surfaces (where one side of the cube is scraped off so that the cube is not a perfect cube and causes a side-to-side imbalance due to its more rectangular shape). shaved angles (with certain angles larger than others, causing the cube to land more frequently on the sides with the largest surface area), and cube with liquid metal cores such as gallium (which become fluid when heated in an oven) are not detected when the metal core solidifies again This can lead to the matrix being weighted towards a specific result.

Dice are determined that have a false weight due to air bubbles inside the cube, or denser sections of the cube that cool as part of the manufacturing process. Most unclear cubes made by Chessex fall into this category. Find out more in the question / answer above.

If he agrees to leave his dice for you to test

Test them. Determine your bias and write down your results thoroughly. If it turns out that all the dice are weighted towards high numbers, it may not be his own fault. He could have just bought some badly balanced dice over Chessex. Explain to him that there are only a few dice that are perfect, and keep part of the Epsom solution so you can show him how the dice were tested.

If he does not agree and refuses to use other dice

There is a clear possibility that he knows about their prejudices or has bought the deliberately weighted dice. This is the most likely scenario that indicates a possible guilt to prove that he lies to you, but his refusal to use dice that you think is fair may suggest that he deliberately manipulates you at your table and generally does not fit very well into the social contract of most dungeon and dragon groups.

If this is the case, tell him you will exclude him from the group if he does not let you test his dice until he either uses a set of dice that you yourself have tested as balanced or that is allowed to roll his dice test to determine their inclination.

It's not fair to allow your teammates to cheat at your table, and if your dice are actually weighted in a way that would be fair, it could negatively affect the playing experience of everyone else at the table. No one likes a Mary Sue like no one likes a scammer.

There's a chance he'll play the badge and try to get you to stay, even if that happens. Probably like, "You do not have any proof that you're throwing me off your table, that's not fair to me."

If they offer such a counter argument, just tell them that he acts in a way that confirms his guilt, and that if he had nothing to hide, he would have allowed his dice to be tested, or just a cool guy and For the rest of the games, use another player's dice.

If he does not agree with her tests but uses other dice

Probably the simplest scenario that honestly requires neither science nor thorough testing of the dice. If he uses only other cubes, the potentially charged cube is completely removed from the equation, resulting in a completely diffuse situation. No more bad dice = no ridiculous buns anymore.

dnd 5e – Shadow Blade, Overchannel and Sneak Attack Dice

When a Level 14 Evocations wizard with 3 Rogue levels applies his overchannel ability to a 5th level Shadowblade spell and lands an attack on a creature causing 4W8 + Skill Modifier + 2W6 Sneak Attack damage.

Because the Sneak Attack is considered "extra damage" (taking into account all the damage characteristics the Shadowblade possesses), is it also maximized by Overchannel?

Does Overchannel fix the shadowblade damage?

My first impression is to both, but I could overlook something.