[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

I put mapgen4 on hold a few weeks ago because I was having some seemingly random unreproducible freezes, where it would still calculate the map updates but it wouldn't draw them. I had tried everything (or so I thought), gotten frustrated, and taken a break. I often find that I need to take a break from something, and then when I get back to it, I figure out the problem. During this break I've been "productively procrastinating", working on several other things that I've wanted to do, including map generation on a sphere, a procedural face generator, improving touch support on many of my pages, and improving my tower defense pathfinding page. I ended up also experimenting with a better interface for my mouse-drag code, a recursive renderer in Vue.js, and a D3 + Vue.js experiment in which Vue keeps track of dependencies for D3.

Mapgen4's style takes inspiration from hand drawn fantasy maps

It's time to get back to work on mapgen4.

Within 10 minutes I had written a test environment to try to trigger the bug. It didn't. But the test environment in combination with moving the sliders around triggered the bug reliably. There were 2 sliders out of 27 that would cause the symptoms I was dreading. But in making the problem reproducible, I had made it much easier to find the problem. Within another 10 minutes I had fixed it. Yay!!

I believe I have fixed the bug, but it's possible there's another bug hiding in there.

Why was I able to find this now but not earlier?

  1. I was frustrated earlier. After taking a break, I'm calm. Being frustrated makes it harder for me to figure things out.
  2. I was looking in the wrong place. I was convinced it was a problem with my multithreading (in part because multithreading is such a common source of bugs), but it wasn't.
  3. By taking a break, my brain generated new hypotheses in the background. At some point, maybe a week ago, a thought came to me: there's some weird behavior with rivers. When I came back to this project, I discovered that the weird behavior was linked to the bug. The problem is that occasionally, no rivers are large enough to be drawn, and my code tries to draw 0 rivers. This seems to mess up the graphics state. I fixed it by only drawing if the number of rivers was greater than 0.

I'm posting this in part to remind myself to take more breaks and to get frustrated less.

I can now get back to implementing the remaining features. Yay!

Go play with the mapgen4 beta! If you run into a bug, let me know!

Labels:

2 comments:

Scott Turner wrote at November 13, 2018 10:31 AM

Lol @ the zero rivers frustrating you for so long. Well, that's how it goes.

I love playing with the beta, btw. Very responsive, especially compared to my system, which takes minutes to generate and render!

Amit wrote at November 13, 2018 11:14 AM

Thanks! Yes, that's how it goes :-)

In this project I was optimizing for speed. I picked simpler algorithms that would run fast instead of cooler algorithms that would produce nicer output. I think it worked pretty well, but there were soooooo many times I had to skip something that would improve the maps.