Road and Countryside Script – First Year Project

I didn’t want to do a grid city like everyone else. Skyscrapers were cool but I wanted interesting patterns. We had started learning python a couple of months before I started writing this script. I knew nothing of classes or object-oriented programming, so the entire thing is procedural. There was no over-arching design – I just jumped in with an idea for generating roads using vectors from polygonal shapes. I got a terrible mark for this project – probably because it is occasionally very buggy, and always very slow. I haven’t figured out where the bugs are yet but I think refactoring it with classes would make much more sense!

I made the terrible mistake of just running it with internal random numbers every time I wanted to test it, so could try 100 times without noticing that the roads don’t make T-junctions when they hit another road properly after splitting 4 times for example. I also put the separate parts of the script together very quickly – generating houses next to the roads was something I did while making the UI. I’m quite proud of the code that moves the road onto the landscape – although I probably should have done raycasting or something, I decided to implement a UV-coordinate-per-face type solution (barycentric coordinates) in 2 dimensions then reprojecting into 3D. Probably much slower! The landscape generation code itself is about 8 lines. The UI design is merely a thin veneer over the underlying implementation!

If you’re interested in any of the algorithms/ getting the script, contact me!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s