How to Fail at Pyweek
About this talk
- how to fail at Pyweek
- and have fun along the way
First try
- game concept: beaver building a dam
- fend off evil birds and fishes
- I was relatively unambitious
- created a game called Dambuilder
Dambuilder
If first you...
- I succeeded the first try
- but
- if first you succeed...
- you can still fail next time!
Second try
- game concept: world simulation
- a bit broad
- but some actual game would materialize soon enough from this, right?
libraries
- pygame again
- with pgu this time
- cage for cellular automata for the simulation
- managed to get simple GUI going with pgu
- ...didn't do much with it
The simulation
- created a simulation which involved..
- domestication of plants
- tech levels
- population
- growth of nation states
- war between states
- didn't have game yet...
Screenshot
Wait
- my simulation is rather complex
- it's too slow!
- cage is in Python
- rewrite cage to C library (unbound)
- (by this time I knew I'd never finish the game)
- Pyweek ends
- I then let the unfinished unbound linger forever in my SVN repository
Followup
- much later
- find the corepy library
- generate assembly from Python!
- be your own JIT!
- opposite of PyPy!
I know!
- I know!
- I can generate a cellular automaton engine that's really fast with it!
- also half-baked lingering in my SVN repository
Try two and a half
- didn't actually do anything
- just signed up and thought about ideas
Third try
- so second try was perhaps slightly overambitious
- this time, we're going to have space marines
- space marines!
- you can't go wrong with space marines, right?
Libraries
- pyglet
- cocos2d
- kytten
- box2d physics
Got working
- GUI with kytten
- that I ended up not using
- cocos2d agent
- that I ended up not using
- define a simple 2d world (of rectangles) with box2d
- render it with pyglet
Along the way
- cocos2d had a release out
- but there was also a newer release
- a very well hidden release
- I ran into a bug and went to look for it
- some issues with the release procedure...
cocos2d release issues
- the new release was called 0.3.1 beta
- but its setup.py said it was 0.3.0
- CHANGELOG mentions a version 0.4.0 with an unknown release date
More release issues
- some __date__ variable set to 2008-06-27 even though release was in 2010
- code.google.com said "mar 08", while the previous releases were
mostly in "mar 2008".
- 'mar 2008' means march 2008, while 'mar 08' means march this year
- not uploaded to pypi, and not even listed on some page so that
setuptool's web crawler can find it
So
- joined cocos2d mailing list
- added issues to the issue tracker
- cocos2d is actually really cool
- just needed some minor tiny release process tuneups
cocos2d 0.4.0rc
- the 0.4.0rc0 release earlier this month was managed much better
- an upload to pypi would be nice though... (it's still at 0.3.0)
So back to the game
- those space marines need to fight something
- what do space marines fight?
- aliens!
- don't want dumb aliens that walk into the rectangles all the time
- so they need to be able to find their way between those rectangles
- I need path finding!
- that's not so hard when you have a grid
- but with randomly distributed rectangles everywhere it turns out to
be more difficult
- path finding meshes?
- ugh, too complicated, don't want!
Steering behaviors!
- found out about this concept called steering behaviors
- Give your aliens a few simple ways to behave, going to goals,
avoiding things
- Found paper and library: opensteer
- But library in C++, so wrote some simple steering behavior code in Python
- (hiding in my subversion forever)
- Still, even writing simple steering behaviors is still complicated
- I'm lazy
Idea
- I know!
- I can use genetic programming to evolve steering behaviors
- Breed code that steers the aliens
- that way I don't need to write the code myself!
GP in Python
- looked into 2 or 3 Python libraries for doing genetic programming
- they're all cool
- and they all sucked in various ways I forget
- cool!
- I get to write my own!
Genetic programming
- GP typically done with lisp-style expression trees (think python AST)
- mutation: change some code in the tree randomly
- crossover: take one branch of one tree and swap it for one from
another tree
- crossover algorithms with typed information are horribly complicated
stack language
- I know!
- I'll invent my own forth-style stack language instead!
So
- wrote a simple stack language in Python
- evolved my aliens
- ...
- they sucked even worse than before
- (all went to a corner of the map)
Screenshot?
- sorry
- didn't even bother to make a screenshot this time
By this time
- somewhere by this time I realized...
- ... I'd probably not finish this game during that week
- but I found out about push3
push3
- a stack language dedicated to genetic programming
- read various push3 papers
- idea: implement push3 with corepy and make it really fast
- some other time...
Conclusion
- I didn't succeed at creating a game very often
- but had a lot of fun
- created fun code
- (lingering in my SVN forever)
- and learned a lot
- (applicable at least to future pyweeks!)