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
21
votes
14 answers

Evaluate dice rolling notation strings

Rules Write a function that accepts string as a parameter, returning evaluated value of expression in dice notation, including addition and multiplication. To clear the things up, here comes EBNF definition of legal expressions: roll ::= [positive…
samuil
  • 5,001
  • 1
  • 37
  • 44
13
votes
4 answers

Parsing dice expressions (e.g. 3d6+5) in C#: where to start?

So I want to be able to parse, and evaluate, "dice expressions" in C#. A dice expression is defined like so: := + | - | []d(|%) | := positive…
Domenic
  • 110,262
  • 41
  • 219
  • 271
10
votes
3 answers

Dice odds: Simulating a game of Craps

My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I plan on bringing $200 again for this trip and…
Kevin
  • 3,771
  • 2
  • 31
  • 40
9
votes
2 answers

How can I generate "Go First" Dice for N dice?

Background As described here http://www.ericharshbarger.org/dice/#gofirst_4d12, "Go First" Dice is a set of four dice, each with unique numbering, so that: Any roll of two or more dice will never result in a tie. Any die rolled against any other…
anonymous coward
  • 12,594
  • 13
  • 55
  • 97
8
votes
7 answers

Double dice graphics in Python

I'm new to programming and in my project, I'm trying to print basic dice graphics. I'm trying to make a function that accepts two numbers from 1 to 6, and prints corresponding two dice faces next to each other. I've tried several approaches, but…
7
votes
2 answers

dice roll math with large n (>100)

I promise this is not just another dice rolling homework problem. I implemented a function to calculate the probability of obtaining less than a sum s when rolling n m-sided dice. My function works for small values of n but I am finding weird…
Lief Esbenshade
  • 793
  • 4
  • 13
7
votes
7 answers

Roll a dice via e-mail

I have been asked this question, but failed to find an article that describe a good method. Instead I came out with my own method (see my answer below). However it is also possible that I merely came up with a method I am not smart enough to break.…
Chen Levy
  • 15,438
  • 17
  • 74
  • 92
7
votes
2 answers

Generate a matrix of all possible outcomes for throwing n dice (ignoring order)

In cases where order does matter, it's rather easy to generate the matrix of all possible outcomes. One way for doing this is using expand.grid as shown here. What if it doesn't? If I'm right, the number of possible combinations is…
Brani
  • 6,454
  • 15
  • 46
  • 49
6
votes
1 answer

Expand random range of integers using probability distribution

I tried to solve the classic problem of generating a random integer between 1 and 7, given a function that generates a random integer between 1 and 5. My approach was to add the result of 2 calls to rand5(), effectively turning this into a "sum of…
The Bic Pen
  • 773
  • 6
  • 21
6
votes
9 answers

Determine Frequency of numbers showing up in dice rolls

For a game I'm trying to determine the frequency that a certain # will show up at a given # of dice being rolled. I know... that question seems odd. Let me try to explain it with real numbers. So, for 1 die, the frequency for each number will be…
bugfixr
  • 7,997
  • 18
  • 91
  • 144
6
votes
2 answers

Project Euler 240: number of ways to roll dice

I 'm trying to solve Project Euler problem 240: In how many ways can twenty 12-sided dice (sides numbered 1 to 12) be rolled so that the top ten sum to 70? I've come up with code to solve this. But it really takes a lot of time to compute. I know…
deeshank
  • 4,286
  • 4
  • 26
  • 32
5
votes
1 answer

Creating a visual dice roller with T-SQL (just for fun)

Just for fun, I wanted to create a visual dice roller using SQL (I know that this is hardly what the language is designed for). I've come up with the code below, which will roll as many dice as you like (@Dice) and show a visual representation of…
Simmo33
  • 73
  • 1
  • 7
5
votes
3 answers

Random numbers for dice game

Possible Duplicate: random string generation - two generated one after another give same results I am writing a simple dice game for windows phone 7, that involves rolling two dice at the same time. Here is my Dice Roll Code: private int…
BigPete
  • 779
  • 2
  • 9
  • 21
5
votes
2 answers

Calculate probability of a fair dice roll (in non-exponential time)

Variations on this are pretty common questions, but all my google-fu has left me stumped. I would like to calculate the odds of a fair dice roll, but I want to do it efficiently. There are lots of examples out there of how to do this, but all the…
5
votes
3 answers

From 5 dice rolls, generate a random number in the range [1 - 100]

I was going through some coding exercises, and had some trouble with this question: From 5 dice (6-sided) rolls, generate a random number in the range [1 - 100]. I implemented the following method, but the returned number is not random (called the…
yohm
  • 452
  • 7
  • 14
1
2 3
58 59