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.
Ethan_145 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
pritaeas 2,194 ¯\_(ツ)_/¯ Moderator Featured Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Ethan_145 0 Newbie Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
rproffitt 2,662 "Nothing to see here." Moderator
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
Ethan_145 0 Newbie Poster
Dani 4,329 The Queen of DaniWeb Administrator Featured Poster Premium Member
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Ethan_145 0 Newbie Poster
Reverend Jim 4,968 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
toneewa 81 Junior Poster in Training
JamesCherrill commented: Yes, benchmark to identify performance problems, don’t guess +15
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
Ethan_145 0 Newbie Poster
toneewa 81 Junior Poster in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.