« War of the Cubes! | Main | War of the cubes : Code »

War of the cubes:Update Warning Long Post!

Over the last week I have made some significant amount of progress in the game/simulation whatever. There were a couple of ideas I had been toying with essentially how to pass messages between game objects and how they should react to events etc.

The solution I am came up with is that objects now each have a Priority based Event Queue. Events can be sent to objects to by adding to this queue and since I its priority based we can assign different priorities to the events eg USER EVENT, AI EVENT, IMMEDIATE EVENT.

- USER EVENTS - any event triggered by a user eg. click on the unit,commands to the unit by a user.
- AI EVENTS- more useful while a unit is being controlled by an AI. The AI need not be a master AI it can be like a Group AI thread created by a user. Eg A User creates a group out of a bunch of units and sends them out on a reconnaissance mission. One unit in the group identifies an incoming hostile and it can send events to all its group members to prepare for the incoming hostile etc. The Message passing is also useful in simulations to trigger events eg if more than 3 simutrons ( yes thats my name for actors:p ) are near a simutron it can randomly ask a simutron to clone itself .

- IMMEDIATE EVENTS - These must be highest priority events eg A simutron got shot and needs to die. We can decided to process event that lead to the units death first before handling other user commands.

One thing I forgot to do is sort it based on event time priority. At this time I am not sure if that is the right approach probably I should just use event time as a sorting criteria and not the type of event or just have 3 separate event queues per simutron.

Right now the simulation ignores priorities as all the events are currently simulation events and its just simutrons signalling to each other to die or clone themselves or die of loneliness.

I also added more states to each simutron. A simutron's state machine looks like the following right now


CREATED ->ACTIVE -> DEAD->DESTROYED

-CREATED - The simutron is growing to life and won't process any events in this state( useful or doing a creation animation)
-ACTIVE - Simutron is ready and will process events now as well as fire off events based on certain conditions being met.
-SLUMBERING (not shown will update diagram later)- Simutron will process incoming events but will not trigger any events by itself nor do any checks. Its like a sleep state for the simutron.
-DEAD - Simutron is dead and will not process any more events. Useful to start playing a death animation.
-DESTROYED- Simutron is done dying! release all resources now.

I will expand this state machine as the game develops but for now its sufficient. Now the code I have implemented allows me to just add a seed population of simutrons and just watch them kill/clone other simutrons.

As of now I have the flexibility to easily change the simulation logic and try out different simulations. The current simulation is a variant of Conway's Game of Life but there are a few bugs I need to fix with it:) Mainly, the creation rate of simutrons is far higher than their death rate leading to a few thousand of them on screen and bringing the simulation to a halt! What I would like to achieve is a stable population of simutrons using simple rules.

Screenshots/video to come!

The next thing I am planning on doing is to setup a Master controlling AI and let it spawn GroupLeader AI's which in turn will control individual simutrons. The idea is to simulate flocking behaviours/self organizing groups etc.

How this will work will be each simutron will start off directly being controlled by Master AI. At any time when 3-4 simutrons come close to each other they will randomly promote one simutron as a group leader and join that group. Then the movement of the GroupLeader will determine individual simutron movements. The Group will keep adding more simutrons to itself till it reaches a certain group size. The loners who don't join a group for a long time will die off leaving only groups moving about.

Once this stage is reached we can simulate group to group interactions and more complex behaviour can be modelled.

Later on I will add other AITypes controlled by Master AI which inturn will control group AI's. These AITypes will have different types of priorities eg, Building, War , Reconnaissance etc. The master AI will use these AITypes to shift priorities and assign/take away simutrons from AITypes. Essentially this will be a resource optimization problem for each AI. Given different competing objectives how to optimize resource allocation and usage.

Eg The master AI at any time has X number of simutrons available to it and different tasks to complete like building/fighting/reconnaissance etc. Depending on what state the simulation is in it will have to dynamically reassign simutrons between AITypes. Similalry each AIType will have multiple objectives and limited number of groups/simutrons under its control and will have to prioritize based on available resources.

The AI development will be a long continuous process which I will be doing alongwith the other significant integration which is Physics. I intend to integrate a physics engine (either bullet or Ode) into the simulation to handle stuff like collision detection and a more realistic behaviour of simutrons.

At some point I hope to make this into a simulation framework by integrating a scripting language to control the simulation.

Note To Self: Should commit code to some code versioning system:)

Can you digg it? Bookmark This

Post a comment

About

This page contains a single entry from the blog posted on August 20, 2007 11:12 AM.

The previous post in this blog was War of the Cubes!.

The next post in this blog is War of the cubes : Code.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.

Links

Powered by
Movable Type 3.34