• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Drilian

Racing AI (with complications)

8 posts in this topic

Having read through some of the other racing AI threads on these forums, I've noticed that most of them involve creating an AI that follows a developer-specified optimal racing line. But my tracks are hideously loopy: My Journal, for Screenshots. I really would rather not have to manually create a racing line for each track. Mostly because I don't even know that I could FIND an ideal sort of racing line. Heck, I'm not even sure that, as bad as I actually am at racing games (don't let the fact that I'm writing one fool you), I could even DRIVE a fairly optimal line. And another wrinkle: In addition to the steering and the accelerator (which includes the brakes), there's also a "slide" button, which turns off the motion dampening in the car's sideways movement (i.e. holding "slide" allows the car to continue moving in the direction it's going, even if the car turns). I'd like the AI to be able to use that feature, though I won't be terribly heartbroken if it can't. Is there any other sort of way to generate a near-optimal racing line? Or to make an AI that can use other attributes of the track to drive such a track? Suggestions? I'm new to this whole AI business, so it could be (And is even likely) that I'm missing something horrendously obvious. Please feel free to point it out. Thanks much, Josh
0

Share this post


Link to post
Share on other sites
I always see this type of problem as follows: Discretize the set of decissions that the AI can take at any given time, discretize the time intervals at which decissions are made, look at the problem as a search in a directed graph. If you can somehow discretize the states and then "round" the intermediate results to the discrete states, your search can be sped up tremendously.

You can precalculate optimal paths this way, or you can have the AI take the decissions in real time, although I am not sure if this is practical.

For a racing game, I would imagine that the state can be described by:
* how far you are from the goal (or some other single-number indicator of where you are in the race),
* where you stand on the track in the left-right sense,
* what direction you are moving in,
* how fast you are going
and perhaps you need to add another number with the direction that the car is pointing to, since you have the "slide" option.

So if you consider 10 positions within the left-right range, 64 directions of movement, 16 speeds and maybe another 32 directions for where the car is looking at, for every "slice" of the racetrack you need 320K nodes. The good news is that you can start with the last slice of the racetrack (the goal), where you know exactly how long it's going to take you to the goal (0). Then computing the slice before that one is really easy. You keep going back like this, and it is always easy to find what the cost of getting from any node to the goal is, given that you know the cost of getting there from all the positions in front of you; just imagine you take each one of the actions and look up where you would end up on the next "turn".

This algorithm only requires keeping a few slices in memory at any given time (as many as can be traversed in a single turn at maximum speed). This is a lot of data, so in the end you will have to reduce it to something practical, like storing just one (or several) good paths.

I hope this helps.
0

Share this post


Link to post
Share on other sites
First, you could use an algorithm (I prefer A*) to find sort out the path, and then do something like this: "if the angle of turn is more then n degrees, then enable 'slide' feature"...

-zubair-
PS: sorry if i was too brief
0

Share this post


Link to post
Share on other sites
Grab a copy of Ai Game Programming Wisdom 2, theres an article in there on Generating Racing Lines automatically. Page 485
0

Share this post


Link to post
Share on other sites
Thanks for the help, everyone!

A copy of AI Game Programming Wisdom 2 is on order :D
0

Share this post


Link to post
Share on other sites
While waiting for your book check out RARS and some of the cars people have done for that (may need to google for them, look for K1999 by Remi Coulom for a really awesome car, can't find the paper right now though).

Under algorithms you can see how someone used A* for it.

Here is a reinforcement learning example for RARS. Also check into neural-nets, which I hear worked quite well for Colin McCrae Rally.
0

Share this post


Link to post
Share on other sites
About that sliding thing, I recently implemented AI players in my top-down racing game Turbo Sliders. As the name suggests, sliding is an integral part of the game and it surely did add complexity to the AI code. AI cars try to follow one of 10-20 racing lines (generated by human driving) but it was quite hard to make it work with the cars that slide a lot. Are you aware of other racing games with AI where there would be as much sliding?
0

Share this post


Link to post
Share on other sites
Drilian, I would be tempted to just hand each track to a bunch of playtesters and record the paths they take, recording how they use the controls and possibly tweaking them slightly, to be used later by AI controlled characters. It might also be worth seeing how far you can go (literally) with simple steering behaviours.

And bear in mind that, relative to the track itself, the racing line is still just 2D (assuming I understand your game). The problem is easier to think about in those terms, as I believe the AI Wisdom article will cover.

PS. Ande, I love Turbo Sliders. Great game! :)
0

Share this post


Link to post
Share on other sites
I was skimming your journal and noticed:

Quote:
Original post by Drilian
Plus, the car has a force-field (or whatever they will call those things in the future), so the walls actually bounce the car more like a pinball bumper than in a realistic fashion (the force field applies some bounce force).


Combind that with sliding, and a perfect AI might end up finding some very unlikey--but very fast--ways of bouncing through corners, which you might not actually even want.

You also mention:
Quote:
Original post by Drilian
Each track segment gets the following attributes (which are relative to the track segment's initial orientation):
Length - This represents the angle of the track relative to the in-game representation of the north star. That, or just the length of the track down the middle. I can never remember which is which.
Width - Determines what the width will be by the end of the section of track (the previous section determines the initial width).
Curve - The amount of curvature of the track. A negative curve is to the left, positive is to the right. A 360 degree curve is, as expected, a full rotation.
Horizontal Skew - This is how much the track strafes to the side (along a sinusoidal sort of path) across its length. It's like a lane-change. Only the pavement is changing lanes, not the car.
Incline Curve - This is the circular incline of the track. A 360 degree value of this would be a full loop. Positive is up, negative is down.
Vertical Skew - Similar to the horizontal skew, only vertical. How's THAT for descriptive?
Twist - This is how much the track rolls to one side or the other along its length, which modifies the orientation for the next segment
Bank - This is similar to twist, except it raises one side instead of twisting around the middle, and the orientation remains unchanged in the next segment of track (this is to allow for banked curves, which I wouldn't want to curve upwards because of the bank or something stupid like that).


You might be able to use an abstraction of those for the current and next segment as inputs to a neural network. Alternatively, some sort of FuSM might also work, although the outputs aren't all that orthogonal, so it isn't the greatest place for a FuSM.
0

Share this post


Link to post
Share on other sites

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  
Followers 0