I want to simulate a random deliver of 52 standard cards without using rand/srand urandom etc...
this is my random number function
int rand2(int lim)
{
static int a = 34; // could be made the seed value
a = (a * 32719 + 3) % 32749;
return ((a % lim) + 1);
}
the struct where i will know if a card have already popped ( 0 = NO, 1 yes )
typedef struct s_game
{
int *cards;
int state;
unsigned int dat_rand;
} t_game;
int main()
{
t_game game;
int i;
int rd;
i = 0;
game.cards = malloc(sizeof(*game.cards) * 52);
while(i < 52)
{
rd = rand2(52);
if(game.cards[rd] == 0)
{
game.cards[rd] = 1;
printf("i:%d\n rd: %d\n", i, rd);
i++;
}
}
}
But my output is always the same, each cards is delivered at the same time so im searching fo a better random function or a different way to fill my deliver