dice

dice rolling in C# console application giving incorrect totals

本秂侑毒 提交于 2019-12-11 09:54:53
问题 I am writing dice roller program in C# console. I am giving two input Enter the size of the dice and Enter how times you want to play. Suppose dice size is 6 and 10 times i have played. Output is coming: 1 was rolled 2 times 2 was rolled 7 times 3 was rolled 8 times 4 was rolled 7 times 5 was rolled 4 times 6 was rolled 5 times Total: 33 (its not fixed for every execution this no will be changed) But my requirement was this total always should be number of playing times. Here I am playing 10

Random number generator with non-equal distribution of numbers

坚强是说给别人听的谎言 提交于 2019-12-11 06:07:26
问题 I know that I can use var rolls = []; for (var i=0; i<100; i++) { rolls.push(Math.floor(6 * Math.random()) + 1); } to get 100 rolls with a single die. But what if it is a magic die, where each number doesn't show up equally? So instead of each number showing up 1/6th of the time, the numbers 1-4 each shows up 10% of the time whereas 5 shows up 20% of the time and the remaining 6 shows up 100%-20%-4*10% = 40% of the time. How do you make such a random number generator where the distribution

Formatting Dice Roll Output Java

时光总嘲笑我的痴心妄想 提交于 2019-12-11 01:27:41
问题 I created a code where the user inputs the number of times that a dice will be rolled. The program then outputs the face values, the number of times each face came up, and a percentage frequency of each face. I have to use System.out.printf() to format the output. My problem is that whenever I input a roll that is more than 9, the formatting of my output is completely thrown off... Here is my code: package variousprograms; import java.util.*; public class DiceRoll { public static void main

Specializing a class template constructor

半世苍凉 提交于 2019-12-10 23:27:23
问题 I'm messing around with template specialization and I ran into a problem with trying to specialize the constructor based on what policy is used. Here is the code I am trying to get to work. #include <cstdlib> #include <ctime> class DiePolicies { public: class RollOnConstruction { }; class CallMethod { }; }; #include <boost/static_assert.hpp> #include <boost/type_traits/is_same.hpp> template<unsigned sides = 6, typename RollPolicy = DiePolicies::RollOnConstruction> class Die { // policy type

C# code only gives expected results on step through?

北城以北 提交于 2019-12-10 14:54:39
问题 Ok so I have a dice throw app... When I step through the code it functions normally and 'results' contains the correct number of throw results and they appear to be random, when I leave the code to run and do exactly the same thing it produces a set of identical numbers. I'm sure this is a logical error I cannot see but fiddling with it for hours hasnt improved the situation, so any help is much appriciated. :) class Dice { public int[] Roll(int _throws, int _sides, int _count) { Random rnd =

Dice odds: Simulating a game of Craps

感情迁移 提交于 2019-12-10 02:56:11
问题 My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I plan on bringing $200 again for this trip and before I go I thought I'd run some craps simulations to see if I can double my money again. I've read from several sources that the house has the smallest advantage in craps when placing a passline bet with maximum odds. From my memory, and as surveyed

Dice(ITP1_11_D in AOJ)

落花浮王杯 提交于 2019-12-09 21:52:40
Introduction Write a program which reads n dices constructed in the same way as Graph shows, and determines whether they are all different. Input In the first line, the number of dices n is given. In the following n lines, six integers assigned to the dice faces are given in ascending order of their corresponding labels. Output Print “Yes” if given dices are all different, otherwise “No” in a line. Constraints 2 ≤ n ≤ 100 0 ≤ the integer assigned to a face ≤ 100 Samples Sample Input 1 3 1 2 3 4 5 6 6 2 4 3 5 1 6 5 4 3 2 1 Sample Output 1 No Sample Input 2 3 1 2 3 4 5 6 6 5 4 3 2 1 5 4 3 2 1 6

dice notation in excel

随声附和 提交于 2019-12-08 07:57:48
问题 i'm having an issue in excel and i need help from someone who knows better. Quick story : i'm a rolist, i'm doing character sheet on excel and i need to do dice notation calcul. I need to be able to write in a cell something like 3d6+2d4+6 or 3d8+2+3d9-2d6 or any combinaison. and then calculate the result in a other cell. something like Rolldice(A1) and it would calculate it (if 3d8+2+4d8 was given it would give a number between 9 and 58 ) Basicaly 1d6 means 1 dice with six faces, thus a

dice notation in excel

有些话、适合烂在心里 提交于 2019-12-06 15:37:01
i'm having an issue in excel and i need help from someone who knows better. Quick story : i'm a rolist, i'm doing character sheet on excel and i need to do dice notation calcul. I need to be able to write in a cell something like 3d6+2d4+6 or 3d8+2+3d9-2d6 or any combinaison. and then calculate the result in a other cell. something like Rolldice(A1) and it would calculate it (if 3d8+2+4d8 was given it would give a number between 9 and 58 ) Basicaly 1d6 means 1 dice with six faces, thus a random number betwen 1 and 6 . 2d6 would mean doing 1d6 + 1d6 (thus a number between 2 and 12 ) I don't

Dice odds: Simulating a game of Craps

大憨熊 提交于 2019-12-05 01:59:36
My brother turns 21 in a couple of weeks and my parents and I are taking him to Las Vegas. For my 21st, I brought $200 to gamble in Vegas and came home with around $450, mostly from playing craps. I plan on bringing $200 again for this trip and before I go I thought I'd run some craps simulations to see if I can double my money again. I've read from several sources that the house has the smallest advantage in craps when placing a passline bet with maximum odds. From my memory, and as surveyed by Wizard of Odds , most casinos on the Strip are 3-4-5 odds with a $5 minimum. Taking this into