dice

Does msvcrt.dll use a linear congruential generator for its rand() function?

北战南征 提交于 2019-12-13 06:30:48
问题 I am trying to predict the output of a program that uses msvcrt's rand() function for generating the face of three dice. I believe the code is something like: dice[0] = rand() % 6 + 1; dice[1] = rand() % 6 + 1; dice[2] = rand() % 6 + 1; , and I was wondering if I could use a prediction program for linear congruential generators to predict the next numbers in the sequence. 回答1: See for yourself: C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\rand.c (Or use %VCINSTALLDIR%\crt\src\rand.c

Why is my Swing program still advancing?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:42:55
问题 So I have my program using JButtons with actionListeners attached, but when the program hits a certain point where it should wait for an action to be performed, it skips right over the waiting, and just continues on. I am wondering if it is due to there being no IOException being thrown, but if I throw it, it just returns a bunch of errors, which creates a huge mess. And yes, I know that I am mixing command line with swing. That is because it started out as command line, and now I am making

Reorganise 2x36 dataframe to a 6x6 dataframe. Dice throw visualisation

核能气质少年 提交于 2019-12-13 02:37:31
问题 I've created a data-frame of all the possible outcomes from a dice throw as 2x36 dataframe. d1 d2 1 1 1 2 2 1 3 3 1 4 4 1 5 5 1 6 6 1 7 1 2 8 2 2 9 3 2 10 4 2 11 5 2 12 6 2 13 1 3 14 2 3 15 3 3 16 4 3 17 5 3 18 6 3 19 1 4 20 2 4 21 3 4 22 4 4 23 5 4 24 6 4 25 1 5 26 2 5 27 3 5 28 4 5 29 5 5 30 6 5 31 1 6 32 2 6 33 3 6 34 4 6 35 5 6 36 6 6 To make this visually more pleasing I want to re-organise it as a 6x6 table. [,1] [,2] [,3] [,4] [,5] [,6] [1,] "1 1" "1 2" "1 3" "1 4" "1 5" "1 6" [2,] "2

Unable to Interact with Android Custom Dialog

天大地大妈咪最大 提交于 2019-12-12 13:55:30
问题 Ok, bear with me because I haven't worked with custom Dialogs (or Android programming at all really) that much, and I'm sure I've made a stupid beginner mistake. So I have a simple dice rolling app that I'm trying to incorporate into my existing app, but I want to do it as essentially a popup. The solution I found thus far was to extend a dialog class and use the xml from the app as a custom layout. This actually displays the expected output, but doesn't allow me to interact with it (i.e. it

Dice roll not working C++ deafult_random_engine

隐身守侯 提交于 2019-12-12 05:56:42
问题 For some reason I keep getting 6 every time. I know of another way to do a random dice roll, but I wanted to learn how to use the deafult_random_engine . #include <iostream> #include <string> #include <random> #include <ctime> using namespace std; int main() { default_random_engine randomGenerator(time(0)); uniform_int_distribution<int> diceRoll(1, 6); cout << "You rolled a " << diceRoll(randomGenerator) << endl; } But this bit of code works with the time(0) . #include <iostream> #include

C# - How to find the most common and the least common integers in an array?

拟墨画扇 提交于 2019-12-12 03:40:00
问题 I was asked to make a Dice program with two arrays (one for each dice) and add the two results, e.g.: 2 (dice 1) + 6 (dice 2) = 8. The program must roll the dices 100 times and show the sum each time. I could do it so far, but the program also must show which sum is the most frequent, and which sum is the least frequent. Like this: sum = [2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6]. Most common: 2; Least common: 5. How can I do it? This is how my code looks like: static void Main(string[] args) { Random

Having trouble with my dungeons and dragons dice roller

﹥>﹥吖頭↗ 提交于 2019-12-12 02:47:33
问题 import java.util.Scanner; public class Project2Main { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int numberOfSets = 0; System.out.println("How many sets of dice would you like to roll?"); numberOfSets = kb.nextInt(); kb.nextLine(); for (int i = 0; i < numberOfSets; i++) { int dice1 = 0; int dice2 = 0; int dice3 = 0; int dice4 = 0; int diceTotal = 0; if (dice1 < dice2 && dice1 < dice3 && dice1 < dice4) { diceTotal = dice2 + dice3 + dice4; System.out.println(

Tkinter button animation

不想你离开。 提交于 2019-12-12 01:25:36
问题 I have have been working on a simple piece of python 3.4 code using tkinter. It is a dice roller for D&D. It has buttons for all the basic dice, and one that allows you to input a number of sides. The way I laid it out reminded me of a keypad, so i thought I should add in something that allows you to click the buttons by pushing the buttons. I figured out the system for clicking the buttons to get the function to call, but I can't figure out how to make the button animation go. Is there a way

Need help on figuring out dice game scoring logic

蹲街弑〆低调 提交于 2019-12-11 23:37:34
问题 So, we are creating a game in VB.net based off the game, Farkle. Basically, you roll an amount of dice and depending on what you keep is your score. We have eight dice. Here's an example, say you roll 3 "3"s and you want to score them, a three of a kind. We want to check all the dice together to see if we do have three 3's. We have figured out the two of a kind, but the three of a kind we cannot. For l = 0 To 5 For o = 1 To 6 For q = 2 To 7 If (DieScore(l) = DieScore(o) And DieScore(l) =

Unlimited sides to dice in simulator

若如初见. 提交于 2019-12-11 22:02:07
问题 I am new to python and programming in general. I am trying to create a dice simulator that will allow the user the choose how many sides the dice has and how many times to roll the dice. Then the program is supposed to keep track of how many times each number comes up and display the result. I have gotten this far, where the random number generator will generate a random number for each roll. But i can't figure out how to track the number of times each number comes up and display that. Please