Bullfrog: Improving AI

I’ve been steadily plugging away at my list of bugs and enhancements for the upcoming release and finally tackled one area that I had been avoiding: improving the AI of some of the bugs.

Most of the bugs had a pretty random set of behaviors depending on how close to the edge of the screen they were moving. But other than keeping them from getting stuck in a corner or wandering off screen, their decision trees were pretty simple.

  1. “How long since the last time I turned?”
  2. “Which direction do I turn this time?”

The only bug that had any intelligence to speak of was the feared mosquito. Since the whole purpose of the mosquito’s life is to harass the player and steal valuable time off the ticking clock, it needed to chase the frog and buzz him. So the mosquito’s decision tree looked something like the following:

Unfortunately, I didn’t have time during the contest to really give any of the other bugs any convincing artificial intelligence. I made a crude attempt at making the Horsefly flee the Bullfrog if it ever came too close, but I was unable to get it to work without the fly trapping itself in the extreme corners of the screen.

With this upcoming release, more of the bugs finally have some “intelligence” to them. I revisited the Horsefly code and was able to rewrite the AI code to give the fly some simple evasion behavior, but it’s now smart enough not to get trapped. Well, okay not quite smart, but it falls back on its random behavior if it gets too close to the edge of the screen. This completely eliminates the trapped fly problem.

With this small success, I also attacked the bee’s AI. In this case, I didn’t want to add any intelligence, but to cause the bee to go into a frenzy when approached by the frog. My approach was to simply increase the bee’s movement speed when the frog came near. This gives the illusion that the bee is agitated by the frog’s presence.

Granted, these changes aren’t rocket science but they do break up the repetitious pattern of random movement at constant speeds.

With these changes “in the can”, I’m down to four items left on my list. Hopefully, I’ll have the time to get these coded and tested in the next week.

The only real hurdle left is finding a way to test the Universal Binary so that I can include that as part of the release.