473,325 Members | 2,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Loaded Dice Tester

13
I have this assigment to do that determines which of three dice are loaded. The dice are actually three C functions called dieA(), diaB(), and dieC()each of which returns an int in the range 1 – 6 when called.

I would have to exercise each of the dice functions and determines which one is “loaded.”


This is my idea of how to make ten throws of die A
Expand|Select|Wrap|Line Numbers
  1.  #include 
  2. "threeDice.h" /* header file */
  3. int main()
  4. {
  5. int j;
  6. for ( j=0; j<10; j++ )
  7. printf("%2d\n", dieA() );
I would like to know how I would begin to do this program. I was messing around with the rand() function to replicate the throwing of the dice. I know I need variables for a counter and for the number of rolls.

Any help would be appreciated.
Oct 5 '06 #1
2 3733
r035198x
13,262 8TB
I have this assigment to do that determines which of three dice are loaded. The dice are actually three C functions called dieA(), diaB(), and dieC()each of which returns an int in the range 1 – 6 when called.

I would have to exercise each of the dice functions and determines which one is “loaded.”


This is my idea of how to make ten throws of die A
Expand|Select|Wrap|Line Numbers
  1.  #include 
  2. "threeDice.h" /* header file */
  3. int main()
  4. {
  5. int j;
  6. for ( j=0; j<10; j++ )
  7. printf("%2d\n", dieA() );
I would like to know how I would begin to do this program. I was messing around with the rand() function to replicate the throwing of the dice. I know I need variables for a counter and for the number of rolls.

Any help would be appreciated.
You could design it this way.
Each method uses a different method for generating random numbers(So perhaps you need three different random functions, or try to manipulate the seeds to the calls to the rand() function)

generate say n throws of the die with each of the functions.
you could use three arrays. array a for storing numbers from method dieA(), array b for etc.

Then you need a test for randomness of the numbers runs test etc (whatever is not complicated for you).

so you then just take the values in each of the arrays and test them for randomness. A good test will give you the degree of randomness for each test so that you can say which method produced the least random numbers.

The greater the size of a, the more consistent your results become.
Oct 5 '06 #2
DeFault
13
Please forgive the errors in code I just wanted to get it written down to understand it. If there is anything that I have missed could please explain what it is.

Expand|Select|Wrap|Line Numbers
  1. int dieA();
  2. int dieB();
  3. int dieC();
  4.  
  5. #include <stdio.h>
  6. #include "threeDice.h"
  7.  
  8. int main ()
  9. {
  10.     int a_store[0];
  11.     int b_store[0];
  12.     int c_store[0];
  13.     int n_throws, size;
  14.     int a_random;
  15.  
  16.     for ( n_throws = 0; n_throws < size; n_throws++){
  17.  
  18.         printf ("%2d\n", dieA());
  19.         a_store[n_throws];
  20.  
  21. }
  22.  
  23. for ( n_throws = 0; n_throws < size; n_throws++){
  24.  
  25.         printf ("%2d\n", dieB());
  26.         b_store[n_throws];
  27.         }        
  28.  
  29.         for ( n_throws = 0; n_throws < size; n_throws++){
  30.         c_store[n_throws];
  31.         printf ("%2d\n", dieC());
  32.         }
  33.  
  34.        a_random = rand() a_store[n_throws];
  35.  
Oct 6 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Hal Vaughan | last post by:
If I have a class like this: public class Tester { ObjectType1 ot1; ObjectType2 ot2; ObjectType3 ot3; public void main(String args) { //Preliminary checking, resulting in bRun being
2
by: Michele Simionato | last post by:
Some time ago I hacked a custom solution to run doctests on text files containing documentation. The solution involved this kind of game: tester=doctest.Tester(globs={},verbose=1)...
11
by: Tomi Lindberg | last post by:
Hi, I'm trying to find a way to calculate a distribution of outcomes with any combination of dice. I have the basics done, but I'm a bit unsure how to continue. My main concern is how to make...
101
by: Elijah Cardon | last post by:
Let's say I have m dice having n sides, such that n^m is not going to bust int as a datatype. With m=4 and n=6, an outcome might be {2, 5, 1, 2}. What is a good way to represent this in c so that...
0
by: Bree | last post by:
The game requires it not to accept negative numbers. At the moment it isnt, and it is urgent I find the solution asap. So if anyone can help I would much appreciate it. Thanks Bree This is the...
2
by: Smithers | last post by:
I have a Windows Forms application that implements a plug-in architecture whereby required assemblies are identified and loaded dynamically. Here are the relevant classes: A = application =...
5
by: | last post by:
I am having problems with casting or converting a class to to an interface from which it derives. I'm certain that it's due to how it's being loaded, but I'm not sure how to get past the problem....
4
by: clairelee0322 | last post by:
Hello guys again! I am a C++ beginner and I am working on another project.. It's called Dice Lab with Loops.. unforunately I don't even know how to start the program.... Don't blame me for not pay...
1
by: clairelee0322 | last post by:
I am a c++ beginner and i am working on a dice loop lab. This program should roll two dice (each dice is from 1 to 6) and then total them together. The user should be able to input how many times...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.