Game Development Reference
In-Depth Information
opening song of the latest opera. Unfortunately, the scene described is a funeral
home, not a small theater. No matter how good the AI is at making Horatio sing
and portray emotion and move on stage, it is behaving inappropriately. As
mentioned in Chapter 1, ''Introduction,'' one of the overriding goals of any AI
programmer is to avoid artificial stupidity.
No matter how good the AI is at the things it does well, players will recoil when
the AI is stupid. Inappropriate behavior destroys suspension of disbelief. Simple,
hard-coded AI carries with it the risk of selecting an inappropriate behavior. If
the AI for Horatio could reason, it might be thinking, ''You mean I am not
supposed to be singing right now?'' Hard-coded AI also tends to exhibit poor
default behaviors: ''This is what I do when I don't know what to do.'' A simple AI
can be hamstrung by having a set of behaviors that is too limited: ''These few
things are all that I know how to do.'' While hard-coded AI lacks formal
structures that lead the programmer to deal with any of these issues, action
selection is the most noticeable.
Thus, the first challenge when writing hard-coded AI is to make sure that the AI
reasons correctly that the action it is about to take is the right one. It should not
decide to sing opera at funerals. The second challenge for hard-coded AI is to
fake it gracefully when it does not know what it should be doing. The third
challenge for the AI programmer when creating hard-coded AI is to give it a
sufficiently broad set of behaviors. Answering this third challenge helps mitigate
the second one if the additional behaviors have different situations where they
are appropriate.
The Ugly
The major enemies of hard-coded AI are size and complexity. Code organization
is ad hoc unless the programmer actively takes steps to regularize it. Changes to
the code often entail a full rewrite or major refactoring of the codeā€”and failing
to refactor the code carries the risk that the new code will never work properly.
This kind of code is said to be ''brittle.'' It has certain strengths, but beyond a
certain point, the method fails catastrophically. Ad-hoc organization provides no
clear guidance for the programmer with respect to where more code should be
added as new capabilities are required. This method fails to scale up.
Reconsider hard-coded AI when size and size-related complexity threaten to
become overwhelming. Hard-coded AI is a good place for small, complex
algorithms, but it is not well suited when the complexity is mostly due to large
Search Nedrilad ::

Custom Search