Sign in to follow this  

basic futuristic race game AI

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi folks, I'm busy with a futuristic racing game. I am making this for a handheld gaming system so resources are limited. I have 4 futuristic hoverplanes of which one is the player and the other 3 are computer driven planes. I need AI for this. The levels are build up from an ascii in which you can make straights and corners. So i don't know the level before hand so i can't make a script or anything for it. It needs to be done when i load in the file or just at realtime. How can i do this? (I never have done racing AI so please every pointer or idea is welcome). My own thoughts(can be bad or impossible) 3 ways: - creating a trackpart (straigth for example) with waypoints on it. Trying to calculate the closest and then go there but i have no idea how i should model it physicswise. - creating 1 waypoint in the middle of the trackpart and then always let the plane go to the next one (only then i really don't know how to model overtaking.) - checking how close you are to a wall (every trackpart has walls so you can't go out of the track) and adjust your direction to go as far from both walls as possible ( this will not work when approaching corners, you will simply go to fast i guess.) well as yo ucan see i have some thoughts but since i have not done this I hoped you could guide me into the right direction. greets ghotirein EDIT: it is at the moment a 2D problem since i do not have hieght differences. However I hope the give solution will take into account that i want to expand it maybe in the future to a 3D problem. [Edited by - ghotirein on June 1, 2007 3:10:24 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by ghotirein
- checking how close you are to a wall (every trackpart has walls so you can't go out of the track) and adjust your direction to go as far from both walls as possible ( this will not work when approaching corners, you will simply go to fast i guess.)

You could use:
X = (lane_width / Distance to left wall)
Y = distance to next corner.
nextCornerSide = next corner is right or left.
ClosestOpponentDistance = distance to the closest opponent in front.
ClosestOpponentX = Same as your X but for the closest opponent.

Base behavior:

1[base] * MoveToX(1/2);
2[prepare for turns] * if (Y < turnSafetyDistance) desiredSpeed = f(Y); //f should give the proper speed to enter a corner.
3[overtake] * if (ClosestOpponentDistance < distanceToStartOvertaking)
if (ClosestOpponentX < 1/2)
MoveToX(3/4);
else
MoveToX(1/4);

You have to compensate 2 and 3 with nextcornerside.

Share this post


Link to post
Share on other sites
There's a pretty exhaustive set of articles about how to set up a racing game on this site. I'm sure you can repurpose anything in their to suit your game.

I can't find the articles at the moment (got bored looking) but just browse around the Articles & Resources section.

-me

Share this post


Link to post
Share on other sites
Hi

@ Palidine: Well i have searched on the site but i only found a lot of articles about real racing games and all the physics that come along with it. My raing game is more a simple SNES mario kart kindof game. But I will try to find some articles about AI see if I can simplify it a bit to only suit my needs :)

@ Zanshibumi: I get it for the straight parts but how do i calculate X when in a corner ? and what exactly do you mean by

if (ClosestOpponentX < 1/2)
MoveToX(3/4);
else
MoveToX(1/4);
Do you mean here that if the opponent is on the left side of the track then overtake on the right otherwise overtake on the left ? (or vice versa)

Share this post


Link to post
Share on other sites
Quote:
Original post by ghotirein
@ Zanshibumi: I get it for the straight parts but how do i calculate X when in a corner ?

You subtract the distance of both sides from the center of curvature.

Quote:
Original post by ghotirein
if (ClosestOpponentX < 1/2)
MoveToX(3/4);
else
MoveToX(1/4);
Do you mean here that if the opponent is on the left side of the track then overtake on the right otherwise overtake on the left ? (or vice versa)

Exactly.

Share this post


Link to post
Share on other sites

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this