1
I am having a doubt in the program I made to represent the game cho-han bakuchi, this game has as a rule to roll two dice of 6 sides in a cup before to show the dice if it makes the bet in which the player speaks cho(pairs) or han(odd) and then the data are displayed and summed up their values.
in my program the game works except for the dice bearing, I am using the function time and srand this way:
srand(time(NULL));
The problem is that after the program is compiled and run the time(clock time on my pc) is saved then whenever the data scroll they will scroll the same number as the srand is saved in the schedule X for example 14:32:43 let’s say that the dice roll 4 and 4 would always like to know how I do to change this because no matter how many times they roll it will always be 4 and 4 would always like each given random Foce what I do?
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int die1;
int die2;
int sum;
int main()
{
int x, cred=100, y, apost;
srand(time(NULL));
die1=1+(rand()%6);
die2=1+(rand()%6);
sum=die1+die2;
while(cred!=0)
{
printf("faça a aposta:(digite -1 para sair)\n");
scanf("%d", &apost);
cred=cred-apost;
printf("\nescolha 1-cho(par) 2-han(impar):\n");
scanf("%d", &x);
printf("\njogador rolou %d+%d=%d\n", die1,die2,sum);
switch(x)
{
case 1:
if(sum%2==0)
{
printf("ganhou!\n");
cred=cred+(apost*2);
printf("seus creditos sao:%d\n",cred);
}
else
{
printf("perdeu!");
printf("seus creditos sao:%d\n",cred);
}
break;
case 2:
if(sum%2!=0)
{
printf("ganhou!\n");
cred=cred+(apost*2);
printf("seus creditos sao:%d\n",cred);
}
else
{
printf("perdeu!");
printf("seus creditos sao:%d\n",cred);
}
break;
}
}
return 0;
}
^^ thanks I’ll take a look =)) and that’s what I wanted to know, now if I need to put a number of random players from 1 to 5 players?
– Leonardo V. De Gasperin