Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Entreri 1.7 Released (Entity-Component Framework)  (Read 3494 times)
0 Members and 1 Guest are viewing this topic.
Offline lhkbob

JGO Knight


Medals: 32



« Posted 2013-05-19 07:31:07 »

Hi guys!

It's been quite a while since I've posted but I've been lurking regularly as I finished up my first year of grad school. The big news now is that I've released a significant update to my entity-component framework: http://entreri.lhkbob.com and https://bitbucket.org/mludwig/entreri. I posted previously about an earlier version of Entreri: http://www.java-gaming.org/index.php?topic=24962.0

You guys gave me some good feedback, mostly about scariness of strict component definition rules I had imposed.  After some significant revisions, I've updated it to allow you to define your component types as Java bean interfaces, and then an annotation processor to generate the implementation that uses a mapped-object model for performance.

As an example, I could define two components as follows:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public interface Location extends Component {
   public float getX();
   public Location setX(float v); // automatically returns this component

   public float getY();
   public Location setY(float v); // ""
}

public interface Health extends Component {
   public int getHealth();
   public Health setHealth(int v);
}


Then using these components would look along these lines:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
EntitySystem system = EntitySystem.Factory.create();
Entity player = system.addEntity();
player.add(Location.class).setX(0).setY(0);
player.add(Health.class).setHealth(250);

// .. later in your main loop ..
// this shows how to iterate over all entities with a single component type,
// and it uses a flyweight instance for faster iteration over the underlying data
ComponentIterator checkForDead = system.fastIterator();
Health flyweightInstance = checkForDead.addRequired(Health.class);

while(checkForDead.next()) {
   if (flyweightInstance.getHealth() <= 0) {
      system.removeEntity(flyweightInstance.getEntity());
   }
}


Other new features include a parent-child hierarchy model that makes it easy to have one entity for the player, and another entity for its weapon and link them so that deleting the player entity will automatically delete the weapon. Another is a multi-threaded job/task API that tries to make simple parallelization easy to do without much thought, such as splitting the rendering and physics tasks onto separate threads with minimal synchronization.

I'd love to hear more feedback, and hopefully get people who have had experience with other libraries such as Artemis, or Ash, to give it a comparison.

Thanks!
Michael

Offline matheus23

JGO Kernel


Medals: 109
Projects: 3


You think about my Avatar right now!


« Reply #1 - Posted 2013-05-19 08:55:06 »

This is really interesting. All those names for the Entity component frameworks are always so special: Artemis, Apollo, Entreri. What's going on? Cheesy

Anyways, the example looks very cool, and - in contrast to other entity frameworks mentioned above - you have a very special iterating concept, which looks really cool and well designed. Good work!

Didn't check it out completely yet, though.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline relminator
« Reply #2 - Posted 2013-05-19 14:21:17 »

Nice job!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ReBirth
« Reply #3 - Posted 2013-05-20 01:52:14 »

This is really interesting. All those names for the Entity component frameworks are always so special: Artemis, Apollo, Entreri. What's going on? Cheesy
I found new one on github called Ashley.

Offline gouessej
« Reply #4 - Posted 2013-05-20 11:32:32 »

Hi

Your verbs should be at the 3rd person in your Java online documentation ("Gets" instead of "Get", "Returns" instead of "Return", ...). I don't clearly see the service(s) this kind of API provides. Is it still possible to pack all components into a primitive array?

Offline lhkbob

JGO Knight


Medals: 32



« Reply #5 - Posted 2013-05-20 13:26:11 »

Thanks for the comments; I know besides Ashley there is also another one called Ash. I think it's a general library thing though because you've also got things like Kryo and Slick. Artemis was my original inspiration and has since diverged pretty heavily but there is a fiction character named Artemis Entreri that I used to like, also it sounds kind of like Entity.

Gousseg,  this API still packs everything into primitive arrays, it just does it for you so it's less error prone and your code looks much cleaner.  In general, even entity libraries that don't do this still get you to think about your code in a novel way that can improve it.  I think this is like how learning a functional language can help your OO programming even when you don't program functionally directly.

Offline gouessej
« Reply #6 - Posted 2013-05-21 10:20:03 »

Gousseg,  this API still packs everything into primitive arrays, it just does it for you so it's less error prone and your code looks much cleaner.  In general, even entity libraries that don't do this still get you to think about your code in a novel way that can improve it.  I think this is like how learning a functional language can help your OO programming even when you don't program functionally directly.
When I see Artemis and your framework, I just feel like they encourage the developers to use an object-oriented language not to respect the OOP principles, by separating the objects and their mutators the former as entities and the latter as "systems".

Offline sproingie

JGO Kernel


Medals: 202



« Reply #7 - Posted 2013-05-21 19:25:15 »

When I see Artemis and your framework, I just feel like they encourage the developers to use an object-oriented language not to respect the OOP principles, by separating the objects and their mutators the former as entities and the latter as "systems".

OOP has evolved over time.  It's no longer acceptable to have giant inheritance trees, and composition is the name of the game now.  Now it's quite possible to have a nicely compositional design without the use of entity systems, but the chief advantage of such systems is that they force you into using composition over inheritance.  This is a boon for novices who otherwise might not wander into such a design of their own volition.  That a good entity system also provides for flexible ways to assemble components at runtime and optimizes for reference locality is a bonus.
Offline theagentd
« Reply #8 - Posted 2013-05-21 23:48:30 »

I can't help but think that the Location component shouldn't be returning Player instances considering that that the Health component returns itself. Also, am I correct in assuming that the components you defined have automagically generated code or am I just being delusional? >.>

Myomyomyo.
Offline lhkbob

JGO Knight


Medals: 32



« Reply #9 - Posted 2013-05-22 04:06:04 »

Oh yeah, that's a typo, I was fussing back and forth about calling it Player or Location. Edited it to be correct.  Yes, the interfaces get implementations generated by annotation processing such that every bean method pair defines a "property" which is backed by a primitive array. The component implementations just get an index into that, so iterating over the component data of a particular type is very efficient and cache friendly.

And I should mention that the annotation processor would raise an error if my mistake was made in the actual code base.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pmatrasc

Innocent Bystander





« Reply #10 - Posted 2013-07-15 19:01:26 »

I've been using Artemis for a while and I'm quite happy with it.
Has anyone tried Entreri and would suggest it over Artemis?
Offline ReBirth
« Reply #11 - Posted 2013-07-16 02:40:47 »

For library like these trying is not enough. We need benchmark.

Offline lhkbob

JGO Knight


Medals: 32



« Reply #12 - Posted 2013-07-16 14:22:41 »

Although Artemis and Entreri originally started out having a similar API, Entreri has evolved in a significantly different direction.  The reason for this is that underlying component data is packed efficiently into primitive arrays that provides better guarantees for cache locality if used carefully.  Components are defined as interfaces, which IMO reduces the amount of boilerplate that you have to write and helps ensure the principles of data-only components are followed.

That being said, I haven't performed any official benchmarks yet because I am interested more in real application performance.  Often in micro-benchmarks, garbage collection doesn't kick which means lists of objects haven't been moved around in the heap and actually have quite good cache locality.  Anecdotally when doing tests between an old version of entreri (that was structured more like artemis) and the new entreri, data packing seemed responsible for a 2-4X performance improvement.  These performance advantages are less noticeable for small entity counts, but entreri scales very gracefully to tens of thousands while still giving very good performance (it won't be the bottleneck at that point).

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!