howdy,
I had an idea the other day that might speed things up a little bit on the server. One of the things that kills CPU time so often are single or double floating point calculations (fractions and decimals instead of simple integers for the rest of us). Anyhow, a game like this will involve plenty of random numbers in the dice throw. Random number generation can be a particularly effective CPU killer in this regard. So here's an idea....
Have an array of 1000 (or 10,000 or more) pre-generated random numbers in memory already. Then each time the server needs a new number it just indexs up by 1 entry and gets the number. In this case it's just simple integer computation and very fast. On a single player system this would be very poor and quickly become apparent to the user (ie things are not random). However, on a larger multiplayer server, the players themselves (by doing different actions all over the server, all the time) would make the list essentially random for any given player. Do you follow?
now, while this might seem like a simple thing to code, i realize it might be unfathomabley difficult to introduce into Bioware. Or it might just be down right impossible. But if there's a way to change it from calculating pure random numbers (well, they're still pseudo random, but who cares), to pulling a number out of a list each time, then it might make sense. In fact, if I had to guess, i'd say "impossible" with bioware. But I don't reallly know anything about it.
Anyhow, just a thought.
random numbers and NS
I wish I could remember what NWN actually uses, but this discussion has come up on multiple servers that I've played on. If I remember correctly, Bioware is using the compilers built-in pseudorandom number generator, which is a very sad one at that. If it could be changed replaced (something that I also don't recall well, though I know many certainly try), the Mersenne Twister is an incredibly good generator that is so fast that pre-computing numbers instead would be a waste of time and memory. http://en.wikipedia.org/wiki/Mersenne_twister
Does anyone know what NWN2 will be using for this function? If its still the same one, perhaps this should be brought up on thier boards. This function would be the basis for just about everything, mob movement, all checks and combat.
One of the things that might help if CPU was the issue, was tone down some of the ingame animal fighting, which is fun, but not totally needed. Random cpu movements give the game flavor though, so its just something to look at if you hit the wall.
What kind of server does NS run on now? Any specs? I actually do server architecture and have for the past 7 years, RISC, IA32, and IA64. My current server types handled 2000 people running applications on them. I might be able to help a bit there with recomendations if the specs were known.
Umpa
One of the things that might help if CPU was the issue, was tone down some of the ingame animal fighting, which is fun, but not totally needed. Random cpu movements give the game flavor though, so its just something to look at if you hit the wall.
What kind of server does NS run on now? Any specs? I actually do server architecture and have for the past 7 years, RISC, IA32, and IA64. My current server types handled 2000 people running applications on them. I might be able to help a bit there with recomendations if the specs were known.
Umpa
I actually use MT at work and it's a great way to get random numbers fast as possible. But it's still going to be slow compared to this (if the two schemes are coded at the same level). What I'm suggesting would be to only index a single array once (or only a few times) for each random number. MT performs a much larger number of integer shifts to arrive at the random number. Using the stock MT will further introduce a Floating point calculation when you convert the decimal to integer (you could get around this in a clever way, but it's still more integer computations).
Don't get me wrong, MT is a great routine when you need a huge, reliable series of (pseudo) random numbers quickly. However, there are (I believe) plenty of poor random number generators that will perform faster than MT. They just happen to show their true non-random nature very quickly (where as MT is sufficient for most applications by providing a very long series of random numbers).
hmmm.... anyhow. There's more to think on this.
Don't get me wrong, MT is a great routine when you need a huge, reliable series of (pseudo) random numbers quickly. However, there are (I believe) plenty of poor random number generators that will perform faster than MT. They just happen to show their true non-random nature very quickly (where as MT is sufficient for most applications by providing a very long series of random numbers).
hmmm.... anyhow. There's more to think on this.
NWN1 uses a standard random generator for some functions, just a big error in its seeding means it always returns the same sequences. Supposedly fixed for NWN2 at least a year ago (when the devs had more time and inclination to stop by irc they did dish a few things...try the NWN2 channel on NWNConnections irc server).
Tep wrote:I login and there's a dwarf to kill. You can't ask for much more than that.
Alkapwn wrote:NC has the most amazing melee build there is. Its a friggin unstopable juggernaut of pain.
Thank you for that piece of information. I have thought and said for years the random number generator in NWN is whacked. The results were just too improbable, like rolling the same number 6 or 7 times in a row when trying to maximize your HPs on a level-up. If such a thing occured once every two months, I could have no complaints. But it happens quite a bit, much to my dismay.NWN1 uses a standard random generator for some functions, just a big error in its seeding means it always returns the same sequences.
"Do unto others as you would have them do unto you."