Page 1 of 1
Posted: 09 Aug 2012, 22:13
Citywalker
Hi.

This is what is called the "Expert AI" at RVZT.

It makes the Re-Volt AI run difficult vehicles in slippery places better than they do with original stock AI parameters, and it runs decently some vehicles that no AI (V1207 or V1.2) has ever been able to run before.

I was told that my tutorial was too mathematical and hard to understand.
Okay, I’ll make it simple.
You don’t have to read all this long post, if you don’t want all the background info.
All you need for tuning is this:
• The spreadsheet that automates the calculations (xls and odt, also usable via e.g. Google Docs): here;
• The track for tuning the Expert AI: “8 on Ice” here;
• Latest V1.2, or WolfR4 by Jigebren: here.

The spreadsheet includes short instructions and a simple way to find the right AI values: input “1” or “-1” and test the result.
WolfR4 is needed for refreshing the car in-game, so you see the tuning results (or use Re-volt V1.2 and press Ctrl+R in-game).

N.B.: A key point that people seem to have difficulty understanding: doing donuts = oversteer in Re-Volt coding.

Happy tuning!





- - - - - deep technical information below - - - - -


Latest edit:
Huki’s latest V1.2 AI (beta 0815) uses the car AI part of parameters.txt in the old way again, so you can use this tutorial for both the old AI (V1207) and the new AI (V1.2). The same tuning result works for both versions, so you’re good to go in any case. The only difference is that Huki’s v1.2 AI has better crash recovery and route selection. Edit: no, the tuning value is different, and Huki's AI has a sharp excessive countersteer happening sometimes that breaks the car's flow. So it's possible for V1.2 in principle, but not perfect.
Well, thanks anyway, Huki.

This tutorial makes the Re-Volt AI run difficult vehicles and slippery places better than they do with original stock AI parameters, and it runs decently some vehicles that no AI (V1207 or V1.2) has ever been able to run before.

For best results, read also the latest finding down below (“I think I found a simple and effective place to tune the Fringe AI into Expert AI.”).

• Foreword:
All my earlier attempts were half-baked, because I was trying to do the same thing that Huki was trying earlier: find a single AI that runs everything imaginable. But this is simply impossible. Instead, I now present a method of tuning a scratch-made car AI for any individual vehicle so that it runs decently anywhere, including ice. The secret is to find a fringe value between two opposite types of bad behaviour for that specific vehicle – with that value, the vehicle runs well.

• Proof of concept:
I also have a hands-on proof of the method: there’s a link in the bottom of this post, with an AI showcase pack of the most varied lot of vehicles that I could find – most of my own racing collection, hand-picked for maximum variety of different handling effects. See for yourself, and also try racing them, so you see what the AI actually accomplishes.
And logical proof: I found why the original AI usually oversteers on ice – OverMax range is wrong. It has to be between 1.0 and 2.0, not between 0.0 and 1.0. With OverMax less than 1.0, the steering correction is mathematically too small and the car never countersteers when entering the tailspin with wheels turned maximum into curve. Result: steering locked into spin. I tried OverMax 2.0 for maximum countersteer effect and everything countersteers correctly now (even with just track AI), thus the AI can finally be properly tuned. Yay! :D

Now, on with the method.

• Start with the easy runner option (copy this into parameters.txt):

UnderThresh 5000.000000 ; switched off, it’s an easy runner
UnderRange 1 ; for simplicity
UnderFront 0 ; must be 0, otherwise vehicles don’t move
UnderRear 0 ; must be 0, otherwise vehicles don’t move
UnderMax 1.0 ; easy runner, no need for tuning
OverThresh 5000.000000 ; switched off, it’s an easy runner
OverRange 1 ; for simplicity
OverMax 2.0 ; easy runner, no need for tuning
OverAccThresh 5000 ; switched off for simpler tuning
OverAccRange 0 ; not used now, because OverAccThresh is switched off

The last 5 values can be left as-is, they mainly control route-selection.

• Tune on the track "8 on Ice", using Time Trial option.

For this, use the command line switch -gazzasaicar to run the game and select Edit mode / None. (Hint: hold RCtrl key if you want to control the vehicle yourself).
To refresh the car, use WolfR4 button of [Refresh Car Info]. This also requires the CHANGELING cheat code to be active.
Or in V1.2, press the R key.

• If the vehicle runs well with this, then congratulations, you have an easy runner and nothing else needs to be done ;)

• If the vehicle is not running well, then a suitable value has to be found for UnderThresh and OverThresh (both will have the same value). I call this a fringe value, because it’s between two types of bad behaviour, for example everything higher makes the vehicle oversteer and everything lower makes it understeer. Every vehicle has that fringe (some have it wider, some have it narrower), and every vehicle runs decently on all surfaces with that value.

• Find the stable fringe, going stepwise from 5000 down to a value between the bad behaviour and the opposite bad behaviour, always halving the step. For example, if a vehicle oversteers, then decrease the value until the vehicle no longer oversteers. If it has started understeering instead, then increase the value again until it no longer understeers. If it has started oversteering again, then decrease the value again. Go back and forth like this, always halving the step, until you find a value that’s between oversteering and understeering, so that the vehicle runs smoothly through the track. That’s the fringe for that vehicle.
On example of Candy Pebbles: 5000, (- step 2500 =) 2500, (- step 1250 =) 1250, (- step 625 =) 625, (- step 312.5 =) 312.5, (+ step 156.25 =) 468.75, (- step 78.125 =) 390.625, (+ step 39.0625 =) 429.6875, (+ step 19.53125 =) 449.21875), (+ step 9.765625 =) 458.984375. That’s where the AI is balanced for this car.
If this seems too complicated to calculate, then don't worry, use the spreadsheet template here (xls and odt, also usable via e.g. Google Docs).

• Caution:
Difficult vehicles can’t be made perfect everywhere, because Re-Volt’s static AI can't always cope with both ends of speed range if the car has very high top speed. But everything can be made _decent_.
And a tip: make two runs with each good value you find, because the result may be unstable sometimes. If a value is good for two runs in a row, then it's a sure good value.

• Depending on what the vehicle does, you will need to use four types of UnderMax/OverMax pairs. The stepwise tuning process remains the same.
Different handling types:
•• If the vehicle oversteers, then tune to no more oversteer, but not yet understeer.
UnderMax -2.0 ; oversteering, routed to oversteer code
OverMax 2.0 ; oversteering, countersteers in curves
•• If the vehicle understeers, then tune to no more understeer, but not yet oversteer.
UnderMax 1.0 ; understeering, turns more into curve
OverMax -1.0 ; understeering, routed to understeer code
•• If the vehicle needs to powerslide into curve (drifters, hovercrafts), then tune to no more tail-swings, but not yet too much countersteer.
UnderMax -2.0 ; powerslider, countersteers for balance
OverMax -1.0 ; powerslider, turns nose more into curve
•• If the vehicle needs to slide sideways into curve (copters), then tune to no more excessive left-right swing, but not yet going too straight.
UnderMax 1.0 ; side-slider, pushes sideways into curve
OverMax 2.0 ; side-slider, countersteers for balance
•• Problematic vehicles:
If tuning for oversteer or powerslide and getting no stable fringe (it still oversteers when slow and already understeers when fast), then try tuning for normal steer.
UnderMax 1.0 ; normal steer, turns into curve if sliding out
OverMax 2.0 ; normal steer, countersteers if spinning out
You can also try the oversteer pair for a problematic powerslider, and vice versa.

• And that’s it. Once you get the vehicle to run smoothly through first part of “8 on Ice”, you can go test it on other tracks of your choice and fine-tune it further if you want.

• And lastly, the proof-of-concept pack of vehicles: get it here.
These are all tuned for smooth run through Supermarket 2, and then verified in 12-car race on Neighbourhood 2 and 1.

What’s included in the proof-of-concept and why some are special cases:
Volken: stock easy runner. Easy runner, no need for tuning. Good with 5000.000000.
Sprinter: stock problem child on ice. Tuned for oversteer. Good with 937.500000.
Candy: stock RWD. Tuned for oversteer. Good with 458.984375.
Panga TC: stock roll-over in turns. Tuned for oversteer. Good with 546.875000.
Rotor: stock flipping in turns, not even intended for AI. Easy runner, no need for tuning. Good with 5000.000000.
Clockwork 1: not even intended for racing or AI. Tuned for oversteer. Good with 1250.000000.
Clockwork 2: not even intended for racing or AI. Tuned for oversteer. Good with 937.500000.
Clockwork 3: not even intended for racing or AI. Tuned for oversteer. Good with 937.500000.
Clockwork 4: stock fast and tiny. Tuned for oversteer. Good with 1093.750000.
Ufo: not even intended for AI. Tuned for oversteer. Good with 625.000000.
8-Legs Jr.: custom on asymmetric chassis. Easy runner, no need for tuning. Good with 5000.000000.
Rawdog: custom leaning car, handling changes in mid-turn. Easy runner, no need for tuning. Good with 5000.000000.
BiWheel: custom unstable turn-on-a-dime. Easy runner, no need for tuning. Good with 5000.000000.
RL Burnout Toyeca: custom RL body-dragger. Tuned for oversteer. Good with 468.750000.
(Special case: old AI node selection code gets confused at start line, but starts after a reposition.)
Caterpillar: custom with mega inertia. Tuned for oversteer. Decent with 468.750000.
(Special case: high inertia makes it oversteer on tarmac and understeer on ice. Currently balanced between those two. Could be tuned better for tarmac, but goes straight on ice then.)
Fast Traxx: custom slow climber. Easy runner, no need for tuning. Good with 5000.000000.
Plymouth RR Wheelie: custom wheelie-popper. Tuned for understeer. Decent with 310.058594.
(Special case: its physics hates any collisions. Also, old recovery mode can’t handle the car – as long as it stays in race mode, it goes well.).
Ghost Car: custom go-through-things, based on Mystery. Easy runner, no need for tuning. Good with 5000.000000.
Heavy Metal: custom super-heavy. Tuned for understeer. Good with 312.500000.
HoverTech: custom hover, technically a full-drifter. Tuned for powerslide. Good with 1850.585938.
(Special case: static AI can’t handle its different sliding at different speeds. Understeers a bit when fast and oversteers a bit when slow.)
K22a Virus: custom overpowered RWD. Tuned for oversteer. Good with 468.750000.
RL Komatsu930e: custom RL heavy tail-happy. Tuned for oversteer. Decent with 312.500000.
(Special case: static AI can't cope with so different handling when slow and when fast: oversteers when slow, understeers at high speed. Could be tuned better for slow speeds, but goes straight in fast curves then.)
Nomster RC: custom soft-suspension 4WSteering. Easy runner, no need for tuning. Good with 5000.000000.
Motocross Rider: custom superlarge leaning. Tuned for understeer. Good with 4.882813.
(Special case: actually tail-happy, but too large for most tracks, thus understeers with track AI. Now has nervous, but precise steering.)
Mowmaster: custom RWSteering body-pusher. Tuned for understeer. Good with 214.843750.
(Special case: old AI node selection code gets confused at start line, but starts after a reposition. Also, static AI can't cope with so different handling when slow and when fast: oversteers when slow, understeers at high speed. Not perfect, but best that static AI can manage.)
Piaggio Vespa: custom understeering leaning. Tuned for understeer. Good with 390.625000.
Police Sidecar: custom asymmetric CoM, straight on wheels. Tuned for oversteer. Good with 312.500000.
Slideout: custom supersmall. Easy runner, no need for tuning. Good with 5000.000000.
Stuntman BMW: custom asymmetric CoM, leaning on side. Easy runner, no need for tuning. Good with 5000.000000.
Suppressor APC: custom heavy nose-heavy. Tuned for oversteer. Good with 625.000000.
T-Bucket: custom insanely fast. Easy runner, no need for tuning. Good with 5000.000000.
(Special case: static AI can't cope with so different handling when slow and when fast: oversteers when slow, understeers at high speed. Not perfect, but best that static AI can manage.)
RL Chibi Fatbax: custom RL supersmall. Easy runner, no need for tuning. Good with 5000.000000.
Toy Copter 2: custom with realistic copter steering. Tuned for side-slide. Decent with 25.634766.
(Special case: recovery handling is reversed, thus sometimes sticks to wall.)
Thunder Tiger: custom soft-suspension typical buggy. Tuned for oversteer. Good with 614.013672.
(Personal note: huh, it has a _really_ narrow fringe due to its spring action!)
Race Unibike 2: custom sharp-steering leaning. Easy runner, no need for tuning. Good with 5000.000000.

Posted: 10 Aug 2012, 05:21
Huki
Some notes about the current v1.2 AI:

- Don't use 2.0 for OverMax, the final correction value doesn't get capped as you expect - it just rolls over.
The new under/over steer correction code is quite similar to the old one, but we did some major clean up and rewriting (for better readability) and we didn't take out of range values into account. Maybe the next release will add back the safety checks...

- In the new version there is no need to set the OverMax value higher than 1. You can already achieve full counter-steering with OverMax 1, because the calculated correction value is directly set, not added/subtracted from the original steering.

- When the UnderFront-UnderRear test is passed, the old version simply corrects steering and leaves the throttle at full. The case in v1.2 is different: when this test is passed, the car goes off-throttle and the steering is just not modified.

- Isn't it a good idea to just use UnderXXX vars for understeer and OverXXX vars for oversteer correction? I think the re-routing only makes sense for ice where the car definitely spins out after understeering. We're thinking of simply adding a new racing line type called "Slippery" to handle behavior on ice.

Posted: 10 Aug 2012, 19:52
Citywalker
Thanks for the reply, Huki.

-1 I’m guessing that the cleanup and rewriting includes the intelligent oversteer correction. What exactly does it do? (I was thinking that this was what messed up my tuning try for the V1.2 AI...)

-2 Huh, good, you cured the mistake! Thanks :)
Okay, then I’ll try OverMax 1 for the V1.2 AI.

-3 I guess I’ll try UnderFront/UnderRear 5000 then for the V1.2 AI, to keep things simple.

-4 Re-routing was definitely necessary for old AI on all surfaces. It’s not only for spin-outs, it balances different situations for different types. All the four types need their respective UnderMax/OverMax pairs, otherwise there is no fringe value to find, i.e. oversteering cars don’t become understeering with even minuscule Thresh values, and vice versa, and for the other two types as well. Examples: Caterpillar can’t hold a straight line anywhere without re-routing. Mowmaster’s originally super-wide steering never gets any sharper without its respective re-routing pair. I was unable to cure the tail-spins of Hover on grass until I tried that specific re-routing pair, and Copter didn’t start turning at all with any other UnderMax/OverMax pair.

-4a You don’t need a new AI line. With fringe value, the cars hold the line just fine on ice. In fact, some do it better on ice than elsewhere. You can tune FringeAI for the track “8 on Ice” if you want to. I know, because I tried and succeeded :)


Edit:
Okay, I tried the tuned Sprinter and Caterpillar with OverMax 1 for the V1.2 AI, and then with UnderFront/UnderRear 5000, and no, they still oversteer with your V1.2. Is there anything else that I should know?

Edit:
It’s definitely the intelligent oversteer correction that breaks the tuning for V1.2. I tried tuning Sprinter from scratch there, and with UnderMax/OverMax -1.0/1.0 and Threshes 312.500000 it decides to countersteer excessively on Market2 ice and then still oversteers in resulting correction-U-turn. With Old AI, cars do one or the other, not both.
Huki, what is this code-bit actually doing and is it really necessary?

Posted: 13 Aug 2012, 00:46
Huki
CW wrote:I’m guessing that the cleanup and rewriting includes the intelligent oversteer correction. What exactly does it do? (I was thinking that this was what messed up my tuning try for the V1.2 AI...)
The new oversteer correction simply lets the car oversteer if the car is spinning towards the racing line, correction only has effect if the car is about to spin away from the racing line. The first 2 screenshots below show when the car is let to oversteer, and the last 2 shows when correction would be in effect.





Currently it's only meant for normal surfaces though. For ice we had planned to support a new racing type called "Slippery" and tweak the "intelligent oversteer" differently for that type of path.

Well without going into further details, I've now decided to remove this new feature for the next release. :) I guess we can already avoid too early correction of oversteer by setting OverThresh to a safe value, so we can probably do without this feature.

By the way, the new UnderFront/UnderRear behavior will be disabled too (at least for now) as there's not any car yet that makes use of it (and we'll probably not be updating car parameters any time soon).

I've also given a deeper check to make sure hacks and re-routes keep working as before, so your method should be ok in the next release (or tell me if you need a quick build to test).

Posted: 13 Aug 2012, 04:05
MythicMonkey
If I'm following all of this correctly, then that sounds good, Huki. Like I've said before the AI is still kind of a grey area for me, so at this point I can only mention that it -sounds- like we're heading in the right direction. :lol:

I will say additionally though, two things. <smiles> The first is that it sure would be helpful to have a good 'solid' set of parameters that we car makers could use to 'manually' adjust AI behavior as necessary for individual vehicles.

And second...please give this woman whatever she wants. :D

She is the one I am hoping will help us ALL make sense of this whole business, so I humbly ask that you give prime consideration to her valuable input on this matter.

My gratitude in advance for all of your efforts in this and all other matters pertaining to the improvement of this great game that we all so much enjoy. :)

Mythic

Posted: 13 Aug 2012, 11:24
Citywalker
Thanks for the explanations, and yes, I would like a test build when you have time to make one <smiles>

Posted: 16 Aug 2012, 04:28
Huki
Citywalker @ Aug 13 2012, 11:24 AM wrote: Thanks for the explanations, and yes, I would like a test build when you have time to make one <smiles>
Hmm never mind, there have been several other bugfixes, so I'll just be releasing a new update soon, hopefully by tomorrow...

EDIT: Released now.

Posted: 16 Aug 2012, 06:12
MythicMonkey
That's excellent, Huki! I greatly appreciate all your hard work and all that you give to the community. :)

Mythic

ps...On a side note. <grins> You guys could really use a 'thumbs up' smilie. <laughs> :D

Thanks again, dude. :)

Posted: 01 Sep 2012, 22:38
Citywalker
Latest edit:
Huki’s latest V1.2 AI (beta 0815) uses the car AI part of parameters.txt in the old way again, so you can use this tutorial for both the old AI (V1207) and the new AI (V1.2). The same tuning result works for both versions, so you’re good to go in any case. The only difference is that Huki’s v1.2 AI has better crash recovery and route selection.
Yay, thanks, Huki!

Edit: no, the tuning value is different, and Huki's AI has a sharp excessive countersteer happening sometimes that breaks the car's flow. So it's possible for V1.2 in principle, but not perfect.

Posted: 15 Sep 2012, 22:29
Citywalker
Bump:
Added an option for problematic vehicles.

Posted: 25 Oct 2012, 22:25
Citywalker
Bump:
There’s a better stock track for tuning the AI.

Posted: 08 Jan 2013, 20:15
Citywalker
I think I found a simple and effective place to tune the Fringe AI into Expert AI.

Use the track “8 on Ice”. If the car is not an Easy Runner already, then use the appropriate Under/OverMax pair and find the fringe where the car runs smoothly (without swinging or zig-zagging excessively and still staying inside the straight section) until the end of the first straight (the stones right and left). (Technically, watch for the second line, "AI State" - if it changes from Race to Correction, the car is swinging too much.) Then with oversteer pair, go up with the Thresh values until out of fringe ("AI State" changes from Race to Correction) and use the highest value still in the fringe, or with understeer pair, go down with the Thresh values until out of fringe (car starts zig-zagging on straight section) and use the the lowest value still in the fringe.

This tunes the car to cope with ice and still have good turning ability elsewhere. (And that highest/lowest within the fringe is usually enough precision. Trust me, I’m a perfectionist myself :) If the car still has some problems elsewhere, e.g. understeering at very high speed, then that car needs different thinking for different speeds and the static AI of Re-Volt can’t do that. The first highest/lowest within the fringe at “8 on Ice” is mostly a full Nicholson – as good as it gets :D ).

Posted: 27 Feb 2013, 21:33
Citywalker
Clarified the latest and best way to tune the AI: tuning at “8 on Ice”.

Posted: 16 Apr 2013, 20:33
Citywalker
I was told that my tutorial was too mathematical and hard to understand.
Okay, I’ll make it simple.
You don’t have to read all this long post, if you don’t want all the background info.
All you need for tuning is this:
• The spreadsheet that automates the calculations (xls and odt, also usable via e.g. Google Docs): here;
• The track for tuning the Expert AI: “8 on Ice” here;
• WolfR4 by Jigebren: here.

The spreadsheet includes short instructions and a simple way to find the right AI values: input “1” or “-1” and test the result.
WolfR4 is needed for refreshing the car in-game, so you see the tuning results.

Happy tuning!

Posted: 27 Apr 2013, 21:11
Citywalker
I added some useful tips to the spreadsheet. Re-download, please.

Posted: 16 Jul 2013, 22:51
Citywalker
I added a couple more tips to the spreadsheet. You can re-download, if you want.