Important updates:
1. Rewrote unit behaviors by using Finite State Machine
2. Updated Path finding in the game
3. Added Group formation
2. Updated Path finding in the game
3. Added Group formation
1. FSM:
After search a lot of RTS articles online, I decided to use FSM to implement my unit behaviors. It really helped me to organize my codes and have a better picture for my gameplay flow. Here are the states i defined:
Idle: wait for commands from player or enemy to show up in range. *Still doing unit separation checking and will move if possible collision is predicted (I forgot to do this earlier in my implementation that caused me a lot of trouble).
Move: Move to assigned destination.
Patrol: Move to assigned destination and go to Chase state if find any enemies.
Chase: Chase the target until reach the attack range or out of sight.
Attack: Attack until enemy defeated or out of range .
Idle: wait for commands from player or enemy to show up in range. *Still doing unit separation checking and will move if possible collision is predicted (I forgot to do this earlier in my implementation that caused me a lot of trouble).
Move: Move to assigned destination.
Patrol: Move to assigned destination and go to Chase state if find any enemies.
Chase: Chase the target until reach the attack range or out of sight.
Attack: Attack until enemy defeated or out of range .
2. Path Finding:
I used A* for path finding. At first, I tried to update every number of frames. But I find out it's not very efficient and my game really doesn't need to update path that often. At the same time I searched and read a article: The AI Systems of Left 4 Dead - Valve. I found out the "Reactive Path Following" it suggested was pretty interesting. Therefore, I implemented this to my game and found out the result was pretty good.
3. Group Formation
For the group formation, I read the popular articles: Coordinated Unit Movement & Implementing Coordinated Movement written by Dave Pottinger. Althought I didn't fully understand all the things in the articles, they did give me some idea for group formation. So I decided to implement a simplified version that assigns units to a calculated square shaped destination grids. The assignment starts from the farest grid and for every grid it finds the nearest unit from the group. This will decrease the chance for units to collide with each other.
That's about it for now. My next step will be adding more units and details(GUI and levels) to the game. I will have some play test after my single player mode is done. And after that I will be doing networking for this game and finish it by May.
Reference:
The AI Systems of Left 4 Dead - Valve
http://www.valvesoftware.com/publications/2009/ai_systems_of_l4d_mike_booth.pdf
Coordinated Unit Movement
http://www.gamasutra.com/view/feature/131720/coordinated_unit_movement.php?page=1
Implementing Coordinated Movement
http://www.gamasutra.com/view/feature/131721/implementing_coordinated_movement.php?page=1