AI in Goal Keeper and Players

I am currently developing a simple soccer game with the following features:

  1. 2 teams, each with 3 controllable players
  2. 2 AI goalkeepers that moves around the goal area, and chases the ball when near the area.
  3. The players when not dragged to move to a specific point, will move around randomly in a specific area.
  4. It’s a 2D, top camera view game.

What I am looking for is answers on how to PROGRAM an AI Goal Keeper and Player.

FYI, there are no obstacles (thus no need Pathfinding). All players should not be chasing after the ball.

I have been searching around the web but to no avail. I hope someone can enlighten me about AI for Goal Keeper and Players.

Thank you.

I strongly recommend you get yourself a copy of “Programming Game AI by Example” by Mat Buckland. It’s got an entire chapter dedicated to creating a soccer simulation, and, if you’re interested in AI generally, it’s got some great other examples of finite state machines, autonomous movement etc. It’s not cheap though, so you may want to ask if your local library can get it in for you.

The examples are written in C, but they’re well commented and pretty easy to understand and re-implement into other languages. Here’s a video of the application created in chapter 4 (a 5-a-side match between two computer-controlled players):