I read about skipList implementation in C++ and I don't understand this random function :
float frand() {
return (float) rand() / RAND_MAX;
}
int random_level() {
static bool first = true;
if (first) {
srand( (unsigned)time(NULL) );
first = false;
}
int lvl = (int)(log(frand())/log(1.-P));
return lvl < MAX_LEVEL ? lvl : MAX_LEVEL;
}
Thanks for reading and I'm waiting for your answer :)