Tuesday, May 28, 2013

My First Go at AI

The main driver my AI routines is the distance the player is from an enemy. The visible board size is 10 tiles now and the total map size will vary from level to level. A distance value of 4 is the starting point for the enemies to activate. It's an arbitrary value an will probably change in the near future after some play testing. The trick here is to balance the timing of the enemy movement with the player movement. Right now they all move at the same speed. See the video below.

video

This is my first attempt at tracking an object. There are some issues with the AI timer firing while the enemies have a target. For a first pass it is a good starting place.

Everything is going to be event driven. I have 2 timers now. One for the object movement, firing every 2 seconds, and the other one is for the AI to update the movement. Currently the AI has a nasty show stopping bug that I will need to address. When it fires the second time, after a distance check from the player, the Astar start and end values are getting set to nil somewhere. (Print statements here we come). I need to separate the enemy movement out of the object timer and make it independent. The choice I need to make is a hard one. Do I have every object have timed value and a running timer, or several timers at different intervals. I think the latter is less processor intensive and will allow swarms of enemies. A running timer would need to check every object every frame or have a way to register objects and their fire time. Time will tell.

No comments:

Post a Comment