Thought for today

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." -- Brian Kernighan

I've been debugging collision response code again today. I've resorted to using a very simple case: Axis-Aligned Boxes (AABoxes) for everything. I was using a sphere for the rabbit and a cylinder for the farmer, but that level of detail was unnecessary and it confused the hell outta the code to boot.

I think I've finally got it working reasonably well. Remind me to write up a CookBook entry on this once PyWeek is over.

I also got the farmer to face the correct direction (ie. the direction of movement) which took much longer than it should have.

I also optimised the farmer's A* routine. It's now highly specific to my game, and takes less than half the time it used to take for my more convoluted map. One problem that came up today was that the farmer's hitbox was larger than the A* grid size. This meant that the A* routine would happily plot a course that the farmer couldn't follow due to running into things :) It was a bit silly, really, since the farmer doesn't need to run collision-detection routines, really.

The day's not over yet so I'm hoping to resist the lure of the telly-vision (did you know Australians download more TV than any other country?).

I'm not going to put up any more snapshots or screenies as that would ruin a couple of surprises :)

(log in to comment)

Comments

Richard, that's an excellent quote. Couldn't have put it better myself, as it sums up my feeling this morning after finally finding the cause of an elusive yet stupid bug.
"It always takes longer than you expect, even when you take into account Hofstadter's Law."

-- Hofstadter's Law.
"It always takes half as long as you expect, when you use Python." -- chr15m's addage
Am I the only one who doesn't want a White Dress?
Am I the only one who doesn't want a White Dress?