Indie Game Development - "Having fun, making fun"

Monday, February 6, 2012

Dev Log - Computer AI

Computer AI is in!!!  This was one of the big risk areas for the project that I had never done before.  I specifically avoided writing a computer AI in my last project, but knew I wanted to tackle it now. 

For the last few weeks I would take a pad of paper to my daughter's appointments and spend time just thinking and sketching out how I would approach the AI.  When the time came to actually implement it, I was able to write the AI and debug it in only a week! 

The heart of the AI is a threat assessment system which examines the state of enemies and incomming projectiles.  AI players then compare this threat assessment with their own state and position and choose an appropriate action.  They then call the same automated targeting and dodge animation selection functions I already wrote for human players.  In just two days the AI had already come to life.

I then added layers to handle locomotion, collision avoidance, minimize friendly fire, and make friendly AI yield to human players.  The final step was to add pauses in the AI to simulate how humans wait after performing one action before beginning another.  Without it, the AI were simply too brutally efficient.

I'm now playing 4 vs. 4 games with a mix of human and AI players.  Its all very exciting.