Thursday, December 6, 2007

Debugging, Distribution, Tile Engine

A few hours of the day were spent debugging. I had a problem with the people's behavior. For some reason, when a segment was just almost fully packed with people, all the people would all of a sudden jump backwards behind the nodes, out of the segment entirely, then come back in. I was baffled too.

Anyway, a whole lot of divide and conquer to find the single erroneous line of code...excuse me, erroneous number. All that work just to find one simple small number. But it was fun though. It was a real challenge, and it feels good when you fix it and the bug is gone forever. In the process, I also found a few other small details that needed tweaking. So all in all it was sort of productive.

Of course, there were other minor glitches and so forth that I've come upon and fixed involving severing and retracting. It seems most problems are triggered by one of the two. But they're becoming more stable every day. I'm pretty confident in them.

I hit a problem with the grid testing. I've mentioned before that when testing against a segment, you have to test every grid square it passes through. The code for it is a heck of alot simpler than the code in my last iteration and faster too. But it's also newer and thus more prone to error. It was fine when testing down and to the right, but any other direction and it hit a never-ending loop.

I had to look at the math and figure it out. Sometimes my mind fogs up when I try to do math in my mind. But after about 10-15 minutes of trial and error, it clicked. Doh! The solution was simple and the test now works wonders. Also, to make sure it was working as intended I wrote a few extra lines of code to display an X over every square tested.

I added a little to the..."Person Distribution AI" we'll call it. To start with, each time a person hits a node, the node has to decide which of its branching segments to put the person in. I use a little recursion to determine the cumulative density of each path and all beyond it, and place the person in the one that is least dense. That's old hat. What I did today involved only segments that are retracting. Their density returns as 100%, which means no person in their right mind will try to enter it. More people are saved this way.

I created a simple tile engine. So far there's only one tile. It'll probably stay that way for a bit; I just wanted the tiles there for the sake of progress and prettiness. I'm still open for suggestions if anyone knows of a better method than a grid of tiles. Anyway, even though the tile isn't great, it's better than nothing.

Suggestions? Questions?

clevceo

No comments: