Re: Final Theory Of Everything V5.0



John F wrote:
Richard Bos wrote:
CoreyWhite@xxxxxxxxx wrote:

Good Cthulhu... this guy goes from version 2.0 to 5.0 within four
and
a half hours. He's even better than Microsoft!

Richard

Is there any noticeable change in functionality or is it just bug
fixes which would normally make a minor version change? :-) What I
found interesting is the implementation in C to make it look like it
was on topic in this group... I guess I'll have a look at the code
:-)


My version... moslty lint-clean (no critical stuff... just moaning
around :-) I did not check functionality. I just corrected some typos.
== -> =, 2 -> 2L and so on.

#include <stdio.h>
#include <stdlib.h>

void clearbuffer(void)
{ /* cleanup after scanf */
while(getchar()!=(int)'\n');
/*is this cast correct? I guess not :-) */
}

int main (void)
{
double r;
long int M;
double x;
int y;
int z;
int count;

int score = 0;

//Score keeps track of the number of beans won every game


int games = 0;

// games keeps track of the number of games we have played before
//losing all of the beans, which is equal to score


int beans1 = 0;

// Initial value set to zero and defined within the loop

int wins = 0;
int lost = 0;
int quit = 0;
int init = 0;
int rounds = 0;
int live = 0;
int cnt;

unsigned int seed = 10000u;
printf("Enter seend for RNG: ");
(void) scanf("%ud", &seed);
clearbuffer();
srand (seed);
M = 2L;



printf ("Initial Beans: ");
(void) scanf ("%d", &init);
clearbuffer();
printf ("Stop after winning X number of beans: ");
(void) scanf ("%d", &quit);
clearbuffer();
printf ("Number of rounds: ");
(void) scanf("%d", &rounds);
clearbuffer();
printf("Show live output (1 or 0): ");
(void) scanf("%d", &live);
clearbuffer();

for (cnt = 0, count=0; cnt < rounds; cnt++)
{
// We play up to (int) rounds

int beans2 = 1;

beans1 = init + score;

// Beans gets defined here, as starting with 3 beans
// and having a 0 bonus score (It changes as you
// win more beans per round)



// The program attempts to win just one
// bean for every game


while (beans1 != 0 && beans2 != 0)

// The battle begins


{
r = ((double) rand () / ((double) (RAND_MAX) + (double)
(1)));


x = (r * M);
y = (int) x;

z = y + 1;

// A coin is flipped and is either 1 or 2 in value

if (z == 1)
{
// Heads wins

beans1++;

// Beans1 gains one bean from Beans2

beans2--;
}
if (z == 2)
{
// Tails loses

beans1--;

// Beans2 gains one bean from Beans1

beans2++;
}

count++;

// We keep track of the number of rounds in the battle

}


if (beans1 > score + init)
{
// If beans1 is greater than the initial value
// of beans plus the total number of beans
// that have been won so far in this game, then
// the score goes up, and we go on to the next
// game We check this at the end of every game

score++;

games++;
}

if (beans1 <= 0)
{
//If beans1 has lost the game and doesn't
//have anymore beans then we know the
//game is over, so we reset score, and reset
//games


if(live==1)
{
printf ("Lost at: %d beans , %d games\n", score +
init, games);
}

// And we print out the total number of
// games played on this trial and show the
// total score plus the initial value of beans

lost++;
score = 0;
games = 0;

}

if (score >= quit)
{
wins++;

if(live==1)
{
printf ("Won at: %d beans , %d games\n", score + init,
games);
}

beans1 = 0;
score = 0;
games = 0;

}

}

printf ("Total Won: %d/%d\n", wins, wins + lost);
printf ("Net win: %d beans\n",(wins*quit)-(wins+lost)*init);

getchar();
return EXIT_SUCCESS;
}

--
Johannes
You can have it:
Quick, Accurate, Inexpensive.
Pick two.


.



Relevant Pages

  • New Science of the Quantum Pyramid
    ... and can start from any number on the pyramid. ... from the probability of winning the first game, ... long int M; ... //losing all of the beans, ...
    (sci.skeptic)
  • The Quantum Pyramid
    ... and can start from any number on the pyramid. ... If we just let the particle randomly start at either 1 or 0, ... probabilities of winning the following games. ... long int M; ...
    (sci.math)
  • The Quantum Pyramid
    ... and can start from any number on the pyramid. ... If we just let the particle randomly start at either 1 or 0, ... probabilities of winning the following games. ... long int M; ...
    (sci.physics)
  • Re: bad luck
    ... Citadel gets BLOWN OUT in the first halves of most of their games including some to teams nowhere near as good as Davidson. ... Cardinals +9 -103 @PIN ... KSU -400 ML @INT ...
    (rec.gambling.sports)
  • Re: JAN 11 CBK
    ... Citadel gets BLOWN OUT in the first halves of most of their games including some to teams nowhere near as good as Davidson. ... Cardinals +9 -103 @PIN ... KSU -400 ML @INT ...
    (rec.gambling.sports)