I'm doing a host for an AI contest, and have a randomBot that choice random possible values.
The bot has 2 exported functions: Init(_seed) and MakeMove()
To play exactly same games host have a defined seed value for each bot. and its passes it in the Init function.
The Init function of random bot has a srand(_seed) function call. The MakeMove function of random bot has a rand() function call.
Now the problem is that after loading 2 bots, each game should be the same with the same seed values, but they are different.
As I know srand should store its value per module/thread and not share it.
I made a test and created a function mysrand and myrand that are not exported with calls to srand and rand respectively.
I replaced the srand and rand inside the exported functions with mysrand and myrand... and it worked...
I have a clue why this is happening but not sure...
So why exactly does it happen and how to avoid it because I want the contestants to use any function they want inside the exported functions (don't want to use my proxy functions).
Thanks.
I'm using windows, compilers: gcc, visual C++, borland C++ builder