Age of empires Ai sort off thing

Blitz3D Forums/Blitz3D Beginners Area/Age of empires Ai sort off thing

The best way to tackle AI is to put yourself in the position of the character you're trying to manipulate and think like they would. Then you translate that into code. Example:

Soldier A is 2 blocks away from Soldier B
Soldier A is armed with a rifle with a 1 block range
Soldier A must move closer to Soldier B
Soldier A is now within firing distance
Soldier A fires

Or, in code...

If SoldierDistance(soldierA, soldierB) < soldierA\gunrange
	Shoot(soldierA, soldierB)
Else
	Move(soldierA, soldierB)
EndIf
A very simple example of how you can implement AI. But this is just one of many checks. You'll need to give a 'score' value to each possible action and have your soldier select the action with the greatest score potential. Example: Shooting a soldier is worth 10 points whereas shooting an officer is worth 20 points. So soldier A shoots the officer instead.