Package: ecs
ecs is an MIT-licensed Python entity/component system library for games.There are many articles on the Internet advocating a switch to entity-based systems for game logic. However, many authors seem to burn themselves out telling why the old inheritance-based approach is problematic and how an entity system will solve your problems — without ever really explaining what it is or how to do it.This project attempts to provide an actual implementation for use in real games.The library is called an “entity/component system” library rather than an “entity system,” as the entity portion is just one building block of the total concept.The module is calledecs.cesis too close to something else, and while there is another library calledecs, it’s for an E-Commerce service from Amazon and is unlikely to name-clash in your projects.As this module is in somewhat rarefied air, with not a lot of company, the concepts and API may change during development. Inspiration is taken from theAsh frameworkfor ActionScript 3.0 andArtemis frameworkfor Java.Conceptsecsstands forEntity,Component, andSystem. Each of these parts is important. So what are these?EntitySimply a unique identifier, used to label components as belonging to a logical grouping.ComponentA collection of data. Has no behavior associated with it.SystemPiece of code to operate on data in components for a single frame.Detailsecs defines a few core core classes:EntityComponentSystemEntityManagerSystemManagerTheEntityclass is simply a representation of a unique identifier, and is not to be subclassed. TheComponentclass is intended to be subclassed for your custom components.Systemis also intended to be subclassed for your custom systems.TheEntityManageris a database that storesComponentsubclasses, referenced by their type and entity ID. TheSystemManagermaintains a set ofSysteminstances and allows them to perform their operations.The real action happens in theupdate()method of your subclassedSystemclasses. ASysteminstance queries theEntityManagerdatabase for a set ofComponentsubclasses and operates on the data contained in them.Compatibilityecs is compatible with CPython 2.6, 2.7, 3.3, and PyPy 2.2.0. CPython 3.0–3.2 may also work, but Python 3 users are encouraged to upgrade to Python 3.3. If upgrade is not a possibility for you, please file a issue! Tests ensuring compatibility are run continuously onTravis-CIand can also be run locally usingtox.Examples, Documentation, Contributions, and Issuesecs is a very young project. As such, work on examples and documentation is just getting started. However, if you have read some of the articles mentioned on theEntity Systems wiki, use of ecs should be quite clear. The codebase is quite small and simple and has a comprehensive set of tests to go with it. Those with questions of any sort are encouraged toopen an issue. Contributions are always welcome!Similar ProjectsThis module was written because current entity/component system implementations for Python are scarce or underdeveloped. Here are some other projects similar to this one:PyArtemis, a seemingly unmaintained port of Artemis to PythonMarcus von Appen’spython-utils, which includeebs, an entity system framework similar toecs. However,ebsdoes not draw a distinction betweenentityandcomponent, which we feel is significant.Further ReadingEntity/component systems are a relatively new concept. The canonical source for all entity system-related topics is theEntity Systems wiki, created by Adam Martin. Adam Martin has also written abundantly in hisseries of posts about Entity Systems, which are a great read for those just getting familiar with the concept.Historyecs was originally created byKevin Ward, and is now maintained bySean Fisk. I (Sean) am using ecs in a game written using thePanda3Dgame engine.