Announcing a lightweight entity/component system

Hey I just made a tool I plan to use in future PyWeeks called enco, available here on github. (I'm announcing it now in case I forget until a month before the next one.) It's a simple version of an entity/component system. It's basically a python version of something I wrote in Javascript called UFX.Thing, which I've been using for a while now.

It's documented in the README, and if anyone wants to use it, I'd be happy to help make it work for your situation, if I can. Just let me know.

(log in to comment)


That's interesting, particularly the asteroids example. The way you've done it, it isn't very different to mix-in classes.

The way I understood ECS, it is a pattern to turn is-a relations into has-a relations, so rather than an an entity "being" drawable, physical, controllable by AI, it is a collection of components that do those things. Also, each is registered into its own system, so the drawable sits in a scenegraph, the physical sits in a physics engine, the AI sits in an AI scheduler, the sound emitter sits in a 3D sound system etc. But that approach has always seemed expensive to me, for games on the scale of Pyweek games. Your way looks to produce a simpler class structure, even if I don't think I would organise it in quite so flat a structure as you have.

I'll have to try to think harder about how I structure my stuff next Pyweek. This time I didn't pay much attention to architecture and it got out of hand quite early on.

Cool, thanks for checking it out! I'm wondering if I should even call this an entity/component tool, since it's basically something I just came up with after I heard about the basic idea behind an ECS, and now I realize how different it is from a typical ECS. You're right that it's much closer to mixins.

You're also right that it winds up looking really flat. I think I would tend to make some structure by putting different sets of components in different modules, but there may be a way to impose structure through the implementation as well. I'll have to try it out and see what works.