DumbAI

DumbAIMisc  1.0

  • Thread starter Thread starter ancient_3
  • 64 comments
  • 3,367 views
I ran a test to help me better understand version 1.0.

Mod: F1 1999 by SD
Track: Magny-Cours 1998 by Shin
CSP: 0.3.0-preview 212
Extended physics: Enabled

I set the race distance to 50 laps, which according to Content Manager corresponds to 209.7 km.
1769447233540.webp


I checked, and all cars have a fuel_cons.ini file with the same values:
1769447311711.webp


Fuel consumption and fuel tank capacity are also set identically for all cars:
1769447367269.webp


However, when the race started, some drivers were able to complete the race without making a pit stop, while others were not (for example Heinz-harald Frentzen), as shown in the Race Fuel Monitor:
1769447659596.webp
1769447433517.webp


Is this how it’s supposed to be, or is it an issue?
 
Last edited:
If you have a fuel consumption of 0.85 km per L and your race is 209 km, then you need an amount of fuel of 268 L to complete the race.
With a fuel tank max capacity of 140L, in an optimal world, every AI should have something like 134L in its tank at start and should pit once to refuel for 134L.

But as DumbAI takes a 5% margin (with a bit of randomness), it will compute around an estimation of 281L to complete the race, and here we are at the limit of the fuel tank. So this is a special case :)

The AI that had the random number more optimistic will keep just under the cut and will fill the tank with values close to 140 and make one pit stop. The others that had a more pessimistic random number will be over the 280L limit and then will have to plan 2 pitstops, for example, if they computed 285L to complete the race , they will have 3 stints with 95L at start of each stint.

Not sure what Race Fuel Monitor is displaying. The app shows the result of DumbAI spamming (999999) for LTC (Laps to Complete) but I'm not sure DumbAI replace the values that have been computed for fuel, I had to make Dumb AI spam.

To check what happens with DumbAI:

go to the file bot.lua which is in the "structures" folder in the DumbAI app folder, and there, you can modify lines 229, 230 and 231 of the files from:
--ac.log(ac_name.." laps_to_stop "..table.concat(this.laps_to_stop,", "))
--ac.log(ac_name.." fuel_strat = "..table.concat(this.fuel_after_pit,", "))
--ac.log(ac_name.." real car fuel = "..ac.getCar(this.ac_id).fuel)
to
ac.log(ac_name.." laps_to_stop "..table.concat(this.laps_to_stop,", "))
ac.log(ac_name.." fuel_strat = "..table.concat(this.fuel_after_pit,", "))
ac.log(ac_name.." real car fuel = "..ac.getCar(this.ac_id).fuel)

then save the file and launch the race.

Open the lua debug app and here in the debug area of the app, it will display before the start of the race, for each bot, how much fuel is in the tank at start and how many pit stops are expected. You'll see different values that have been computed each time you have changed items of the DumbAI (every thing is recomputed according to the new options you selected and then displayed in the debug). As there is a little randomization in the computation of the fuel strategy, you'll have some slight differences between the tables that are displayed (mostly because AC do not modify things coming from lua exactly at the same time, according to how you have coded the modificaitons) but you'll get the picture and when the lights go green, the last value displayed is what the car has really inside of it.

If you want to see the amount of fuel in the AIs in real time, you can also modify line 260 from the same bot.lua file from
--ac.log(ac_name.." real car fuel = "..ac.getCar(this.ac_id).fuel)
to
ac.log(ac_name.." real car fuel = "..ac.getCar(this.ac_id).fuel)
and then the AI will spam the lua debug area with its fuel amount at each update of the DumbAI app
 
Last edited:
I made some approximations in my last post so I'll give a complete simple accurate example with Kunos car and Kunos track here:

Suppose you want to race 50 laps of Monza with a Lambo Huracan GT3.
The track is 5755 meters long so your race is 287.75 km.

Lambo GT3:
Max fuel tank is 120 L
Fuel consumption rate in fuel_cons ini is 1.684336 km/L

Margin and DumbAI randomness is applied to Fuel Consumption rate (not to the fuel amount at the end of computation as I mistaked in my earlier post, bad memory sorry).

Margin is 10% and randomness is +/- 5% around this margin value, hence final margin is somewhere between 0.85 and 0.95.

So the final range of fuel consumption rate is somewhere between 1.6 km/L (optimistic margin) and 1.43168 km/L (pessimistic margin)

The fuel needed for the race is then between 179.84 L (optimistic) and 201 L (pessimistic).

Considering the tank is 120L max, every bots will compute 2 stints with 89.92 L for the most optimistic and 100.5 for the most pessimistic. None of the bots should be outside this range.

If I modify the code accordingly to my previous post for lines 229, 230 and 231, I have those results in the debug:
Conrad Gingras laps_to_stop 25
Conrad Gingras fuel_strat = 98.118230534831, 98.118230534831
Conrad Gingras real car fuel = 114.80410003662

And here you see what I meant, the amount of fuel in the car is not assessed correctly by lua when called just after the modification by DumbAI.

But if I add the modification of line 260, then you will see in the spamming in the debug that:
Conrad Gingras real car fuel = 98.108993530273

It has been updated and is correctly accessed by the lua app now. When the race starts, the bot starts with the correct amount of fuel computed by DumbAI.

I hope you enjoyed this small ride in the marvelous world of AC hacking in lua ;)
 
Last edited:
I ran a test to help me better understand version 1.0.

Mod: F1 1999 by SD
Track: Magny-Cours 1998 by Shin
CSP: 0.3.0-preview 212
Extended physics: Enabled

I set the race distance to 50 laps, which according to Content Manager corresponds to 209.7 km.
View attachment 1509040

I checked, and all cars have a fuel_cons.ini file with the same values:
View attachment 1509042

Fuel consumption and fuel tank capacity are also set identically for all cars:
View attachment 1509043

However, when the race started, some drivers were able to complete the race without making a pit stop, while others were not (for example Heinz-harald Frentzen), as shown in the Race Fuel Monitor:
View attachment 1509045View attachment 1509044

Is this how it’s supposed to be, or is it an issue?
Making the same computation by hand as in the previous post, here you should end with either:
  • most AI that expect 2 stints (1 pit stop) with between 129 and 140L in the tank at start
  • a few AI that expect 3 stints (2 pit stops) with between 93.33L and 96.15L at start

Your values look close but some of them are out of the range, I'm not sure why, let me know if you check with DumbAI debug what you obtain :)
 
Last edited:
Back