Quote: "
"Arrays?"
...that's the one!!!
"
lol
what type of game is the AI for? RTS, FPS, Racing, etc...
usually when thinking of a way to program AI, and i don't know where to begin, I usually get the game ready for it, as in functional with ammo, shooting, armor, whatever is is your game. Next I think of how I would play the game like:
if health>min_health_amount
get nearest health
else
if ammo>min_ammo_amount
get nearest ammo
else
go to player and attack
endif
endif
this would need functions for get nearest health etc. but it makes sense. changing things like min_health_amount would affect the style of the AI player, like if min_health_amount=0 he would dual the player to the death the first time he saw the player. or if min_health_amount=100 the ai would run away the first time get got shot.
you would loop through all the AI players like that. also you can give the ai different accuracy amounts depending of the difficulty setting.
the 'go to player and attack' on a lower level would be:
if los(player)=true
aim
shoot
else
get path to nearest waypoint with los with player
follow path
endif
it can get a LOT more complicated with Team FAA or different power-ups.
last year I made a game where the items the player could pick up were something like:
ammo(MISSILES)
health
grenade
laser
teleport
EDIT: forgot to say these types of weapons are ranged weapons, you'd need to program AI to use the infinite range LASER when the normal MISSILES are out of range, use MISSILES when the enemy is in range, or use the damageful-GRENADE when the enemy is within range of the AI player, and outside the blast radius(wouldn't want him throwing grenades when hand-combat would do(unless the AI is a terrorist) /EDIT
In the game I made a while back i programmed the hardest AI to always have "get teleport" at the top priority, so it would get a teleport, and if the AI was 3 shots from death it would teleport to a random spot on the level, thus become invincible, lol.
you will also need a way to see if the AI is under attack, and if so, decide what to do. if the ai is on its path to get a teleport, gut during the trip an enemy starts attacking him, then fight back cuz it can do without the teleport for a while.
or like if an a player is under attack and he's on the same team as the AI player, should the AI go and help the friend or get more missiles?
also if the AI is under attack by 2 or more enemies, it should always attack the weaker one as the sooner you have less enemies, the better.
Sorry for rambling, I like AI programming. lol.
So yeah, to sum it up, it's really game specific and how you want your AI players to play the game.
-----------------------------------
To delete the bug, delete the code.
Specs: Sony VAIO Laptop, Windows XP, P4 2.8Ghz, 512MB RAM, ATI Radeon 64MB video memory, DBP Upgrade 5.3.