This post will go into specifics about some of the coding challenges faced and will be a bit technical just as a warning. The first big hurdle that i faced was getting the obstacle avoidance steering behavior to work right. All the methods for implementing it that I could find documented largely depended on having a precise point of collision to calculate from as well as having some kind of bounding box around the object. However the way that are collision system was set up it could only tell me which side of the ship that I had collided with and not where. The bounding box problem I solved by creating my own based on the current dimensions of the ship and while not precise did the job. Then I had to solve the problem of getting a point by doing a plane to line segment test on the side I knew I had collided with. This mostly worked out but do to slight discrepancies between the dimensions stored in the ship class and the actual model size occasionally makes for strange behavior. The next problem with the avoidance algorithm did not occur till much later in the project. This was once the island objects where added into the game and had a slightly different method of checking collision against them. This involved a line segment to circle check and normally would have gone fine but some where in the calculations a float over flow error was happening. I had never seen this error occur before so it took me some research to find out exactly what was happening. After that I was able to solve the problem by putting in some checks to prevent the over flow as well as fixing a heap corruption error I shall mention later but it was still annoying because it consumed a good couple of days time.
Other then the problems with the obstacle avoidance the only other major AI problems where mostly a result of my designing a system that I had never tried to create before. This lead to me having to redo the code system a few times as well as having to rewrite several functions. For example I had not planned to need a function for calculating the average firing distance from the middle range weapons on the AI ship to the player ship but had to add it in later when some of my other functions ended up needing this information. Most of the changes where miner additions like this but they where unplanned do took up time on the schedule. Fortunately I had allowed for some of this to happen so I did not end up being too bad. The longest part of this was actually writing the scripted decision trees themselves. This I had not anticipated and did put me a little behind. The delay was mostly having to go back and edit an existing tree over and over again till i achieved the type of behavior I wanted that particular AI to have. In the end it was all still done on time but it did take a little longer then I thought and did not leave me as much time as I would have like to try to go back and stream line some of the old code that I had written. I guess I should have done that as I wrote the code but at the time since I had scheduled for it I did not worry about it.
The last major coding problem that I faced in the game had nothing to do with the AI coding but with tracking down a heap corruption error. We had been seeing the error pop up in out files for some time since the start of the project and several of us had tried to fix it but nobody had had any luck at it yet. It was pretty miner at first only causing a break point to be hit in debug mode and not having any real effect in release. However it eventually started to have effect in other systems in the game. At this time I was a little bit ahead of schedule so I decided to take a look at it. I went through every line of code looking for possible places that could cause that kind of bug. I had to do this because we had already tried more traditional bugging techniques and was getting no where with them. After reading through the code I finally tracked it down to a problem in out font system that was using local memory to create some of the storage classes for the fonts. It was a very easy fix once I found it but it was hard to find.
Well thats the hight lights of the coding challenges that I ran into a few other things where took a lot of work to get done but still fell into the area of work that I had expected to have to do. Other miner bugs showed up as well but nothing that took more then a couple of hours to track down and fix.