Artificial Intelligence Depot
Visiting guest. Why not sign in?
News, knowledge and discussion for the AI enthusiast.
FEATURES COMMUNITY KNOWLEDGE SEARCH  
Flesh and Machines: How Robots Will Change Us
Antitechnologists may shudder at the story line, but readers interested in the astounding possibilities of the digital age will be fascinated by Brooks's vision of what is and what will be.
More information at Amazon US UK
2d shooter AI
Help me with some AI for my 2d shooter game!
 
2d shooter AI

I've made a 2d shooter game called XOP. It's a very difficult game to complete, if you play it you'll see why :)

Check it out here : http://rydia.net/udder/p_xop.html

I was wondering if anyone had any advice towards writing an AI that would be able to complete XOP, or atleast get through level 1 without getting killed. IMO, it would be quite a challenge considering the amount of stuff the game throws at you. I'm looking forward to hearing what you guys have to say :)

- Chris

3 posts.
Tuesday 18 December, 01:19
Reply
Downloading

I'm downloading the game as we speak... or as I type ;) I'll dump my brain once I've got the hang of it!

Looking forward to it :P

934 posts.
Tuesday 18 December, 20:44
Reply
Shooter AI Ideas

Chris, sorry about the delay...

As you said, the game is tough! I played for quite a while, and still can't beat the end of level 1 boss ;)

I've got a fair number of tips for potential improvements, but since you're in beta, I'm not sure you're still 'open' to suggestions. So let me know!

Right, for the AI. It's a tough one, but I reckon a good old search is the way to go. In essence, you'd split the area into little zones, and evaluate how valuable they are. First you'll need to predict projectile positions using dynamics, and set those zones to 0 desirability. Then, you'll need to evaluate the potential for destruction of particular zones, by giving it a high reward if you're just below the enemy (and can shoot directly upwards). Then just do a mimimax search, and you're in business.

That probably sounds a bit simpler than it really is, but with a bit of experimenting, I'm convinced that would work. The key, of course, is the evaluation function... you can probably get the agent to learn how to evaluate positions, by learning weights or something. But a good place to start would be to hardcode some default values.

Hope that helps!

934 posts.
Wednesday 26 December, 19:46
Reply
Thanks

> I've got a fair number of tips for potential improvements, but since you're in beta, I'm not sure you're still 'open' to suggestions. So let me know!

Fire away, but just don't include "Make it easier" - it ain't gonna happen ;)

> you'd split the area into little zones, and evaluate how valuable they are.

How big do you think the zones should be? Just so you know, the actual hit rectangle of the player is a 2x2 block in the center of the ship. It can get away with alot :)

> First you'll need to predict projectile positions using dynamics, and set those zones to 0 desirability.

I'm confused by this. What do you mean by dynamics?

> you can probably get the agent to learn how to evaluate positions, by learning weights or something

You mean telling it to keep values that make it survive vs. values that make it die? :)

- Chris

3 posts.
Thursday 27 December, 02:21
Reply
Position Search

Right, suggestions...

- In full-screen, scale the playing area to fit... I had a little black area all around the view. There's so much going on that you need the game as visible as possible.
- A help menu, with the keys. I found ENTER nearly straight away, but it took me a while to find Z/X combo.
- Some bonus items are similar to small projectiles. Make them glow or something.
- How come some enemies can stop and rotate when the player can't?

Ideally, the zones would be 1x1 pixels. That would give the best results for the AI. The search should also be very deep, looking into about 10-20 positions ahead. This won't be possible, however: too expensive. So you'll probably end up having a 4x4 grid, and 4-8 position look ahead. If you're really interested, there are plenty of ways to improve this once you've got the basics working.

Dynamics is a branch of physics that deals with applying computing the position of a body given its velocity and acceleration. So it's stuff you're already doing! Just make sure it's really efficient, so you can do some good motion prediction. If the acceleration does not change, you can solve the equations of motions without having to simulate them.

> You mean telling it to keep values that make it survive vs. values that make it die? :)

Essentially, yes. The AI would learn how to evaluate properties of the position:

Characteristic / Desirability
Collision / 0
Position: Middle-Side / 70-20
Below Enemy / 90

And to combine them together, just add them up, and you get the total desirability. But as I said, you can set those coefficients manually pretty well, since you have a good knowledge of the game itself.

934 posts.
Thursday 27 December, 09:22
Reply
Moo

> - In full-screen, scale the playing area to fit... I had a little black area all around the view. There's so much going on that you need the game as visible as possible.

This will make the game run slow, and additionally make it look really ugly :) If you want the game to fill more of the screen, you can set the screen size to 512x384 in the options menu.

> A help menu, with the keys. I found ENTER nearly straight away, but it took me a while to find Z/X combo.

I didn't think the game was complex enough to include it.

> Some bonus items are similar to small projectiles. Make them glow or something.

Which ones? The only bonus items are the coins and reflect shields. They're both bigger than the bullets and animated :X

> How come some enemies can stop and rotate when the player can't?

Hey, the player can stop .. just not rotate :) I used the standard 8-directional movement for the player because it is much more precise. You need alot of precision movement to survive in XOP!

> you'll probably end up having a 4x4 grid, and 4-8 position look ahead.

The screen width/height is 400x300 .. I made an array : int zoneMap[100][75][6];

Is that right?

I'll try to get some code going.

- Chris

3 posts.
Thursday 27 December, 18:58
Reply