Page 1 of 2 12 LastLast
Results 1 to 10 of 18

Thread: AI for car game

  1. #1

    AI for car game

    Hi! I'm currently implementing some basic CPU-controlled cars for my game.
    It's a bit harder than i thought
    What is the preferred way to implement something like a car that follows a road ?

    My try was this: i've placed some points along the track, near curves etc, and i programmed the car so that it heads to the next point, and once reached go on with the next one.
    This kind of work, but there are some good problems:
    • -If the car for some reason miss the point (ie it is pushed by another car), it tries to go back to that point before proceeding with the following.
      -The CPU cars tend to align one after the other, and all follows the very same path
      -Cars don't avoid obstacles.

    I don't need a to have extremely good AI, but something working and easy to implement
    Any suggestion ?


    PS how the hell does that list tag work ?!
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  2. #2

    AI for car game

    If the car for some reason miss the point (ie it is pushed by another car), it tries to go back to that point before proceeding with the following.
    Perhaps you should not think in terms of points, but rather in lines.


    The CPU cars tend to align one after the other, and all follows the very same path
    This could be avoided by giving each car different setups for stearing, speed (in curves or longer parts of road), breaking, pull ups etc.
    Also, but this may get a bit harder. You want your oponents to act like a real racer. ie each driver wants to be first. You can't win if you stay behind other cars, so they should attempt to get past other cars.

    As for avoiding obstacles, a basic detection setup, like detecting if theres something blocking your path within a few car lengths ahead, move out of the way accordingly. (You can also use this procedure to detect if an other car is ahead of you and want to go past it.)

  3. #3

    AI for car game

    you could use ray casts for the obstacles detection, that would also work for detecting other cars around you (just shoot off a few raycasts in different directions)

  4. #4

    AI for car game

    Quote Originally Posted by tux
    you could use ray casts for the obstacles detection, that would also work for detecting other cars around you (just shoot off a few raycasts in different directions)
    Ok, that would be easy (since ODE already support this), but the difficoult part comes after.
    If i detect the obstacle, what can i do ? It is impossible to do a nice "turn around". It should check whether the object is moving or not, choose to go left or right and the entity of the turning, choose how much staing in "surpass" and when reentering the "normal line". Also, some part of the tracks are thight, so you should check if moving away from the "normal line" will cause the car to bump on the border..
    I don't think i'm able to do all this things.
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  5. #5

    AI for car game

    Hi Nicola,
    Basically what I put in the email were the following links...

    Craig Reynolds ( Excellent site ) - http://www.red3d.com/cwr/steer/

    Steering Behaviors For Autonomous Characters - http://www.red3d.com/cwr/papers/1999/gdc99steer.html

    AI used in Colin McCrae - http://www.ai-junkie.com/misc/hannan/hannan.html

    AI Madness: Using AI to Bring Open-City Racing to Life - http://www.gamasutra.com/features/20.../adzima_01.htm

    OpenSteer - http://opensteer.sourceforge.net/

    The BEST place to start for this sort of thing is Craig Reynolds page and he is one of the original guys ( IIRC ) who formalised steering an flocking behaviour, in terms of algorithms. The Colin McCrae AI and AI Madness articles are also very interesting.

    Lastly OpenSteer is an opensource implementation of steering behaviour, I have not looked into it, but may be they have a C interface that Pascal can interface to.

    I hope you find this usefull.
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #6

    AI for car game

    Another couple of links which you may find interesting are...
    Towards More Realistic Pathfinding - http://www.gamasutra.com/features/20.../pinter_01.htm

    Polygon Soup for the Programmers Soul: 3D Pathfinding - http://www.gamasutra.com/features/20020405/smith_01.htm

    Actually every single game developer on the planet ( maybe even this solar system ) should be a member of the gamasutra ( http://www.gamasutra.com/ ) site
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  7. #7

    AI for car game

    Thanks! I've lot of free time at work today... i'll study that links

    BTW Anybody tried the last version of funkycars? What about the current AI for CPU cars ?
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  8. #8

    AI for car game

    Uhm i've read Craig Reinolds paper. It's path following algorithm is very interesting.. Quite better than mine! It's also not too difficoult to implement.
    I'll surely try it.

    He also describe the obstacle avoidance algorithm, but i think it will be much more difficoult for me, since he uses "actors" that have much more freedom of steering than a car. He can add "side force", while i of course can not

    Also, i've found interesting the use of a neural network for driving a car. Does this really works ? Anyone experienced with NN here ?
    If you save your data in a proprietary format, the owner of the format owns your data.
    <br /><A href="http://msx80.blogspot.com">http://msx80.blogspot.com</A>

  9. #9

    AI for car game

    There is an article on NN over @
    http://www.ai-junkie.com/ann/evolved/nnt1.html

    and it also includes some Delphi code.

    Hopefully that should get you started in NN
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  10. #10
    Co-Founder / PGD Elder WILL's Avatar
    Join Date
    Apr 2003
    Location
    Canada
    Posts
    6,107
    Blog Entries
    25

    AI for car game

    This article can also be accessed through the PGD Library aswell.

    I'll be putting up it's sister tutorial up today so it will hopefully shed some light on Genetic Algorythms for you aswell. Fupster's theories involve the use of GAs and ANNs together.
    Jason McMillen
    Pascal Game Development
    Co-Founder





Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •