# Racing Game, factor speed and angle.

Page 1 of 1

## 4 Replies - 564 Views - Last Post: 14 June 2013 - 08:38 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=323005&amp;s=0d2f19770292d1a2b6a6085eb0d92a6d&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Asthenia

Reputation: 0
• Posts: 51
• Joined: 14-May 09

# Racing Game, factor speed and angle.

Posted 14 June 2013 - 04:31 AM

I'm writing an AI system to drive round a track that I have created. My maths isn't all that up together, so I'm struggling to think about a formulae for it.

So far the car has a steering input(how much he needs to steer), speed, brake.

I'm doing it using a node system, to place along the track so he can find his way.
What I want to do is get a formulae to calculate that when he has to turn a sharp corner, factor in the speed in which he needs to travel at.

Sorry that I can't explain very well, my maths understand isn't all that great.

At the moment, I'm using if statements to calculate if the car is turning an angle > then x then steer.
But as you can see this has flaws as it doesn't take all different angles into account.

If you need me to try and explain better, please let me know and I will try.

Is This A Good Question/Topic? 0

## Replies To: Racing Game, factor speed and angle.

### #2 tlhIn`toq

Reputation: 5871
• Posts: 12,786
• Joined: 02-June 10

## Re: Racing Game, factor speed and angle.

Posted 14 June 2013 - 07:23 AM

Is there a question in there somewhere?

I'm sorry for the level of truth in this statement but...
If you're coding skills are still introductory where you are doing it all with ifs, and your math skills aren't up to the task of the program, then writing an AI for a game is probably not something you are ready to take on - YET. You'll get there. But you might consider more tutorials and concentrate on learning more before you start trying to architect solutions. Being a program architect is something you do after having been a coder for a while.

This post has been edited by tlhIn`toq: 14 June 2013 - 07:23 AM

### #3 Asthenia

Reputation: 0
• Posts: 51
• Joined: 14-May 09

## Re: Racing Game, factor speed and angle.

Posted 14 June 2013 - 07:55 AM

Thanks for giving me advice, I understand what you're saying. But you were here at my level of skill at some point in your life.
How can I learn new things if people aren't willing to explain to me the process involved?

My question still stands, if someone would be willing to point me in the right direction in going about this, then that would be great.

Thank you.

### #4 tlhIn`toq

Reputation: 5871
• Posts: 12,786
• Joined: 02-June 10

## Re: Racing Game, factor speed and angle.

Posted 14 June 2013 - 08:26 AM

We were all at your skill level when we started. And it is with that understanding that I suggest you are over your head.

Just like you, I tried designing programs before I had the skill to write a good method. All it does is result in really bad habits that then require more effort to break, and make you very frustrated.

You wouldn't learn construction by nailing a bunch of boards together with no blueprint then calling it a house. First you learn basic techniques and how to use the power tools. The work up to installing doors and door jams. Along the way you study other people's design and blueprints. You dissect their methods and techniques. Eventually you learn to make your own blueprints that take into account all the little things you learned on your way up the ladder.

The exact same thing happens in coding. You need to learn the language. Then you learn more and more about the tools (the various .NET namespace in the case of C#). You need to learn techniques of recursion instead of a 100 if statements. You dissect other people's designs as there are thousands of publicly available source code programs out there. You read through C# cookbooks that take a problem-solving approach and explain why a particular network search was done a given way.

If you were learning auto mechanics, you wouldn't start by trying to design and build an 18-wheeler when you can barely turn a socket wrench. You might build a go-cart. Then a dune buggy. Then tear-down and restore an old Chevy so you can learn from an already well-engineered product. Eventually you might sit down and design a simple car from scratch. Then a nicer car with more features. And so on.

### #5 Asthenia

Reputation: 0
• Posts: 51
• Joined: 14-May 09

## Re: Racing Game, factor speed and angle.

Posted 14 June 2013 - 08:38 AM

I understand what you're saying. Thanks for taking the time to write that out for us, much appreciated.