Thursday, September 25, 2003

Thinking about... Thinking...

I did the AI for a game called 'Shatterblox'. As with everything in life, I had wanted to do more to it. I think it might just be a good time to go back and make it a bit smarter.

Truth told, the AI's pretty decent for a first attempt. It can (occasionally) make it to level 4 - halfway through the game. That's about as far as a lot of people can get.

Still, I had wanted to implement a variable AI scheme so that each character would have their own way of playing and some would be easier opponents than others. Also, adding pathfinding and some feedback would allow for a much better game - and hopefully an increase in levels obtained.

The method I chose to implement the variable AI scheme requires 3 bytes per character of 'preference' data. This assumes the use of eight different approaches or 'schools (of thought)' as I call them. Currently, the AI uses only five schools to get to level 4, so that leaves me with three more 'slots' to add new schools. The way the preference system works is that the schools are cycled through (up to) three times. Each school has an inherent priority based on it's location in the code, of course, but the preference data is used to supercede this priority.

On the first pass through the schools, each school's respective bit in the first preference byte is considered. If it is a '1' then the school is used. (If a good fit is found at this point, the AI aborts the thinking process and uses that location.) If it is a '0' then the school is not used and the next school, in turn, is considered. When the first pass is complete, a second pass and a third pass follow in the same way. This allows some rearranging of the order of the schools. Additionally, this allows for duplication. This duplication would not serve a purpose in the original design of this process, but could allow for a comparative valuing system with set threshholds for each pass. Under this system, a position choosen by one school might not be valued high enough for consideration in the first pass, but might be good enough for consideration in the sceond pass. In this model, each pass would have a decreasing minimum decided value to accept.

Now if I can find time to sit down and work on it some...

No comments: