Simulations of fair N-sided die tosses and other games of chance involving random number generation.
5
votes
3answers
90 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
52 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 ...
2
votes
2answers
87 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
823 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 ...
5
votes
2answers
50 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
53 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?
...
8
votes
1answer
81 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:
...
14
votes
4answers
897 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 ...
4
votes
1answer
73 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 ...
3
votes
2answers
52 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
113 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
45 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
44 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
443 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
365 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
914 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
370 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
314 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 ...
6
votes
2answers
169 views
Simple 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
396 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
118 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
87 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 ...
11
votes
4answers
2k 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
72 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 ...
10
votes
2answers
993 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
226 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
322 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 ...
9
votes
1answer
171 views
Simulate Random Risk Battle
For Prof. Yorgey's 2013 Haskell course, I'm working on a homework to simulate a Risk battle.
...
6
votes
5answers
799 views
Interactive dice simulator
After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions.
...
1
vote
1answer
123 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.
...
2
votes
3answers
130 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
74 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 ...
2
votes
2answers
245 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 ...
10
votes
2answers
894 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 ...
2
votes
1answer
58 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
140 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
2k 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
1k 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.
...
7
votes
1answer
75 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 ...
14
votes
5answers
7k 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
2k 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.
...
5
votes
3answers
171 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 ...
19
votes
2answers
598 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
59 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 ...
3
votes
1answer
223 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
9k 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
930 views
11
votes
2answers
513 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
313 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?
...
14
votes
5answers
19k views