AI Design for Java RTS
Posted 08 February 2007 - 08:44 PM
I think I am approaching the limits on the utility of this design. I want my units to be able to form up in formations and execute squad tactics as well as simple things like move around a unit blocking its path and general pathfinding.
I am thinking about implementing some kind of Brain class as my AI and centering all the logic in there.
I'm just looking for comments on what others have done for their general AI design as well as suggestions.
Posted 08 February 2007 - 10:25 PM
I could throw up some links tomorrow if you are interested.
Posted 22 February 2007 - 03:02 PM
- Behaviours: What the unit can do, and how to do it.
- AI: deciding what behaviour to do.
In that sense, the "MoveTo", "Shoot", etc you mentioned are behaviours, and you haven't even started to work on AI. :) The Brain approach should prove a good start (give some structure if nothing else) unless you lump everything in there. The question is: how smart should each unit be on its own?
A rule-of-thumb is that AI is everything that the (human) player's units don't do unless the player tells them to. Behaviours can get quite complex and include interactions, such as units that can shoot on the move, aggressive / defensive stances, etc. However, behaviours should be very predictable, so both the human and the AI know what to expect when they issue an order.
You will definitely need a more global AI at the "squad" and "army" level; single units trying to be smart on their own are a recipe for disaster in a RTS. Often, the "army" AI handles the strategic, long-term decisions, creates tasks to complete, and assigns units to "squads" which then have a tactical AI that knows how to accomplish that task. In fact, if you consider the "task" to be the piece of code that handles the tactical AI for a given "squad" (group) of units, you should be able to start seeing some results and have an easily scalable architecture.
Bah, made a mess of the explanation, but I hope it gives you some ideas.
Posted 22 February 2007 - 07:53 PM
When I spoke of orders, an order object such as moveTo simply stores the destination and performs the necessary collision detection and calls the body's move() method, it doesn't actually contain any code to change the units position manually.
This is important as you said because orders could be given that would give the unit extra unintended powers on an order by order basis otherwise.
My main problem is that of, as you said, determining how smart each unit will be.
I would prefer my units in the game to be fairly autonomous in that they will defend themselves, work with other nearby units meaningfully and without any additional higher command. By this I mean that they won't run into each other, shoot at each other, and will move around objects, maintain general formations all without a higher AI guidance controlling the units. I want each unit to know where the others are and know where it should be.
They would obviously only move from their general positions when given an order by a higher player/ai authority.
This contradicts what you were saying in that I would need a higher AI for squad and army movements.
My hope is that I will put the player in a much more macromanagement position in that they wouldn't control their units on an individual level at all. They would assign General AIs to command armies to accomplish goals and the player would merely coordinate strategy and determine objectives.
When I say I want each unit to have a brain, I mean that yes that brain would see where the units are in its surroundings, consider whether it has any orders or not or is moving in formation or with other units, and decide what to do on its own.
Currently, each unit operates similar to a finite state machine. It is given a individual order (although my implementation of the Order class allows orders to be linked together so taht when one is accomplished it is immediately replaced with another one) and that order contains all the code to accomplish that order such as moving the unit around or firing the units weapon.
Keep in mind however, that when the order object tells the unit to "move" or "shoot" it calls one of the units own methods and the unit moves or shoots based on its own movement speed or weapon.
I want all this code and functionality to be taken out of the order class and be put into a brain class so that the units aren't just finite state machines but rather approach a truer AI.
Posted 04 March 2007 - 08:41 AM
Now, I wonder if there is a way I can work a genetic algorithm in here somehow...
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users