Game Development Reference
If the answer to the question, ''How will I do the AI?'' is ''Just write the code,''
chances are you will write hard-coded AI. Also known as scripted AI, this method
has good and bad points. The most serious challenge with hard-coded AI is
knowing when to use it and when not to use it. Because hard-coded AI is the
most straightforward of all AI techniques, most of this chapter is devoted to
facing that challenge, covering the advantages and disadvantages of using hard-
coded AI rather than the methods for hard coding.
When the code fits the situation well, hard-coded AI is often the fastest and most
intelligent AI code possible. When the code is not appropriate, the decisions that
result from hard-coded AI are often so bad that they disrupt the player's sus-
pension of disbelief. Hard-coded AI gets complex very quickly, can be difficult to
debug, and scales extremely poorly. Its brittle nature can quickly lead pro-
grammers to think there has to be a better way. These are software-engineering
issues in addition to being AI issues, but the demands placed on game AI bring
the issues out quickly.
It is very hard to improve on simple, straightforward code for implementing an
algorithm. Properly designed and implemented, this kind of code benefits from