#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define RANDOM_DEVICE "/dev/random"
#define SLOTS 16
#define ABS(a) (((a) < 0) ? -(a) : (a))
const char *playernames[SLOTS] =
{
"Vinc [prophets]",
"-maniac|Su- [prophets]",
"Lucy [NK]",
"Mara [NK]",
"Slatte [PB]",
"Painkiller [PK]",
"UniT_4S6",
"Phil [PK]",
"qbit",
"frozen soul [AxG]",
"Mo [NK] // magoa",
"totenkopf|pb",
"Radiohe4d [eXiLe]",
"[dtg] Nesquick",
"Venom",
"Alexyk"
};
int randarr[SLOTS];
static int twice(int numb, int index)
{
int y = 0;
for(; y < SLOTS; y++)
if(randarr[y] == numb && index != y)
return 1;
return 0;
}
static void fillrandarr(void)
{
int y = 0;
for(; y < SLOTS; y++)
randarr[y] = -1;
}
int main(void)
{
FILE *pF;
pF = fopen(RANDOM_DEVICE,"r");
if(pF)
{
int i = 0;
int ind;
fillrandarr();
for(; i < SLOTS; i++)
{
do
{
fread(&ind, sizeof(int), 1, pF);
randarr[i] = ABS(ind % SLOTS);
}
while(twice(randarr[i],i) );
}
fclose(pF);
printf("\n----- STARTPOSITIONS -----\n");
ind = 0;
for(i = 0; i < SLOTS; i = i+2)
printf("#%.2d: %s vs. %s\n", ++ind,
playernames[randarr[i]],
playernames[randarr[i+1]]);
return EXIT_SUCCESS;
}
else
{
fprintf(stderr,"Failed to open Random device:\n");
fprintf(stderr,"EC[%d]: %s\n",errno, strerror(errno));
return EXIT_SUCCESS;
}
}