Submarine AI

Started by
1 comment, last by Adam Hass 22 years, 11 months ago
Hey, I''m working on AI for my game which will feature submarines. At this time I am working on an NPCMgr in C++. I was wondering if anyone could help me with programming the AI, I desperatly need help with this. If you have any reerence sites for this that would be cool, thanks. Adam Hass
Adam Hass
Advertisement
quote:Original post by Adam Hass

Hey, I''m working on AI for my game which will feature submarines. At this time I am working on an NPCMgr in C++. I was wondering if anyone could help me with programming the AI, I desperatly need help with this. If you have any reerence sites for this that would be cool, thanks.

Adam Hass


Many submarine games use a system of "attractor/repulsors" to help wolfpacks find ships and ships to avoid subs. Subs are "attracted" to ships they sight based on the target''s tonnage, vulnerability, etc. They''re also "repulsed" by any escorts such as destroyers and the like.

This makes for a fluid, realistic flow to an engaement. Once a sub spots a target ship, it will move towards it towards its most "attractive" side--a combination of firing position, optimum range, etc. It will try to avoid any escorts by being pushed "away" from them.




Ferretman

ferretman@gameai.com
www.gameai.com

From the High Mountains of Colorado

Ferretman
ferretman@gameai.com
From the High Mountains of Colorado
GameAI.Com

Actually, this topic appeared recently as a thread in comp.ai.games. The poster was asking how to do path planning with dynamic obstacles. Here you are trying to move toward the dynamic objects, rather than avoid them. The same technique can be applied.

Potential fields are a method of path planning that you can find reference to in the literature. To summarise:

Assign negative ''charges'' to each of your targets, varied by how ''attractive'' they are as Ferretman mentioned;
Assign a positive ''charge'' to all things you want to avoid, again weighted by how ''unattractive'' they are;
Assign a positive ''charge'' to your object (lets assume its the NPC sub).

The desired direction of the velocity vector of the NPC sub is the negative gradient due to the sum of all potential gradients at the point of the object.

In ''lay'' terms, think of this problem as a set of hills and valleys and the submarine is a ball. Things you want to avoid create hills with them on top. Things you want to move to create a valley with them in the middle. Place all of the hills and valleys in your domain and at the point of the sub sum the height contributions from each hill and valley (positive and negative values) to get the mean height (field potential) at that point. Now, work out the local gradient (where the sub is) and align the velocity vector with the direction that minimises the height (ie, points down the local hill). This would be the direction the ball (sub) would roll down if you let it go at that point.

Update this every time iteration of your AI code.

There are some ways to make this computationally more efficient but I wont go into them unless someone really wants to hear them.

Hope this helps,

Tim

This topic is closed to new replies.

Advertisement