1. Pipelining. x86 has a lot of pipelining in it - that is to say the CPU starts work on the next instruction before it's finished working out the previous one. In fact modern pipelines are quite long (i.e more than a couple of instructions). If you have to branch then the whole pipeline gets binned and the CPU has to start from scratch. You can save a lot of time by avoiding branching. For example you may be tempted to do this
Code: Select all
{
do some stuff;
if (rare_case)
{
// skip this instruction when not needed to save time
simple instructions;
}
do some more stuff;
}
Code: Select all
{
do some stuff;
simple instructions;
do some more stuff;
}
2. Portability. Bear in mind that Spring is designed to work on a wide range of processors. If your AI requires shedloads of CPU to work, you're really cutting down the number of platforms it can work on. You may be happy with that, but you should be aware that you are creating a portability problem with older machines if you require too many CPU cycles for the AI.
Hope this helps.
Munch