Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Mar 2004
Offline Last Active Feb 28 2013 10:40 AM

Topics I've Started

Component Based Game Architectures (examples?)(more info?)

22 April 2007 - 12:04 PM

I recently read through 2 articles in GPG5 & 6 that explain the theory, and implementation of a component based game architecture... (quick explaination follows) -------- 100% composition based game objects, no inheritance tree. (an elf "has a" health-component, a location component, a magic component, etc...) Very loose coupling between game objects/components. The only member function that gets called regularly is "Component::ReceiveMessage(msg)" -------- I am completely in LOVE with this architecture. It simplifies SOOO many issues. Inter-object interfaces are simple now, and problems with inheritance trees just vanish. I've proposed this architecture for a couple projects at work now, and everyone who sees it seems to agree that it's great for what we do. Albiet there's some slight performance loss which is a tradeoff for the huge amount of flexibility. ANYWAY... On with the question. I'm looking for more info on/examples of this architecture. Particularly, I'd like an optimal way to handle the message passing between objects (message types or an enum+data). As well as some examples of how people chose to break their game objects up into components. I've waded through 200+ google results without finding much. Anyone out there seen a good component based system that worked well? Or just feel like commenting on the architecture? Post away.

The GPG5 component based architecture, How well does it scale?

10 July 2006 - 04:19 PM

Long post, about a very specific issue... I'll try to be concise. For those who don't know, the book "Game Programming Gems 5" details a very impressive component based software architecture. This architecture is based on game-objects comprised of very loosely coupled components. The components all know thier game-object-ID, but know little else about other components in their game-object. Components interact with other components, and with other game-objects through a message-passing system, and queries to a database-structure which contains all the components in arrays/STL-containers for fast access. A quick example would be a monster game-object which might contain components handling "AI" "health" "attack" "defense" "location" "model" "animation" "description" and "inventory". In a fight, the AI component would send messages, (or used a cached pointer) to the attack component, which would query the object-manager for the "location" component of the enemy creature, it would decide if the enemy could be hit, and if so, would post a Swing-At message. The object manager would route the Swing-At message to the enemy's "defense" component which would determine if it was a hit/miss, and post a message to the enemy's "Health" component, which would subtract hit-points. *Phew*, hope you get the idea... I have been using this architecture for a while at work, and have had _Great_ success with some small/not-quite-small projects. Everyone loves the flexibility, and transparent nature of this architecture. And in the simulation-environment where we work, this idea is making a strong inroads. Anyway, I'm working on a somewhat large project at home, in my spare time. I'd like to use this architecture, but am having some concerns about performance, scalability, and distributability. I'd like to know if anyone out there using this architecture has tried this on a large scale project. 1-Performance) With the many, many components in the database, has the database-structure is going to get bulky, and the lookups will start to slow down. Has anyone found this to be a real issue? 2-Scalability) Since all components are handled in a single database, there's not much that can be done to distribute the load among multiple processors, as contention for the database will probaby (I think) limit the number of active working threads to 1. 3-Distributability) It would be nice if I could move this simulation to a networked distributed setup, with a few computers maintaining all the entities based on zones of control. (I'm still thinking of how this would work. I'm imagining some sort of way to serialize entire game-objects and move them to other simulation-servers when necessary). If ANYONE has any insights into this architecture, when used on a large scale, could you post a few insights? Maybe some thoughts on the performance overhead incurred with this setup? Even some random discussion about this architecture could be helpful.

Best 2D Space-Partition structure for point proximity

07 April 2006 - 03:30 AM

Greets, The game is a 2D landscape, with hundreds(thousands?) of component based game object creatures living their lives... Grazing, hunting, mating, Whatever their AI component wants them to do. The Creatures interact with each other by sending messages to nearby creatures whenever they do something interesting. IE... If Creature#1234 kills and eats Creature#45, a message is sent to every other Creature within 500 units, so they can decide what to do. Also, If Creature#4321 sends out a mating-call, then a message will go out to every other Creature within 1000 units, so that they can react. Of course, there's other message types, which travel over different ranges, but the idea is the same. I've been doing a for loop on EVERY:( Creature to determine the distance-squared, but this is a costly operation. (I profiled it, and the time spent in the "FindNeighbors(int)" function was around 10%. Not Odius, but more than I'd like, and only going to get worse when I ramp up the Creature Count). I need this Space Partition structure to speed up my message passing, by lowering the potentialy interested set of Creatures. The Creature's distribution is slightly clumpy, but can also be spread out over large areas, so no help there. :( --------------------- I can see using a few different space partitioning structures to minimize the potential Creature set... Loose Quad/Octree Quad/Octree Hashed Grid Loose Quad/Octree: My Creatures in this instance are just 2D points on a map. The fact that they are points makes a Loose Quadtree seem like a less-than-perfect solution, because all of my Creatures will end up in the bottom leaves. That's not a terrible problem, but it makes me think something else may work better. A Quad/Octree would work, but since the creatures are somewhat dynamic/mobile they'll be breaking out of their sectors regularly, making me rebuild the quadtree somewhat often. A Hashed grid seems like it would work great. Just hash a Creature's x, and y, to get it's sector, and check against creatures linked in that sector, then check against every creature in every sector within the message-radius. This seems good, because there's less pointer-tracing down a quadtree, but I'll end up doing quite a bit of distance checks on empty sectors. If anyone hass tried any/all of these with a Large number of point-only game objects, and found one system to be very efficient, I'd love to hear your results. My only other option, is to code up all of these, and try them all out separatly.