There seems to be an overwhelming amount of info out there on AI of all kinds, and it's kind hard to digest at once.
For my testing purposes, I'm creating a "typical stateless AI", as described in this article, and now I need to implement the following functions for a 2D square based game board:
-(void)runAway;
-(void)attackPlayer;
-(void)moveTowardsPlayer;
-(void)tacticalMoveAwayFromPlayer;
-(void)waitOrStationaryAction;
For example, I can run my own run away function like this:
-(void)runAway
{
DLog(@"runAway");
[self debugMessage];
int bestTileIndex = 0;
int largestDistance = 0;
int distance = 0;
if(validMoves.count>0)
{
for(NSNumber* tileNumber in validMoves)
{
distance = [self distanceToTargetFromTile:tileNumber.intValue];
if(distance >largestDistance)
{
largestDistance = distance;
bestTileIndex = tileNumber.intValue;
}
}
}
//move to best tile
}
but this method only checks the distance from 1 target, which may not be the best if there are multiple enemies on the game board.
Where can I find good/efficient implementations of algorithms for searching a 2D grid for these functions? For example finding a point that is furthest away from multiple opponents and is accessible within a certain number of moves.
Other functions that come to mind is picking the best/weakest target, moving towards a specific target while accounting for variable terrain cost, etc
I'm certain someone has already done this before.