Hey Guys, Ive been having a bit of trouble with a program which rolls dice for the game risk. Ive been able to implement number of dice choice selection for both attacker and defender, and to get them to roll the results. The part I am trying to implement now is some form of variable which will take the attackers and defenders results compare them and decide the winning pairs of dice from each player. I beleive that I need a variable but looking at my code i've come to the conclusion that I may have wrote myself into a …

Member Avatar
Member Avatar
+0 forum 2

Alright, so I am simulating a rice roll 100 times, repeatedly. It's getting some whack numbers for some reason, I can't find the problem in code. I have done some printing of the different variables and it seems fine, but I know theres something wrong. package com.github.geodox.dicerollingstats.main; import java.util.Arrays; import java.util.Random; /** * @author GeoDoX * * RollingStats.java */ public class RollingStats { private static Random rand; //Used for generating the roll private static int[] rolls; //Stores the roll counts private static int[] highestRolls; //Stores the highest roll counts public static void main(String[] args) { rand = new Random(); rolls …

Member Avatar
Member Avatar
+0 forum 14

Hello everyone! So I wrote a program that simulates a dice game, almost like the game of Craps. I want to turn this normal console app into a dialogue based MFC. So I would create a button labeled "Roll" and the window would show two die being rolled. Here is the code I have for the condole app. It works perfectly, but I am so confused as to how to assign the code to the button and also how to assign the die faces to its respective bitmaps. I appreciate the help! //Game of chance "Craps" #include "stdafx.h" using namespace …

Member Avatar
Member Avatar
+0 forum 1

Hey everyone just to refresh my memory and practice some programming I decided to make the dice program here is my code: #include <iostream> #include <ctime> using namespace std; int main() { int input; int random; cout << " VIRTUAL DICE 1.0" << endl; cout << "Enter 1 to roll and 0 to quit: "; cin >> input; switch(random) { srand((unsigned)time(0)); for(int i = 0; i <= 6; i++) { random = rand(); cout << random << endl; } case 1: cout << "--------" << endl; cout << "| |" << endl; cout << "| O |" << endl; cout …

Member Avatar
Member Avatar
+0 forum 4

Hello, Please take a look at the below code - #include<iostream> #include<ctime> // for the time() function #include<cstdlib> // for the srand() and rand() functions using namespace std; int compInput; int userInput; int die1 = 0; int die2 = 0; int Dice () { // set the seed srand(time(0)); // roll the first die die1 = (rand() % 6 ) + 1; // roll the second die die2 = (rand() % 6 ) + 1; } int compGame() { Dice (); cout << "The computer rolled Dice 1 =" << die1 << " and Dice 2 = " << die2 …

Member Avatar
Member Avatar
+0 forum 18

could you help write a c++ program da allows 10 players to play the game of dice and displaying the winner with highest score

Member Avatar
Member Avatar
+0 forum 2

So I have been working on this dice roller for a while but am stuck. My form looks like this, a comboBox1 where you can pick numberOfSides on the dice, a textbox1 where you type the numberOfTimes it shall roll the selected dice, a button1 and a richTextBox1 to display the rolls. My problem now is to call this with the button and display the results in the richTextBox1 side by side like this 4 12 8 14 before it breaks it to next line. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using …

Member Avatar
Member Avatar
+0 forum 11

Hi I have a problem with dice game. So I have a dice game , but I want to see the picture of the dice every time the player throws the dice not only the number.. I dont know how to make it, do I need to rewrite the random function? Or i can keep it and write there something like if dice number=1 then console.writeline picture? Anyway here is the code I hope someone can help me :) and sorry for my bad English. [CODE] using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DiceGame { class Program { …

Member Avatar
Member Avatar
+0 forum 8

I am fairly new to C++ programming and have been working on an assignment for my C++ class that involves writing a dice rolling program (rolls 2 dice). The program is to get a random seed number and a desired number of rolls from the user, keep track of the rolls of each point value, and then display actual and expected percentages and number of rolls for each point value. We are also to use functions to complete this program. I am having trouble with a couple of things: first, using a function and/or loop to keep track of rolls …

Member Avatar
Member Avatar
+0 forum 2

I'm writing a program that rolls a die a number of times that the user enters, and counts up each time a one, two, three, and so on is rolled. Right now, it only prints out zero's. Any guidance would be appreciated! Here's my code: [CODE] // dice.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { int one = 0; int two = 0; int three = 0; int four = 0; int five = 0; int six = 0; int result[6] = {0}; int …

Member Avatar
Member Avatar
+0 forum 4

The issue with my program is that it does not calculate how many times the specific value has occurred. I believe that I have everything in place, but I'm not sure to as why it wouldn't work. Any help and/or feedback is kindly appreciated. Thanks! Ok, so basically this program is supposed to do the following: Modify the die program so it rolls both dice 500 times. Count the number of times each value occurred. Your output should look like this: 2's = n times 3's = n times . . 12's = n times [code] class HowManyDoubles{ public static …

Member Avatar
Member Avatar
+0 forum 30

I'm working on a program for class that uses the method Math.random( ) to generate random integers between 1 and 6. Then generate ten-thousand numbers between 1 and 6. Then calculate the number of 1 that has appeared, the number of 2 that has appeared, and so on. The final output must be on a dialog box (using JOptionPane). The process must be looped until the user decides to quit. The output format should like the following: ***************************************** The dice has been rolled ten-thousand times, here is the statistics The number of 1s appeared is 2000 The number of 2s …

Member Avatar
Member Avatar
+0 forum 9

I have an assignment to make a craps game in c. The program i wrote runs but it always ends before it should. I think that the while loops in main have a problem but im not exactly sure wat the problem is because ive reviewed this code over and over and it seems logical but somehow its not working properly. The loop is supposed to call the play_game function over and over again as long as the input from the user is 'Y' or 'y'. when you run the program the loop is calls the play_game function, outputs an …

Member Avatar
Member Avatar
+0 forum 2

hi, im trying to create a program that records the amount of times a number was rolled using input from the user. currently it is only printing 1 number and i need it to print 6. i am only beginning to study java so im lacking knowledge a bit. any help would be appreciated. i am expected to use Math.random() so no "import java.util.Random;" here is my code: [CODE]class DiceRandom { static int random() { int die1 = (int)(Math.random()*6) + 1; return die1; } public static void main(String[] args) { System.out.println("How many times do you want to roll the dice?"); …

Member Avatar
Member Avatar
+0 forum 3

I've never felt like a total moron until I took a Computer Science class. I'm trying to create a program that rolls a pair of standard 6 sided dice 10,000 times and outputs how many times doubles show up, using a "while" loop. I think what I'm trying to do is pretty clear, although I'm positive that I am going about it all wrong. [CODE]import java.util.Random; //to use the random number generator /** This class simulates rolling a pair of dice 10,000 times and counts the number of times doubles of are rolled for each different pair of doubles. */ …

Member Avatar
Member Avatar
+0 forum 5

I want it to say "You are correct!" when the number they guess matches the random roll but it just keeps saying this when I type in 6 as my guess, how do I fix it? This is what I wrote in the main: [CODE] int num; int die; cout << "What number do you think you'll roll? " << endl; cin >> num; die=(int)(rand()%6)+1; if (num<6 && num>0) { srand((unsigned)time(0)); cout << die << endl; } else if (num==die) { cout << "Congradulations! You predicted correctly. " << endl; } else if (num > 6) { cout << "Number …

Member Avatar
Member Avatar
+0 forum 5

I was making a windows form project. in the project the user inputs the number of dice rolls he wants(2 dice will be rolled) and then i am suppose to give the number of times each number happened and the percent of times each number happened. The only problem is that i cant make the random number generator generator more than one roll using one name. [CODE]namespace Dice_Roll_assignment { public partial class diceRoll : Form { public diceRoll() { InitializeComponent(); } private void rollDice_Click(object sender, EventArgs e) { AcceptButton = rollDice; if (txtNumRolls.Text.Trim() == "") { MessageBox.Show("Must enter number of …

Member Avatar
Member Avatar
+0 forum 6

I am trying to make a program in which the user is prompted to input a number(max length of 4 digits), and then the program shall produce the number of outcomes of a two dice roll meaning that 1 roll includes two die. The outcomes could be 2-12 and I also have to show how many times the number occurs and the percent the numbers occurs. It should be a bell curve meaning that if a user types 1000 rolls, 7 should have the most out comes and then 6 and 8 and so on. I got part of the …

Member Avatar
Member Avatar
+0 forum 4

Hi you all! I hope someone here will help me, i have workt with my java-program for 14 hours and i cant get it right. Im sure im on the right way but i cant get i all right. ok.. first i have to create a dice-class that generates random number, 1-to 6. Then, in a Jpanel the dices 30 times should be thrown 30 times. Then i will create a staticstic how many numbers of each. well the program work. But it works whithout the dice-klass. how do i implant the class in a corret way?? sorry, dont laught …

Member Avatar
Member Avatar
+0 forum 1

I wrote this as reaction for Pascal newbie's question in Pascal Delphi forum.

Member Avatar
+0 forum 0

I am using Visual Studio 2010 and C#. I am having problems making my three dice generate different random numbers. All of the dice roll at the same time. I have pictures of dice that I want to pull up for each of 3 dice according to what random number was generated. But when the pictures generate, it is the same picture (aka same number) for all 3 dice. I tried at first to make all three dice pull a random number from the same method, then I tried to make a separate random method for each dice (i.e., randomNum1(), …

Member Avatar
Member Avatar
+0 forum 2

Hey everyone, Im working on a few java programs for a class and this one i can't seem to find an answer anywhere for. I need to write a program that roll's a dice, which is simple, then i have to have it roll the dice 20 times. Also simple. But then i have to show it all as one string of numbers and find the greatest number of same numbers in a row, and put Brackets around them. Here is a actual question.: -Write a program that generate a sequence of 20 random die tosses and that prints the …

Member Avatar
Member Avatar
+0 forum 11

Hey guys, im just learning how to use methods but I really cant seem to understand them. We have a question where we have to write a program for the following game. There is a little known dice game which is played with a pair of dice and has the following rules: the player keeps rolling the dice until the total on the dice is 2, 3, 7, 11 or 12. If the total is 7, then the player loses, if it's 2, 3, 11 or 12 then the player wins. If the total is any other number, then the …

Member Avatar
Member Avatar
+0 forum 15

[B]Hello, I am new to programming. I am trying to make a dice game called 10,000. Here is the outline or pseudo code. it kind of works. It will roll and keep score, but sometimes it will roll multiple times. [/B] pick a player player one or player two player rolls six die if any of the six die are ones or fives add those scores to active players score ones are worth 100 points fives are worth 50 points player rolls again minus the die that had a value of one or five example: roll 6 die-values:1,3,2,5,6,4 two of …

Member Avatar
Member Avatar
+0 forum 2

I need to code a program for my friend and it has been giving me some difficulties. This needs to have two classes, one called Tester and another called Game. And the data in the Game class needs to be pulled to the tester class after the calculations are finished. The tester class out puts the sum of the two dice added together. Here are the directions: Directions: You are to write a class that represents a single di. Your class will contain a class variable that indicates the current side of the di. It will contain a method that …

Member Avatar
Member Avatar
+0 forum 1

I am in need of some help. I need a program that will play the game Three's Free. You roll six dice. 3's are equal to 0. Every turn you take away one of the dice, so every time you roll you take away one die. If you don't roll any three's then you take the smallest die and put into your pot. At the end of the game you add up your total. It would be nice if you could choose which die you could take out as well, or if you could choose multiple dice to take out. …

Member Avatar
Member Avatar
+0 forum 3

I'm creating a game where the goal is to roll two dice and if you get a 7 or 11 you win 10 points, otherwise you lose 5. You start with 100 points. I have everything set up so far but I don't know how to keep the program going my subtracting 5 or adding 10 to the original 100. For instance: you roll an 11 so you have 110 points. The next roll you roll an 8 so you should now have 105 points. How does one do this? All I can do is keep the program repeating itself, …

Member Avatar
Member Avatar
+0 forum 3

The End.