[Solved] mygame.pickRandomSeed()?

What is the sense of the function, which I mentioned in the title? Can’t find it in the pokitto API…

1 Like

I think it is from here :

Core::begin calls it for you, so there’s probably no reason to use it directly.

From PokittoCore.cpp:

void Core::pickRandomSeed(){

I used http://www.cplusplus.com/reference/cstdlib/rand/ to generate a random number, but i can use this as well ?

@jonne, is it possible to add more information to the API ? Or maybe start a topic that explains the API more ?

1 Like

initRandom is supposed to initialize that.
Right now, all it does is:

void Core::initRandom() {
    //TODO: hook random seed to battery level

(It might be simpler/better to initialize using getTime as a seed after the first button press)

Where did you see it?
Do you need it for something or are you just curious?

The Pokitto has a Pokitto::Core::initRandom(), but no pickRandomSeed().

Unfortunately initRandom doesn’t function the way I’d hope,
so it’s only useful for using the awful C-style std::rand function.
(And even then only on the simulator. The real deal is empty.)

(I might make a PR to provide a new function or two for better random capability.)

1 Like

I saw it at a source code from a game.

Which game where?
Are you sure the game worked?

It could have been in a comment or it could have been added by the person making the game.

https://os.mbed.com/teams/Pokitto-Community-Team/code/Armageddon/file/8465aff34a93/ageddon.cpp/ Line 292

1 Like

Ah, makes sense… that’s a gamebuino game. The function exists merely to make porting easier and doesn’t actually do anything. :stuck_out_tongue:

1 Like

Ah okay. Most source codes are ports I noticed.

Ah here we go, found it.
It is an actual function in the Pokitto API, but guess what:

void Core::pickRandomSeed(){

It’s the same thing as initRandom(). :P

From the looks of things it’s one of the many functions the Pokitto provides to make porting games from other systems easier.

Ports are easier than actually sitting down and writing something new.
So either the games being ported are really good, the people doing the porting are lazy, or both. :P

1 Like