Questions tagged [dice]

Simulations of fair N-sided die tosses and other games of chance involving random number generation.

Filter by
Sorted by
Tagged with
3
votes
1answer
5k views

Pig dice game with a human and a computer player

To help my son with his programming skills, I am trying refresh my limited Python knowledge. I chose a simple dice game called Pig Dice. ...
3
votes
2answers
550 views

Weighted dice with n faces

Here you find some code that returns the value of a multivariate Bernoulli density function - for a dice with n faces, where each face has its weight (weight must be positive reals, not necessarily ...
2
votes
0answers
301 views

Dice-rolling Android app

This is just a simple app. All it's suppose to do is move the dice around the screen when the user swipes up or down. It will move 2 dice (image drawables) to a position on the screen depending ...
4
votes
2answers
4k views

Simulation of 2 dice rolls

I wrote a program that records how many times 2 fair dice need to be rolled to match the probabilities for each result that we should expect. I think it works but I'm wondering if there's a more ...
4
votes
1answer
7k views

Java Dice Roller with GUI

Three days ago I wrote about a Java Dice Roller I wrote. I've now added a GUI to that program. Here it is: DiceRollerGUI.java: ...
5
votes
2answers
16k views

Java Dice Roller

I've written a basic dice program in Java which takes a number of faces then randomly selects a number within that boundary. Here is the code: ...
7
votes
3answers
1k views

“Dice on a Yacht” game

I wrote a small program to address some assignment tasks related to making a game called 'Dice on a Yacht'. I sent the code to be reviewed by a company I was applying for, and I have not gotten the ...
4
votes
2answers
2k views

C++ Int Array/Vector Over 100 Million

Textbook style program that generates the values of two, six-sided dice; which are used to perform simple calculations. Recently, I saw an example using similar criteria that was able to utilize 360,...
6
votes
2answers
3k views

Python dice class

I've built a simple dice class utility for rolling dice. It supports weighted rolling, and usage is fairly simple. Here's the code. ...
6
votes
6answers
5k views

Text-based dice rolling game in C++

I have made this small text-based dice rolling game in C++. How could I improve it? Be as picky as you'd like. ...
3
votes
3answers
562 views

Diceware Passphrase Generator

I've written a simple Diceware passphrase generator based on this Stack Overflow question and the top answer. Briefly, in the Diceware method, a die is rolled 5 times for each word in the passphrase ...
2
votes
1answer
706 views

Move through a basic roguelike text map

I have a basic outline for the best way I can come up with to move a character through a basic text map. I want to implement this module in my simple text RPG. I know there has to be a better way to ...
13
votes
4answers
27k views

Simple text RPG in Python

I am trying to teach myself to code using Python. The following is the first real program I have written from scratch. I feel that it is messy and in need of improvement, but I am either unsure of ...
6
votes
2answers
186 views

First dice roller

The part I'm really wondering about is in the "if, elif, else" part. I set the variable to bring up the raw input thing so it would stay there long enough to read instead of just printing a response ...
11
votes
2answers
4k views

D&D dice rolling app

This JavaScript object is part of a mobile application that rolls dice for our D&D games. Here are some example of possible inputs from the user: 2d4 2d4 + 3d6 2d4 + 3d6 + 12 ...
7
votes
6answers
361 views

A simple testable standalone DLL for die rolling

I've decided to challenge myself by writing a test standalone DLL with the objective of making all of its publicly-exposed objects able to be as intuitive and as simple-to-use as possible. I've ...
6
votes
1answer
827 views

10-faced dice-rolling game

My code is for a 10-faced dice-rolling game. There are 2 players who start off with 50 points, then they both roll a dice and get a random score between 1-10. The player with the highest roll gets the ...
10
votes
1answer
332 views

Simulate Random Risk Battle

For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle. ...
7
votes
5answers
2k views

Interactive dice simulator

After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions. ...
2
votes
1answer
260 views

Python Koans multiplayer Greed Game

I finished the Python Koans because I wanted to practise Python and I completed the extra assignment which is the Greed Game (see the rules here). I think there are no flaws but you never know. <...
3
votes
3answers
343 views

Python greed roll

I am doing the Python Koans to practise Python a bit more and I got to the greed dice project. It is a very simple dice game that scores a set of up to five rolls. These are the rules: ...
4
votes
1answer
139 views

Playing “craps” for the win v0.3

Continud from Playing “craps” for the win v0.2 You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots, respectively. After the dice have come to rest,...
2
votes
2answers
382 views

Playing “craps” for the win v0.2

Continued from Playing "craps" for the win You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots, respectively. After the dice have come ...
11
votes
2answers
2k views

Playing “craps” for the win

No specific question here. I am beginning with Java and here is an exercise. The rules of game: You roll two dice. Each die has six faces, which contain one, two, three, four, five and six spots, ...
2
votes
1answer
136 views

Greed in Ruby Koans

I've finished the greed problem in Ruby Koans after much confusion. This is my first programming language and I have been doing fine, but then this problem really tripped me up for some reason, ...
3
votes
1answer
276 views

Winforms Dice Control

This is my second Custom Control I have made, a dice. The code below has worked 100% in all my tests, program contains 1 dice control and seven buttons, 6 for setting a number directly, and one for ...
7
votes
4answers
4k views

Dice-rolling program

I am sort of new to programming. I would like to understand the code areas that are garbage and could be better written keeping the exact (if possible) behavior the code has now. ...
10
votes
5answers
2k views

Petals Around the Rose

I have been working on a program that walks you through "Petals Around the Rose". I would like anyone to review it and point out any bad coding practices, as well as efficiency problems. ...
8
votes
1answer
128 views

Dice Calculation Dialect

As a sample of dialects and teaching myself parse with block! values, I wrote the following dice dialect with the following ...
16
votes
5answers
21k views

Yahtzee game (using arrays and object classes)

As part of an assignment for my intro Java class (please bear with my beginner skill set), I'm working on a program for which a Die object class is used to play a Yahtzee game. An overview of the ...
4
votes
2answers
3k views

Number-guessing game in C++

I created a simple number-guessing game. Do I need to divide this program into functions? Please offer suggestions. ...
6
votes
3answers
203 views

Spin-the-bottle-like game, follow-up

I've posted this some time ago. Here is the new version that I made based on all the comments that were made. Another look would be much appreciated, especially on: Getting rid of the ...
26
votes
2answers
1k views

Spin-the-bottle-like game

I've started coding about 3 weeks ago, just for fun and maybe practical uses later. My GF dared me to make a PGM that would replace this dice game where you roll two dice, one with body parts and one ...
6
votes
1answer
144 views

RubyKoans: Greed dice scoring

The Greed game, from Ruby Koans, where you roll up to 5 dice: A set of three ones is 1000 points. A set of three numbers (other than ones) is worth 100 times the number. A one (that is not part of a ...
5
votes
4answers
658 views

Optimized solution for a rolling dice code puzzle

I was asked to provide the solution of this rolling dice problem in an interview. When I showed him my solution, he said that there is another way to find the solution. I am looking for answer in PHP ...
11
votes
2answers
22k views

Dice-rolling simulator

I know there is a better way to store data. What is the most concise way to simplify this script? ...
4
votes
1answer
2k views

Dice game in Python

Could this script be shortened? ...
11
votes
2answers
853 views

Simple dice roll using std::string as dice notation

This will be a function that returns a random number from Dice Notation (more on Wikipedia). I will later use this function to determine whether some skill check is passed or not. Is there any need ...
3
votes
1answer
1k views

Dice notation roller in JavaScript

I have the following function, intended to take standard dice notation (XdY+Z) and return a (sort of) random number based on the input. Are there any bugs/bad ideas/optimizable sections I am missing? ...
15
votes
5answers
44k views

Basic Java dice game

...
4
votes
3answers
7k views

Yahtzee game in C++

I am doing a little in-between semester reading in my C++ book, and I came up with the wonderful idea to try to make Yahtzee in C++. So far the code generates 5 random numbers and then calls the ...
5
votes
2answers
5k views

Roll a die according to the number of sides that the user enters

I have created a program which rolls a die according to the number of sides that the user enters: ...
21
votes
4answers
2k views

Possible improvements to Risk board game?

Enter risk! This program will roll dice for the game of Risk. The initial input is two numbers separated by a space and if the attackers wish to do a blitz they can add one more space and an "!&...
1
vote
3answers
2k views

Modeling a pair of dice using composition in C++

I've written a program all by myself, but I just want to make sure I did it right and if anybody has any suggestions on improving it in any way. Define and implement the ...
7
votes
3answers
2k views

Dice game rules implementation

My in-laws taught me a dice game a couple years ago, and we play every once in a while. A recent excellent answer from @radarbob inspired me to proceed with translating the rules of that dice game ...
11
votes
3answers
5k views

WinForms dice roller

I am writing a dice roller winforms application using C# 2012 VS. Dice roller is set up for playing Shadowrun tabletop. I feel that there might be too much code going into the GUI, but I am unsure ...
11
votes
5answers
31k views

Simple Dice Roll game

Is there a more efficient algorithm to generate random numbers in C++? (This code is working on Dev-C++, but I'm not sure if it works on a Borland compiler.) ...
7
votes
3answers
2k views

Random number generation in Dice class

I don't intend on implementing this into an application yet as I'm going to test it first. As such, it doesn't do much beyond rolling. It also overloads some "typical" operators such as ...
11
votes
3answers
6k views

Craps game rules and code

I'm developing a small craps game in C++, and my C++ skills are a bit rusty. I really need someone to review my code to ensure that I have correctly implemented the game according to the rules. ...
4
votes
1answer
461 views

Yahtzee program

How can I refactor this? ...