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
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. ...
24
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 ...
22
votes
2answers
3k views

Ruby Koans' Greed Task

Having coded in Java and C# for quite some years, I'm currently learning Ruby. I'm working my way through the Ruby Koans tutorial. At some point, you are to implement a method that calculates the game-...
21
votes
6answers
26k 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. ...
20
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 "!" to ...
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 ...
16
votes
5answers
20k 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 ...
15
votes
5answers
41k views

Basic Java dice game

...
13
votes
4answers
23k 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 ...
12
votes
2answers
2k views

Random D20 number generator

I'm teaching myself code using Zed Shaw's Learn Python The Hard Way, and I got bored during one of the memorization lessons so I thought I would make a random D20 number generator for when I play RPGS....
11
votes
5answers
30k 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.) ...
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
2answers
21k views

Dice-rolling simulator

I know there is a better way to store data. What is the most concise way to simplify this script? ...
11
votes
2answers
3k views

2 player dice game with login system

This is a two player dice game where two players each roll two dice. If a player's dice sum is even, they gain 10 points. If the dice total is odd, they lose 5 points. ...
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. ...
11
votes
2answers
2k views

Dice simulator program

I recently began to dabble into the programming world and wrote a Dice Simulator Program. How do I know that I'm writing Good Code? In the sense, is it something similar to how a major Software ...
11
votes
2answers
827 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 ...
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 ...
11
votes
1answer
218 views

Ten Thousand: a dice game for multiple players - follow-up

I've implemented the advice given here and elsewhere as best as I understand: Ten Thousand: a dice game for multiple players I've added a computer player as well. Help me make it even better. What is ...
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. ...
10
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, ...
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 ...
10
votes
3answers
2k views

Simple dice game - JavaScript MVC implementation

I did a simple dice game using what I learned about separating the 'view', 'model', and 'control'. I am quite clear on what the model is (it's the data and state). But I'm a bit confused on the ...
10
votes
1answer
326 views

Simulate Random Risk Battle

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

A dice game called “Greed”

This game is a variation of the Greed dice game. Imagine we have 5 dice. We roll, them, and jot down the results. Then, based on this chart: ...
9
votes
1answer
605 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: ...
8
votes
3answers
2k views

Imitate randomness of a dice roll

I have written some code in Java that consists of two classes. I have tried my best and I want you to tell me if I can improve and how good this is. Also, how important is OOP? Java is an object ...
8
votes
2answers
917 views

Dice roller in Python

I'm trying to get better in Python and decided to rewrite my dice roller in Perl into Python. ...
8
votes
2answers
3k 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 ...
8
votes
1answer
249 views

SFML dice game with logic-presentation separation

I asked for feedback on my Dice class and I was suggested that I should separate logic from view. I decided to completely refactor my project and I'd like to share ...
8
votes
1answer
126 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 ...
8
votes
1answer
184 views

Python port of Java dice game algorithm

I am in the process of learning Python (background in C++ and R). So after the obligatory "Hello World", I decided that my first non-trivial program would be a port of a Java implementation of the ...
7
votes
5answers
1k views

Interactive dice simulator

After finishing my course on CodeAcademy, I wanted to write a program. Please provide opinions. ...
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 ...
7
votes
2answers
2k views

Dice game where two players try to get to 49

Is there an easier way to make a dice game where 2 people roll a dice to try and get to 49? If there is, the program should output the person who has won. After the game has ended, please use the <...
7
votes
6answers
337 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 ...
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. ...
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 ...
7
votes
2answers
606 views

Python Adventure game

I'm a beginner Python coder and this is the first program that I have ever programmed. Please suggest improvements/bugs. Here's the link to the code. ...
7
votes
2answers
4k views

Character generator

I'm a total newbie teaching myself via Zed Shaw's Learn Python The Hard Way and I've gotten bored over a week long memorization lesson, so I thought I would make a character generator for a pen and ...
7
votes
1answer
5k views

Yahtzee Code Kata in Python

I tried a Yahtzee kata in Python the other day. I'm not particularly experienced in Python (C# is my main language) so I'd be interested in any feedback as to how I could have done things better. In ...
7
votes
4answers
7k views

Rolling dice simulator with probability

I'm a beginner at Python, and to start off my learning progress I created a simple program which will roll a dice and decides the probability of it. It would be great to have criticism on my code, ...
7
votes
1answer
428 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

“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 ...
7
votes
3answers
77 views

Evaluating Dice Poker results

In Dice Poker (or Yacht), a player rolls 5 standard dice (sides 1 - 6) and the resulting roll is given a score based on combinations: Two matching dice only - pair Three matching dice only - three ...
7
votes
1answer
141 views

Random Dice Simulation

I extended the example in 04-random.elm to support N dice and to draw the results using SVG. ...
6
votes
6answers
2k views

Simple Python Dice [closed]

I made a really simple Dice class and test script in Python as a gist. It is simpler than other dice I found on StackExchange being here and here. I made it simple for modularity and reusability. ...
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. ...
6
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 ...
6
votes
2answers
1k views

2 player dice game, where even total gains points and odd total loses points NEA task computer science

This is a game for two users who roll 2 dice 5 times. If the total of dice is even the player gains 10 points if it is odd, they lose 5. If there it is a draw after five rounds then the both users ...