This is the mail archive of the xconq7@sources.redhat.com mailing list for the Xconq project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: exploring_worth sub-module functions (Was Re: Side Mask)


>> [Separating exploring_worth function into sub-module functions.]
>
>This is a very minor point but may make a big difference to
>performance:  would these module functions be inline?  gcc
>supports inline functions in C but I don't know if this is
>supported by all C compilers.  (It probably is.  In any case,
>if/when xconq is converted to C++, this issue would disappear.)
>
>I don't know how often the explorer_worth function would be
>invoked, but if it's "regularly," then it needs to be as
>efficient as is reasonably possible.

This is not an issue since the worth values all are precomputed and stored.
So the code only runs once, at launch.

On the general issue of increasing the AI performance, this is something
that I have been working on, and quite successfully if I may say so. Here
is the result of a recent profiling I did in a large and complex game with
six AI-run sides (the figures refer to CPU time):

Handling human input (scrolling the map etc):	7.7%
Running the AI for all six sides:			1.7%
Playing the hit unit animations:			89.9%

The bad news is that streamlining the AI code even further will have only a
marginal effect on the speed, since xconq hardly spends any time there. The
good news is that there is room (CPU wise) for a lot more AI code.

The reason why most of the time is spent in the hit unit animations is that
each unit blast has to stay on the screen for a fraction of a second in
order to be noticed by the human eye. So xconq wastes a lot of cycles
looping in the animation code. The reason why some games slow down to a
crawl after a while is simply that there is a lot more hit unit animations
to draw.

So can we increase the speed by tweaking the animation code? I just did
that in the mac interface (the changes were checked in yesterday). I did
two things. First, I cut the animation times by 50%. Second, I added
pre-flight code that makes sure the animation loop only executes for unit
blasts and firing lines that are visible on the screen.

This does speed up the game significantly. It has some weird consequences,
though. The game is now running much faster for anything that happens
off-screen. You will notice that if you fire at a unit off-screen, or it
fires at you.

Hans




Hans Ronne

hronne@pp.sbbs.se



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]