Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

These days I'm doing some research on Component based entity systems. I had a first aproximation using a blackboard pattern at Entity level and components sharing this blackboard to do communication.

Doing this research I found an entity framework called Artemis, that follows a FRP structure for the entity managment. The idea seems pretty good and I'm thinking of integrating in my engine. But, I have some questions that need to be solved to fully understand this "odd" architecture:

1) In my first aproximation the way components shared data is pretty straight forward following the blackboard pattern. How should this be done following FRP? It seems, each system would be the ones holding all depencencies to components (Making components totally decoupled). I mean, if the collision system needs to know about physic component, movable system, etc... The collision system would import all this components and do all needed work with them. Is this right?

2) Would each system be a homogeneus or heterogeneus component container? I guess it systms has to be homogeneus related to the component type it holds because the system needs to know the component data to play with it during updates. This leads me to next question:

3) Doesn't this architecture leads to have too many system/components?

4) How does an event system fit in this structure? I ussually have slot/signals in game objects for this but it seems with artemis structure there's no "Entity" concept.

Sorry for the long question and thanks in advance.

share|improve this question
1  
Artemis is just a component-based entity management system. I don't think it's related to functional reactive programming. –  Zach Conn Nov 5 '12 at 1:10

2 Answers 2

up vote 3 down vote accepted

Not an expert, but doing something fairly similar; my thoughts:

1) In general, each system will scan the components (of all entities) that are of a type in which it is interested for some condition that it can handle. A “Gravity” system might ignore “position” components that have a “flying” flag, for example. One way of handling the component data locking and preserving immutable data (although I haven't looked into Artemis) is to remove the “previous” state from the set, pass it into the system, and have that system return the “new” immutable state.

2) I believe the answer is “homogenous,” although I'm unclear as to how you mean it. Each component (e.g. “position” or “affinity to spontaneously combust”) is a “record;” every component of a given type has the same fields; but every type of component has distinct (and non-duplicated) fields.

3) Entity systems are designed around that idea. The “ideal” system would have one system for every type of interaction in the game. In real life, sometimes things that are closely related are ganged together for efficiency.

4) Events can be replaced by state changes in the components. Entity systems, of course, don't lend themselves to having “objects” in the OOP sense; but where an “entity” is a “game object,” an “event” could be:

  • attaching a new component to the entity (making it susceptible to effects from other systems)
  • changing the state of that component (thus, systems listening for that state change would be triggered)

The “blackboard system” dispatcher would them be responsible for observing new records being inserted and triggering the systems that might want/need to handle those records in their new state, subject to (perhaps) timer-based rate limits or other effects.

share|improve this answer
    
So, to sum up: 1) We agree that ussually a system will hold just a component type. 2) During the creation of a new entity (for me it will be just an id), components are requested to the systems they belong (I see systems as a factory too) and the system will be responsible to play with it when updating. 3) Did you mean that systems where the ones that registered to other systems events? Example: GraphicSystem needs to know position from PositionComponent, so, GraphicSystem listens to onChange event in PositionComponent that will be fired when the update method of the system updates positioncom –  Notbad Dec 22 '11 at 18:54
    
Essentially, yes, that would be my idea. — In the system I'm building, I actually have each system provide a “filter” function, such that changes to components run through the (hopefully fast) filter function and then get queued into a worker task to be processed if they match its (perhaps approximate) conditions. EG: the graphics system for a certain viewport might provide a super-fast but potentially overly-broad filter to grab anything it "might" see, without having to cull 90% of the world. (Only changes that begin or end within potentially-viewable range are passed into the work task) –  BRPocock Dec 22 '11 at 19:08
    
I see. Have to think a bit more about it. If anyone has any other idea, etc... I would be really happy to hear it. –  Notbad Dec 22 '11 at 21:38

I worked with both "componentbased game-objects" and "functional reactive programming". As you've used "functional programming" in the title already, I will give an answer from an functional programming perspective, but still keep in mind your componentbased perspective.

Doing this research I found an entity framework called Artemis, that follows a FRP structure for the entity managment.

This doesn't make any sense. Please look up the definition of FRP! FRP is a concept on how to handle calculations and depdencies between data in reaction to an external event. I took a quick look at Artemis and I think it's called a componentbased game-object architecture.

The idea seems pretty good and I'm thinking of integrating in my engine.

Please consider extending an existing engine.

@1

shared data is pretty straight forward following the blackboard pattern

Believe me, you don't want to share data. You're creating something similar to a global variable, and we all learned that we shouldn't use them, didn't we? Mathematically speaking you're breaking functional dependency and you will get in a lot trouble with interdependencies and in the long run your brain will explode.

How should this be done following FRP?

You differ between intra-object communication (via reactive values. think signal/slots) and inter-object communication (via messages).

I mean, if the collision system needs to know about physic component, movable system, etc... The collision system would import all this components and do all needed work with them. Is this right?

The collision system handles functionality concerning more than one game object, thus it must be separate from an independent actor and only communicate via messages. The collision system doesn't need to know anything except the position and physical extension of the object.

@2 see BRPocock's answer. But yet again, the system shouldn't know anything about a components data.

@3

Doesn't this architecture leads to have too many system/components?

Correct. Object-oriented programming at it's best ;)

@4

How does an event system fit in this structure? I ussually have slot/signals in game objects for this but it seems with artemis structure there's no "Entity" concept.

Aren't there any identites of some kind? If not, than I assume there's an "implicit protocol" based on component types. Have fun then!

share|improve this answer
    
Nice answer. Thanks for the insights. –  Notbad Nov 6 '12 at 8:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.