• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Warcraft3 random implementation

Status
Not open for further replies.
Level 19
Joined
Jan 1, 2018
Messages
739
I'd like to know how random numbers are implemented in Warcraft 3.
Tried searching and found a python script, however when running it I get a different result using the same seed (10) and low/highbound (0~100) (result was 43 in python (3.9.0), 55 in wc3 (1.31)).

I also found the decompiled code, but it's missing the SetRandomSeed and table, so can't use that either.

Does anyone know where to find a working implementation?
 
Level 14
Joined
Sep 28, 2011
Messages
968
Did you try comparing with the results of the random number generating library of C++?(and with the one of C?)
I have no clue if the random generator in C++ have similar results to the one of python and it is assumed WC3 was made in C++
 
Level 19
Joined
Jan 1, 2018
Messages
739
Did you try comparing with the results of the random number generating library of C++?(and with the one of C?)
I have no clue if the random generator in C++ have similar results to the one of python and it is assumed WC3 was made in C++
Wc3 has its own random number generation algorithm (like you say in C++), so I didn't compare it with the 'standard' C/C++ algorithm, since they are not the same and so I can say with 99.9% certainty they will return different results.

The python script in the linked thread supposedly implements Wc3's algorithm, but like I said I get different results, so not really sure. Though that post is also over 2 years old, when 1.29.2 was latest, and 1.30 was in PTR, while I tested this in 1.31 PTR. Maybe the implementation was changed at some point?
 
Status
Not open for further replies.
Top