Pixel details, and a first version of smarter Cities.

Pixel details

Up until now, land has been land, and water has been water. To create more believable maps, with further customization possibilities, that sadly does not suffice. The filters that are being applied need more details about the geography to make smart decisions. I've added a few "Scanning" filters that basically tags each pixel in the map with additional information. Now each pixel knows the following:

  • What is my altitude? Am I above or below sealevel?
  • Am I in a river?
  • Am I on land, but next to a river? (A riverbank)
  • Am I along a coastline?
  • Am I in a lake?
  • Am I in an ocean?
I plan to add more information at later stages, - as this is fundamental to tailoring content.

Smarter Cities

Previously, when I generated city names, I had no way of making sure that the city names were fitting for their location. Now I can make sure that City 1 should be along the coast. Since I know this, the city name generator can now delegate its work to the specialized coastal-city name generator. No longer will the super-secret city of the pirates "Skullport" be located way up in the mountains :)

Refactoring, cleaning code, and battling high memory usage!

A little history...

This project started as nothing more than testing some noise-generation algorithms. In fact, even the Visual Studio project was called "TestProject". From there on as new ideas manifested, code began to take form. But my mental image of the code was still that it was just something that I wanted to try out, because it could be cool. So alot of code sprang forth as proof of concepts, with many try & fail iterations on most features. After a while, things settled and I started building further on what I had. The problem was that I never really took the time to clean everything up, refactor, and improve. I'm a huge fan of clean code, and  at some point I tried to reduce cyclic complexities and statements per method. However, about halfway through the code I  realized that when dealing with such computation-heavy code, cleaning up the code created a huge performance overhead. In most everyday projects it's still worth it, but not here. Performance is a key success factor, and it's still too slow for my liking. But alas, further performance optimization has been put on the backburner.

Anyway, without focusing on "clean code" specifically, I've refactored and beautified the code significantly over some time now. The next problem was trying to cope with huge memory usage. It has never been a goal in itself to use as little memory as possible, but I felt at some point the usage was ... Well, a little extreme. I've taken steps to reduce memory usage somewhat, replacing huge array copies with pointers and unsafe code where it seems reasonable. Memory usage is down, but it still chews through quite a bit.

All in all, today I am happier. Not completely content, but happier.