does getSorenRandNum() start at 1 or 0?

naf4ever

Dread Lord
Joined
Feb 8, 2003
Messages
405
Location
Southeast Washington State
Does the random number from getSorenRandNum() start at 1 or 0? Meaning if i put in getSorenRandNum(100) would i get back a random number from 1-100 or 0-100?

I would test this myself by simply doing it then having it print the result in the message window. But i still cant print anything in the message window :(
 
if you did gc.getGame().getSorenRandNum(100,"something") you would get a number random number inclusively 0-99 ... I think, I just did a quick test
gc.getGame().getSorenRandNum(2,"something") and only 0 and 1 showed up.
 
naf4ever said:
I would test this myself by simply doing it then having it print the result in the message window. But i still cant print anything in the message window :(
Hmmm - which message window are you looking in?
 
TheLopez said:
if you did gc.getGame().getSorenRandNum(100,"something") you would get a number random number inclusively 0-99 ... I think, I just did a quick test
gc.getGame().getSorenRandNum(2,"something") and only 0 and 1 showed up.


what file(s) do you import into the interpreter to test that?
 
CvUtil.pyPrint prints out to the logs, not to the screen. If you want to print to the screen you need to use something like CyInterface.addImmediateMessage("Foobar","")
 
mattpilot said:
what file(s) do you import into the interpreter to test that?

Im not a programmer at heart, so dont know what you mean by interpreter. But if your question is "How do you actually use this function?" This is what ive found to work.

Code:
chance = CyGame().getSorenRandNum(100, "")
if chance >= 95:

It will then do anything below that last line if the chance matches up with being 95 or greater...
 
mattpilot said:
what file(s) do you import into the interpreter to test that?
I added the code to the OnGameBeginTurn method in the CvEventManager.py file and just kept going through the turns. I tested it through about maybe 50-60 turns and only got 0's and 1's as expected.
 
Back
Top Bottom