Questions tagged [dice]

Dice are small objects thrown by hand that land in different positions, used to generate random value for games, particularly gambling.

A die (plural dice) is a small object (most commonly a cube) designed to be thrown onto a surface. Markings on the face of the die chosen by how it lands indicate a value that is thereby chosen randomly. Dice have been used for centuries--even longer than playing cards--for gambling and other games.

882 questions
3
votes
2 answers

How to calculate the sum of dice whose value combined amounts to an input number

I am supposed to do a score calculator in Java for a dice game that rolls 6 dice (with 6 faces). The score is supposed to be calculated according to a list of options that the user has available. Options are 4,5,...,12. For choice "4", all…
J.Dow
  • 103
  • 9
3
votes
4 answers

How to calculate the probability of getting the sum X using N six-sided dice

The Challenge: For example, what is the probability of getting the sum of 15 when using 3 six-sided dice. This can be for example by getting 5-5-5 or 6-6-3 or 3-6-6 or many more options. A brute force solution for 2 dice - with complexity of…
riorio
  • 6,500
  • 7
  • 47
  • 100
3
votes
1 answer

computing the maximum point-wise distance of both CDFs

I have 2 CDF and have to find the maximum pointwise distance. I created histograms and plotted both. The values are generated by a random function which takes the sum of two random numbers 1-6 for 100 times, similar to two dice. But, I can't manage…
3
votes
3 answers

Making a multiple random dice roller that shows a picture of the dice. Why doesn't my code work?

Trying to make it roll multiple dice and show pictures of dice function rollDice() { var numDice = document.getElementById("diceNum").value; var container = document.getElementById("dieContainer"); container.innerHTML = ""; for…
Flufsi
  • 51
  • 3
3
votes
3 answers

program to Roll a dice with picture instead number using javascript

I am trying to print out images on the dice, instead of just the number. But when i am using document.write, it just opens a new tab, and shows the picture. What should i use to print it out, with the button i have?
KX0
  • 99
  • 1
  • 3
  • 10
3
votes
4 answers

Python program that simulates rolling a 6 sided die and adds up the result of each roll till you roll a 1

so this is the code I wrote that attempts to answer the question in the title : import random print("Well, hello there.") while True: a = random.randint(1,6) sum = 0 if(a==1): #If a one is indeed rolled, it just shows rolled a 1 and…
ggezpython3
  • 53
  • 2
  • 12
3
votes
3 answers

Need to output the top 3 outcomes of rolling 2 dice, which have a variable number of sides

The following code computes the probability distribution of outcomes of rolling two dice with a variable number of equal sides: def compute_probability_distribution(sides): dist = {x+y: 0 for x in range(1, sides+1) for y in range(1, sides+1)} …
CElliott
  • 151
  • 4
3
votes
4 answers

How do I ask if the user would like to continue the game after each dice roll in java using netbeans?

I need help with this question: A dice rolling game is played with two six-sided dice. A user playing the game, will roll the two dice and two random numbers between one and six will be generated. The sum of the two numbers will be used to decide…
Bec
  • 59
  • 1
  • 8
3
votes
6 answers

Is it possible to remove a part of a function? (i.e. a specific variable when a condition is met)

I'm trying to create a simple dice game using JavaScript. I want to simulate a Yahtzee game with 5 dice, and after each dice roll, every dice showing 6 should be put aside and the code should roll the remaining dice until all dice are put aside.…
Mathias
  • 33
  • 6
3
votes
3 answers

probability of T total eyes when throwing N dice with S sides

I want to calculate the probability of the event that the sum of all eyes of n dice with s sides (numbered from 1 to s) is equal to t. My language is Python 3. My current approach is pretty much a try-and-count solution and only works for small…
Byte Commander
  • 6,506
  • 6
  • 44
  • 71
3
votes
1 answer

Freezing dice rolled?

I am creating a game along the lines of Yahtzee the dice rolling game. I have to give the user 5 dice rolled, and ask them a 5 digit number of which dice they'd like to re-roll. For example: Your roll is: 5 1 5 5 1 Which dice should I roll again?:…
D. Leigh
  • 53
  • 4
3
votes
3 answers

recursion resulting in extra unwanted data

I'm writing a module to handle dice rolling. Given x die of y sides, I'm trying to come up with a list of all potential roll combinations. This code assumes 3 die, each with 3 sides labeled 1, 2, and 3. (I realize I'm using "magic numbers" but…
user360648
  • 33
  • 4
3
votes
3 answers

Dice Sum Probability with Different types of Dice

I am currently working on a java application where I need to calculate the probabilities of rolling each sum for a variety of dice. The dice types I am supporting are d4 (4 sided dice), d6 (6 sided dice), d8 (8 sided dice), d10, d12, and d20. The…
Andrew
  • 902
  • 1
  • 11
  • 28
3
votes
1 answer

Number of Dice rolling till reaches a Stop Value

I am trying to count the number of dice rolls till it reaches to a definite stop value. For example, I want the stop value as 100. I am writing the following code: sumofsides <- function(stopvalue) { totalsum <- 0 while (totalsum < stopvalue) { …
S Das
  • 3,291
  • 6
  • 26
  • 41
3
votes
3 answers

looping in unit test bad?

I have a unit test that relies on a random dice roll. I roll a 20 sided die and if the value is 20 it counts as a critical hit. What I'm doing right now is rolling the 20 sided die up to 300 times. If any one of those rolls is a 20 then I know I had…
mikedev
  • 733
  • 9
  • 16
1 2
3
58 59