Performance and Optimization

Topics

  1. Performance
  2. Optimization

Performance

FlexBot has a relatively small footprint on top of the system resources already required by Half-Life. Preliminary tests on sample behaviors indicated that a fairly complex behavior can take as little as 3 milliseconds of compute time per think cycle on a 400Mhz Pentium II. Half-Life makes approximately 10 think cycles per second on a typical machine. Using a well-designed behavior, a dedicated server can run up to the Half-Life-imposed maximum of 32 clients (bots) without any slowdowns. A listen server experiences occasional but generally acceptable slowdowns when a large number of bots (usually more than 20) are added to a game.


Optimization

There are several simple techniques that a bot programmer can use to optimize a bot's performance.

Limit Traces

There are several simple steps that can be taken to optimize FlexBot behaviors. Perhaps the most important is to limit vision traces. Traces are one of the most expensive sensor calls that can be made due to the fact that they require several complex Half-Life engine calls. Note that the default left-distance, right-distance, and center-distance calculations do eight traces each by default. It may be beneficial to define customized substitutes with fewer traces if the effect on the behavior will be minimal.


Remove or Limit Debug Calls

Using the update_trace() function to send debug messages can be very expensive, particularly if it is called many times per think cycle. Even when debug mode is off, the system will still do a fair amount of work handling the messages. Removing update_trace() calls for a final build can be an excellent way to improve performance.