🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

how to write a Worms Reloaded AI

Started by
4 comments, last by LorenzoGatti 10 years, 7 months ago

new to the pixel world,i have just read a topic about how to run on pixel terrain.and shoot holes.

i want to write a simple game like Worms Reloaded,but now get no idea how AI works.

basicly if i shoot a missile,i solve a parabola equation,and i get the answer.

but the missile may be block by the map terrain by its shape,and different ways to shoot at target.

so i think it's infinite solution,and not effective to loop a lot possible solution and check if they are right solution.

guess maybe there is some better idea?

Advertisement

Hummm... I think its a misunderstanding about AI...

Are you talking about Physics?? AI is the process of decision making, I mean, what kind of weapon the 'computer characters' will use in each situation ( assuming they may change weapons ) and how the characters will decide witch player to attack...

If the problem is how the projectiles interact with the map, so you may search for help with physics or something like that...

So.. you need help with Physics or AI? or both? :)

KrinosX

new to the pixel world,i have just read a topic about how to run on pixel terrain.and shoot holes.

i want to write a simple game like Worms Reloaded,but now get no idea how AI works.

basicly if i shoot a missile,i solve a parabola equation,and i get the answer.

but the missile may be block by the map terrain by its shape,and different ways to shoot at target.

so i think it's infinite solution,and not effective to loop a lot possible solution and check if they are right solution.

guess maybe there is some better idea?

I think it's pretty reasonable to try lots of different solutions and pick one that works, computers are fast!

There's no reason not to solve the parabola equation for 10 or so different launch speeds and collision test all the results you get. You could probably multiply that up by a number of different launch positions your AI might consider walking to too, and still not really tax the CPU. Put a bit of effort to make sure you can distribute the work over multiple frames (extra marks if you multithread it), and it'll be fine.

Yeah I converted a golf game and that's how the AI worked for that (take loads of shots, give them a score based on distance to hole, terrain the ball ends up on, etc.). And that was on PS1 (so slow compared to PCs these days, and it was 3D too). In order to not get a hole in one on all par 3s if it was possible to do it the computer randomised the shot taking algorithm (power bar etc.) by adding on a parameter drawn from a normal distribution table (mean was best shot power/ball strike location, standard deviation depended on AI level).

The normal distribution was just a table but I think C++11 has Gaussian (normal distribution) random distributions in the <random> library. Picking a utility value for a shot (i.e. the score awarded to each test shot) is probably a lot easier for a Worms type game since you can score damage dealt (although positioning could be a factor too for counter attacks).

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

Hummm... I think its a misunderstanding about AI...

Are you talking about Physics?? AI is the process of decision making, I mean, what kind of weapon the 'computer characters' will use in each situation ( assuming they may change weapons ) and how the characters will decide witch player to attack...

If the problem is how the projectiles interact with the map, so you may search for help with physics or something like that...

So.. you need help with Physics or AI? or both? smile.png

both i think,first for AI to pick a right way to shoot,and this shooting algorithm requires physics about terrain,actually need Math and Physics i guess?

and because is's a 2d game,it may also need some graphics algorithm to run parabola on pixels and effective?

so many things involved...


So.. you need help with Physics or AI? or both? smile.png

both i think,first for AI to pick a right way to shoot,and this shooting algorithm requires physics about terrain,actually need Math and Physics i guess?
and because is's a 2d game,it may also need some graphics algorithm to run parabola on pixels and effective?
so many things&nbsp;involved...

Learn about one thing at a time.

Step 0: showing a window, accepting keyboard output, and shutting down properly.

Step 1: displaying moving sprites.

Step 2: displaying animations of projectiles (according to physical models).

Step 3: collision handling and explosions.

Step 4: destroying terrain.

Step 5: falling terrain.

Step 6: worms and pickup items, supported by terrain.

Step 7: walking and falling worms (player-controlled).

Step 8: a full game for human players, without AI (hotseat).

Step 9: AI-controlled worms who do anything player-controlled worms can do, with pluggable AI modules. This is a game architecture task, not an AI task; the first AI modules should be simple demos (e.g. walk in a random direction as far as possible then shoot a random weapon in a random direction).

Only at this point you should begin to worry about what AI behaviour is fun; you might discover, for example, that lobbing a cannonball on a perfect parabolic trajectory is too effective because there are too many open spaces and the player needs several attempts before hitting, resulting in frustrating mortality (this is what happens in Scorched Earth against the best AI).

Golf is completely different from Worms clones because if the AI opponent has a great shot the consequence is a slightly more challenging score to compete against, not immediate and unfair defeat.

Regarding AI, I recommend planning with straightforward strategies that the players can recognize: shooting obstacles until there is a clear path to shoot an objective, walking to safe places, erecting walls and walkways, digging a relatively safe pit and taking advantage of wind to shoot vertically out of it, etc.

Omae Wa Mou Shindeiru

This topic is closed to new replies.

Advertisement