Here's what I've been working on (on and off — I have to admit I haven't devoted too much time to it) in Python.
The blue squares are cities, which emit workers. The workers build roads, and a complicated decision procedure determines whether the workers actually follow the roads or not. (Approximately, they'll do it if they're going in the same direction, and haven't hit a road in a while.) The original plan was to do some more city-building and resource-gathering simulation, but I wound up focusing of making the lines look nice, which was probably more on-task anyways. A neat hack: the workers could only move in 8 directions, which gave chunky lines. But the directions themselves were stored as floating-point numbers, so I nudged rounding back and forth every other timestep, which gave pretty nice and smooth lines.
It's funny how the things we will or won't do in the name of performance are so influenced by syntax. It's a lot easier to bring myself to write something O(n) in the middle of a tight loop if it's a list comprehension than if it's a for loop.
Monday, December 17, 2007
Cities and roads in python
Subscribe to:
Post Comments (Atom)



0 comments:
Post a Comment