I'm making a game in Python, where two armies battle each other. The soldiers both spray arrows at each other. But for each soldier, there is a 1 in 15,000 chance every frame them firing. One thing I noticed was the FPS dropped from 60 to less than 3. Both armies combined have about 5,000 soldiers, so that means about 75,000,000 random numbers are generated every frame. Is there a way I can generate huge amounts of random numbers efficiently? I was using the randrange
function, which is pretty slow. I plan to expand the armies, but it seems hopeless.
↧
Generate 75,000,000 + Random Numbers Fast
↧