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
5
votes
1answer
260 views

Simple game in C++ involving a dice and bolts

I have been working on a simple game in c++. the game consists of a dice and several players. the number of players may very between 1-4 and as long as each of them has 2-4 bolts. singleton ...
1
vote
2answers
289 views

Dice roll game that generates random number

I just want to know how efficient is my code and is there any better way to do the same program in C? Can the if statements are replaced with something else or can I merge the two loops together to ...
3
votes
2answers
2k views

Simple dice console game in C#

I wrote a little console game that is supposed to take some dice and some players and determine the winner of the game. I wrote it for the sole purpose of figuring out why i'm doing the things i'm ...
22
votes
6answers
25k views

Simple text-based RPG in Java

I was looking for suggestions on how to improve the general flow of this code, as well as minimizing if / switch conditionals. ...
1
vote
1answer
582 views

Computing the probability of rolling a given total with five dice

I'm trying to compute the probability of rolling a certain dice total with an unknown number of dice. Below is a brute force example for 5 dice, hence the 5 loops. I feel like there is a recursive ...
1
vote
1answer
66 views

Exurbb (automated turn based) Battle Simulator Revised

I have revised my other question's code which you can find a link to here. This is just an automated turn based battle simulator which means everything comes out about 1 second at a time, and player ...
4
votes
1answer
246 views

Exurbb (automated turn based) Battle Simulator

I have created a semi-medium program (in size) to simulate any battle for all of your battling needs! I would like some feedback on how it is (not to great at programming in c++) or you can just put ...
5
votes
1answer
2k views

Python - Random dice

I am a fairly new programmer, and I stumbled with a beginner practice project, a random dice number generator. The code works, but I would like to know if there is an efficient way compared to mine to ...
7
votes
1answer
140 views

Random Dice Simulation

I extended the example in 04-random.elm to support N dice and to draw the results using SVG. ...
4
votes
0answers
67 views

Evaluating RPG-formatted dice rolls with repeats in Clojure

My target was to write a function that takes a String as input, interprets it as a series of dice rolls, evaluates it and returns a series of integers. The input is in a form that is typical in table ...
7
votes
1answer
416 views

Python dice game: C Low (Special Edition)

I am a Python noob and over the last week it has been my goal to learn how to write python code. As my first project I decided to create a dice game called C low. This is a version of that game that ...
7
votes
3answers
1k views

Find the total number of ways W, in which a sum S can be reached in N throws of a dice

I was solving this question: Given there is a 6 sided dice. Find the total number of ways W, in which a sum S can be reached in N throws. Example: S = 1, N = 6 => W = 0 S = 6, N = 6 => W ...
3
votes
1answer
484 views

Winning strategy for the dice pig game

I am writing a computer opponent in java to play the dice game pig. I am trying to code it to be optimized based off of this paper. ...
3
votes
2answers
689 views

Real time graph simulation of dice tossing

When tossing a dice many many time all numbers tend to appear the same number of times, but if the number of throws is small then some numbers may appear more or less often than others, even ...
6
votes
1answer
373 views

Unfair die game

For this task, you're going to play a dice game, but first you must prepare for an overwhelming victory. The game itself is very simple. Both players roll a single die and whoever rolls highest ...
6
votes
2answers
482 views

Working Craps program

How can I make this better? ...
2
votes
1answer
672 views

Compute the probabilities of getting each of the possible sums when throwing 2 dice, n times

I'm struggling with some coding-inexperience. The code I've written below, is extremely inconvenient and ugly to look at. My question to you is: How can this be done more efficiently? The way I've ...
5
votes
2answers
16k views

Dice Roll Program in C

I've made a dice game that rolls three die, calculates the sum of their results, and asks the user whether he/she thinks the next roll's total will be higher, the same, or lower than the current roll. ...
5
votes
1answer
1k views

Simple Version of Bunco Game

Any idea to write this code (fixable part) smarter? Note: Arrays, pointers, global value are not allowed to use. The game is played with 6 rounds. At the beginning, each player rolls one dice, with ...
4
votes
1answer
2k views

A dice roller in node.js

I knocked out a dice roller in 2 days. I think this is the first coding project I've ever actually completed to a degree where I'm not embarrassed to post it. This is my first time working with ...
5
votes
1answer
889 views

PigDice game in C#

In the C# Player's Guide book there's a challenge in which you have to write the PigDice game in C#: It's a multiplayer game, every player starts with score 0. Player X rolls 2 dice. Player ...
5
votes
1answer
3k views

Dice simulation and counting pairs

This is my first time putting a code together for Java based on my own so i was hoping if you someone would be kind enough to review and provide feedback or constructive criticism on this code. The ...
7
votes
2answers
890 views

Dice roller in Python

I'm trying to get better in Python and decided to rewrite my dice roller in Perl into Python. ...
64
votes
3answers
16k views

Monopoly simulator

I was advised by a Reddit user to get my code reviewed on this site. The complete code is on GitHub. ...
2
votes
1answer
200 views

Pen-and-Paper Dice Roller Tool

A friend asked me to write a pen-and-paper dice roller, so I put this together. I'm still pretty new to Java Swing, so I was hoping I could have some advice on how I handled the layouts and everything,...
5
votes
1answer
3k views

Dice-throwing game

I'm a beginner trying to create a dice game according to the specification given below. This is an improved version of my program based on the feedback given by users on my original question. Again, ...
6
votes
3answers
20k views

simple two players dice throwing game

I'm a first year uni student. We were asked to come up with code that can represent a simple two players dice throwing game (specifications are given below). I know as a matter of fact that there ...
3
votes
0answers
363 views

Ship capt crew dice game

I built this game that I used to play at family get-togethers. I am still working on the final implementation of how to actually play someone in the game. Please critique the main logic of the dice ...
5
votes
1answer
3k views

Dice roll program with statistics

This is a working program I made to roll dice a specified number of times, show how many times each number (2-12) occurred, and the percentage of the total rolls that each number got. I'm trying to ...
2
votes
2answers
2k views

Beginning C# dice game

I've been learning C# for about a month and have a finished game. I would like some constructive feedback on my progress so far. ...
2
votes
1answer
2k views

Player vs computer dice game

This is a dice game where, if you try to get as close as 24 without going over, you are allowed to "hit" three times. If you decide hit, you have the option of rolling one or two more dice. Player and ...
1
vote
2answers
3k views

Beginning dice game

This is my first dice game and I have spent countless hours working on it, yet it is still very basic. I was wondering if anyone could spare the time to suggest improvements. ...
6
votes
3answers
240 views

Simulation for rolling dice in X-Wing

I've recently started playing the X-Wing Miniature game, and there is quite some math behind some of the dice rolls, as they are affected by many abilities and so on. Manually calculating these is ...
4
votes
2answers
187 views

Functional translation of dice simulation

I have tried my hands at "functionalising" a toy problem I had: find the expected number of throws of a six sided die until all sides have been seen (the answer is 14.7) My starting point is my ...
1
vote
2answers
563 views

Java rolling dice + csv array output

I have made a program to take x number of die and rolls them y number of times, then stores the data into an array so that I may output a CSV file. Everything works as intended, but I am having ...
10
votes
4answers
3k views

Generate set of random numbers and remove lowest

I'm learning some Python with my kids, and we're making a program to generate D & D characters from user input. One portion of the code is to generate stats, which are a set of six numbers where ...
8
votes
2answers
2k views

Scoring solution for Farkle (dice game)?

I've written the following function on Python (3.3) to take a list of 6 integers and return the maximum score for a game of Farkle. While the results are correct I don't feel it's a very Pythonic ...
4
votes
2answers
1k views

Dice-rolling Python script

I completed writing a dice roll script in Python but I thought it looked too messy. Is there anything I should change here? ...
9
votes
1answer
587 views

My first Haskell: dice rolling

Yesterday morning I decided to stop procrastinating and start learning me some Haskell. So far I've made this, which is a simple cli 'dice rolling' utility that can be used like: ...
18
votes
4answers
3k views

Printing all possible sums of two n-sided dice rolls

For my CS class, we were tasked with writing a program that calculates all the possible results from rolling two n-sided dice. For example, the input of 4 would ...
5
votes
1answer
1k views

Pretty print dice faces from multiple rolls of multi-sided dices

In this question related to rolling multiple dices, the OP pretty prints for a single case where number of dices is less than or equal to 6. This led to me finding this code golf on "Draw dice result ...
4
votes
2answers
318 views

Script to determine the outcome(s) of any number of dice rolls

I think this code has far to many if else clauses and not enough abstraction via functions. I would like to break the code down into a series of small functions, or methods if i decide to go OOP, but ...
3
votes
1answer
4k 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
445 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
297 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
6k 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
14k 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,...