Ludum Dare 33 — August 21st-24th, 2015 — Theme: You are the Monster

Back to Browse Entries

ECS in Python

by brianbruggeman - Jam Entry

I didn't have much time at all to do anything. So I implemented an Entity Component System that I think is pretty close to what might be needed for someone just getting started with ECS. I think there's room for improvement, and I'll certainly update more later.

Downloads and Links




xgeovanni says ...
Aug 24, 2015 @ 4:29pm

An unorthodox entry.

Having "factory" classes and that sort of thing isn't very Pythonic. The docstrings are nice but it could do with a few more comments.

I might use this some time and return better feedback, that's just what stood out from skimming the code.

I might

triplefox says ...
Aug 26, 2015 @ 9:22am

ECS in a dynamic language like Python tends to involve a redundant approach to architecture. You can already access the raw fields and check for existence. The only thing you need on top of that is something to maintain a global indexing of same-type fields. And then once you pursue that road further, and try to add more integrity constraints, you drift towards implementing a relational database, or at least some subset of one. If you want a game engine that is maximally data-driven, try writing all data in BCNF form. (You can spend well over a week thinking about how to implement a clickable GUI button, doing this.)

If you want to continue focusing on architecture from a performance angle I recommend thinking about how your system will treat memory allocation as that is the main thing separating "great" entity systems from "good enough" ones; zero runtime allocation is a good goal. If the entity system ends up being worse than just hand-rolling allocation strategies for each piece of data in the game, it loses by default.

Bottom line, though: you will get more done in gamedev, especially in game-jam scenarios, by writing a single large main loop that does everything in a semi-customized fashion. It is inelegant and CS Professors Hate It, but it has the result of making the code more like an art asset - fluid, easy to change, easy to toggle or cut bits out, or make one-off variations.

Aug 27, 2015 @ 6:11am

Thanks for the feedback guys!

@xgeovanni - I'll be adding more examples in the near future. Factory is really for fast/simple generation of a component. My first example avoids the use of the factory and uses the Component class a more traditional sense.

@triplefox - My goal was to make the interface easy to understand and use for rapid development. But I appreciate the constraints and considerations you've mentioned.

foxor says ...
Aug 27, 2015 @ 1:55pm

Seems like a start to a potentially useful project, but ATM it doesn't do enough to be worth the overhead.

Next steps seem to be things like adding a serialization engine, visual editor, asset importer, graphics pipeline and all the various parts necessary to support the "drawing system".

Python totally needs better game engines!

LegacyCrono says ...
Aug 28, 2015 @ 10:39pm

Hmm, not sure how to rate this. What an unusual entry :P
I don't use Python for gamedev but I can see this being quite useful, you should work on it and release for the community to use in the next LD. Good job!

colinn says ...
Aug 29, 2015 @ 12:56am

I rated this fairly high since as a programmer I really enjoy looking at different architectures

El Cabaro says ...
Aug 29, 2015 @ 4:17am

Like others have said, what an unorthodox entry. I kinda dig it.

hate-marina says ...
Aug 29, 2015 @ 9:50am

Looks pretty JAVA-ish, but it's okay, carry on :D

lanestp says ...
Aug 30, 2015 @ 2:04pm

Thats actually a nice little library. For a game jam having a prebuilt ECS would be really nice, esp. in Python. The problem with languages like Python is they put you into patterns that don't work all that well for Gamedev. In a gamejam scenario almost any reasonable sacrifice in performance is acceptable as long as it makes development faster.

You must sign in to comment.

Mini Submission FAQ

TEAMS: Teams entering the Jam should pick a single representative to submit your game, or create a team specific account you can share. We currently do not support Team Voting, but sharing an account and together playing and rating games is acceptable.

CAN I ENTER BOTH EVENTS?: You should pick 1 event, whichever you think it’ll do better in. If the idea is strong, and everything plays well enough, you can go Compo. If you’re a perfectionist, and would prefer people to play a more polished game, do the Jam. Historically, more games are entered in the Compo, but with more people and more time, Jam games have the potential to be better (that doesn’t mean they are). Many solo participants do enter the Jam.

If you made 2 games, unfortunately, the website doesn’t support multiple submissions per user. To submit your 2nd game, you will have to make a 2nd account. Only do this if you made 2 games. Alternatively, if one game is better than the other, then consider just entering the better game.

CAN I KEEP WORKING UNTIL THE DEADLINE?: Yes! Immediately after the 48 or 72 hours, we do something called Submission Hour. As the name suggests, it’s an extra hour for you to package, upload, and submit your games. If there were catastrophic issues trying submitting your game, or you misunderstood how submissions work, that’s okay. It happens. We’re flexible. If you need advice, check with the folks on IRC. If you need an admin, get in touch.

CAN I KEEP WORKING ON MY GAME?: Oh definitely! You should! But for the sake of judging, keep the Compo or Jam version around. You can include a link to the Post-Compo/Post-Jam version of your game on your games page, but sure your main links are the original version.

PORTS: Ports to other platforms can be done after the deadline. That said, the sooner you finish your port, the sooner people can play your game, improving your chances of placing in the final results. For best results, provide a Web version of your game, or a Windows version with no dependencies. Also be sure to rate at least 20 games to improve your visibility (Coolness).

MY GAME CRASHES, IS UNBEATABLE, OR I MADE A TYPO: We allow you to fix crashes, win condition, or tiny bugs after the deadline. In a sense, this is like “porting” to support more players. We leave this open to interpretation, but generally speaking your game should be identical to the game you submitted. No new features, just fixing mistakes you should have caught had you been better rested.

MY GAME DOESN’T SHOW UP: If you can’t find your game, it’s usually because the URL to your downloads are missing ‘http://‘. Fix your URLs ( and you will show up. Alternatively, if you just posted it, wait a minute. The cache may not have refreshed yet.

NOT LOGGED IN?: If you get a message about not being logged in, even though you are, it’s because your web browser cached the non-logged in page. You can fix this by either refreshing your cache or clearing your cache. CTRL+F5 in many browsers. Chrome is a bit more work. Press F12 to enable Developer Mode, then you can right click on the refresh button and select “Empty Cache and Hard Reload”. This option is unavailable if you are not in Developer Mode.

[cache: storing page]