GravityBomb is a strategy/puzzle game that pits you against opponents with the objective to destroy any hostile vessels that get in your way. To accomplish that goal, you have to aim your gravity bombs with just the right angle and power to snake your way through a gauntlet of interstellar objects. It is currently being developed by Protodragon Software for release on the PC via digital distribution. GravityBomb is being developed with the XNA Framework and may see future releases on the 360 or mobile platforms.

Report RSS AI: The opponents of GravityBomb

Dragonsdoom talks about how he built the AI for GravityBomb. Originally, the AI was dumber than a boat made of pudding. Its pretty lethal now. How did it get that way? The magic of search heuristics and random seeds.

Posted by on

Intro

Hello again, Dragonsdoom here to give you some insight into the mind of the machine. Today I'm going to talk about the AI of GravityBomb and how it pretends to think. I'll be mentioning a couple programming concepts but don't get scared, I have pictures too.

Artificial Intelligence

I spent a week recently on the latest version of the artificial intelligence. In the early stages of my game the AI shot randomly. This was dumb and I replaced it with a more convincing set of code that told the AI to shoot at the edge of a planet's gravitational field. More specifically, it shot at the edge of the center-most planet's gravitational field. It worked perfectly! At least, it worked perfectly on level one:
Image Hosted by ImageShack.us

Pictured: Level 1 with the addition of asteroids.

Unfortunately, it didn't really work on later levels or levels with strange planet types. I can't really ship an AI that only works on the first level, so I talked to a few people and researched some solutions. I arrived at a solution in three parts:

  • I read about genetic algorithms (algorithm means something like ‘instruction list to solve a problem'), which is a type of very abstract problem solving solution based on how real-world genetics work. Genetic algorithms are a type of search huristic and are known for being very effective at quickly garnering a pool of possible solutions, although the solutions they come up with may not be the very best. I ended up implementing something similar, but I think mine is distinctly less sophisticated; it uses brute force techniques more than the breeding techniques genetic algorithms are known for.
  • While I was doing all that, I also rebuilt my game systems to support many simultaneous projectiles and started collecting data by firing a very large number of projectiles ‘behind the scenes‘.
  • I ran into some really serious slowdowns from all the physics calculations and how I was choosing the best shot. I looked into sorting algorithms, a popular field of study for programmers looking to manage data and found a useful one called merge sort to organize all my data in a way that helped me to remove poor quality shots from the list of available shots. I added several other optimizations along those same lines and eventually got the system as it stands today.

Here are a couple of screenshots from along the way:

Image Hosted by ImageShack.us

Pictured: An early test of the firing system. Rather pretty in its way.


Image Hosted by ImageShack.us

Pictured: Slightly later in development. The shots began responding to gravity.


Of course I had to hide everything behind the scenes for clarity, but the end result is very good.

Image Hosted by ImageShack.us

Pictured: Maybe too good.

Collision

So the AI is much better now, even at extremely challenging levels. It shouldn't one-shot snipe you out like you're playing Battlefield 3 on a pro clan-server, but it should serve a fine challenge. A few bonus stages seriously ramp up the difficulty though; I'll leave it for you to discover when the game comes out.

Post comment Comments
Newbez
Newbez - - 480 comments

lol i thought it said gravity bong and i was like "YEAH BOI!"

Reply Good karma Bad karma-1 votes
Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: