soundmud / soundrts

A real-time strategy audio game
http://jlpo.free.fr/soundrts
Other
44 stars 32 forks source link

sometimes the game slows down too much #98

Closed soundmud closed 5 years ago

soundmud commented 6 years ago

The game usually slows down on maps with many squares, meadows, buildings or units, especially if the units are moving or fighting.

There will always be a limit. What a good maximum number of units would be?

Maybe the game could automatically during a game:

francipvb commented 6 years ago

Hi,

What about the collision system?

It would be nice if the game can exclude some map areas from the simulation, like unseen or empty squares.

Another thing it appears to be causing these slowdowns are not really deleted units during the game, like dead knights. This can be the source of slowdown of a match with some time, like 1 hour or more.

What do you think?

Cheers,

soundmud commented 6 years ago

The collision system works well, I think. It should work well with big space, especially mostly empty space. If profiling shows that collision detection is a problem, it might be useful to do something there. Previously the game would enter "no collision mode".

Profiling is a way to know where time is spent. I don't usually check the memory use, maybe I should.

The dead units should disappear after a while, if they are not reanimated.

The main idea here is that there will always be limits, and that the game should set dynamic limits during the game, to avoid too many unit creations before it is too late. Maybe the game could even retroactively remove units from all the players, if it is really needed.

The limit is difficult to guess in advance because the slowdown will happen when the units start moving.

sanslash332 commented 6 years ago

What did you mean with “randomly remove units”… simply remove units because performance?

I think that a better solution, is with debug, try to find the better max numbers of units in a game, can be moving and attacking / doing things, without slow the game. After know this number, well. Put that suggestion in the documentation, a aproximateli. With that you can calculate the best max global poblation limit for your maps, depending the numbers of players you wanted, and the size of the map.

In my case, regulally I play an set in my maps the global max limit in 200, like the majority of rts games. But, I never can try it in a LAN play, with various players, to check how te game works.

On internet well. Is hard to check, because it depends the connection of each player, the current ping between players, etc.

francipvb commented 6 years ago

I don't know if it can help, but I've playing a profiling session of SoundRTS.

I don't know how to process the output data from the python cProfile but I'm uploading to this topic.

Here is the file.

Cheers,

ethindp commented 6 years ago

I think that the game should use multithreading a bit more, rather than making the game run on one processor/processor core. This might solve this little problem, though the game should also be converted to Python 3 (that might make it a lot faster; Python 3 has some major improvements in regards to performance, and multithreading is better too).

soundmud commented 6 years ago

@sanslash332 The limit is probably linked to the slowest CPU, not to the network, because very little is sent through the network.

@francipvb Thanks. There is already cProfile inside the code with a PROFILE variable to change to True, and I won't profile before some changes have been made though. https://github.com/soundmud/soundrts/search?utf8=%E2%9C%93&q=cprofile&type=

@ethindp I'll think about it.