News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Opponent's path

Started by Cas, January 23, 2021, 07:28:14 AM

Previous topic - Next topic

Cas

I'm starting this thread without much information just so there is a place where we can drop whatever we have about this topic. The idea is  getting to fully understand how Stunts resolves what is going to be the opponent's path on a track. There has been some discussion about this in the past in different threads, but I think there isn't a thread specially for this, so it'd be better to put everything together.

We know, of course, that Stunts will try to find the shortest path for the opponent and it seems it first adds the number of tiles for each path and apparently ignores the numbers and types of obstacles there may be. However, I've made experiments in which I tried to force two equally long paths in different orientations and I haven't been able to find a theory that can predict Stunts' choice in those cases.

To show how counting tiles is non-trivial, when counting, single-tiled objects count as one tile and two-tiled objects count as two tiles, of course. Then, four-tiled objects are less clear because you can either turn or go straight and, in the case of the cork u/d, you go straight, but you follow a whole circle in the middle. My guess is Stunts ignores this and takes it as two tiles. But what if you turn?  Is it two tiles or three tiles?

My original guess was that, when path lengths were equal, Stunts would pick either the first path it resolved from the group of candidates or would display a preference either towards going straight or towards turning. I also suspected that orientation could break this, that is, rotate the track 90 degrees and the path may change. I don't remember the results of this test, but it's worth trying again.

Anyway... shoot everything you can think of!

EDIT: Maybe this should be moved to reverse-engineering...
Earth is my country. Science is my religion.

Daniel3D

I did a first test with mirror tracks,
with equal laps the opponent favors the left lap.
I think by design because that's the side they start on.

it does not matter which lap split comes first,
(oppT1 and oppT2 track both favor left side)

If the right side is shorter (oppT3) then the right side is taken,

If oppT2 has an obstacle on the left side (single slalom) then also the right is taken, (oppT2o1)

So first careful conclusions:
when equal take left,
track piece properties are taken into account,

(test are done with skid, don't know if opponent weaknesses are taken into account)
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

On default its more complex.
The outer lap is clearly longer but skid favors it anyway.
(it is the first left, so it complies with favoring left)

I know that skid sometimes does go straight at the first split,
Tested with different cars and with or without false start,

Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

Quote from: Daniel3D on January 25, 2021, 11:21:35 AM
I know that skid sometimes does go straight at the first split,
Tested with different cars and with or without false start,

Maybe path data in opponent files is the key in this case..
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

#4
OK, test with unequal laps,
Left lap 10 straits longer than right lap.
Bernie chooses right (no surprises here)
-----
test 1 - OPPT3o1
When I change road for slalom on the right lap the first 5 don't change the preference.
When I place 6 Bernie chooses the long road.
------
test 2 - OPPT3o2
changed on the long lap two corners and two straights to banked road.
Now only two slalom tiles on the short road tip the favor to the long road.

So
the slalom has a negative modifier.  [-2?]
the banked road has a positive modifier.  [+2?]

Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Duplode

Sorry for being a bit late to this thread, as there's something you'll want to be aware of for the next round of experiments.

Quote from: Daniel3D on January 25, 2021, 11:21:35 AM
On default its more complex.
The outer lap is clearly longer but skid favors it anyway.
(it is the first left, so it complies with favoring left)

I know that skid sometimes does go straight at the first split,
Tested with different cars and with or without false start,

Below are attached two replays of races against Skid on Default. Same track, same cars, same settings -- and yet, Skid chooses the long way in the first lap and the short way in the second. The only meaningful difference is that in the first lap I jumped over the right slalom block on the hill, as you normally would with a sufficiently fast car, while in the second one I switched lanes before the hill and took the jump from the left lane, swerving to the right just enough to avoid the left slalom block.

Why does that happen? Something I found through restunts in 2016 (only to lose the results with a fried HD before getting to document the results) is that dual-way tracks have invisible checkpoints on the road which change the path of the opponent when you hit them. While the checkpoints are set up in arbitrary positions, said positions are fixed for each track (I believe the algorithm uses a pseudo-RNG seeded with the track data, so while the positions are reproducible there shouldn't be nice patterns like those you found for the F4 cameras). As for Default, there presumably is a checkpoint somewhere on the left side of the road near the slalom blocks.

I'm reasonably sure the checkpoints are the one source of unpredictability in the opponent path choices. They might make things quite confusing in your experiments, so you'll likely want to, at least for now, do them without moving your car so that they don't become a factor. (Ideally, of course, we'd want to know where the checkpoints are. I will try to find again where their positions are in memory, though it might take me a little while to actually do it.)   

Daniel3D

Thanks, that kind of makes sense.
(It's 4AM, just got woken up by one of my kids. So if I jump to a insane conclusion that might be the reason)

The opponent favours left on equal tracks. Because the player starts on the right lane. If you go through a checkpoint on the left lane this switches.
It's a simple solution for a simple AI.

(That would make default.trk have a equal left and right lap for lap calculation..)

Quote from: Duplode on January 26, 2021, 03:38:18 AM
(Ideally, of course, we'd want to know where the checkpoints are. I will try to find again where their positions are in memory, though it might take me a little while to actually do it.)   
That would be awesome
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

Quote from: Duplode on January 26, 2021, 03:38:18 AM
I'm reasonably sure the checkpoints are the one source of unpredictability in the opponent path choices. They might make things quite confusing in your experiments, so you'll likely want to, at least for now, do them without moving your car so that they don't become a factor. (Ideally, of course, we'd want to know where the checkpoints are. I will try to find again where their positions are in memory, though it might take me a little while to actually do it.)   
I've made a copy of default.trk to test this. For some reason in my test version of stunts (with edited files everywhere) opponents always go straight...
Don't know why.
In my competition version the game crashes at opponent selection,
Don't know why.

So I ran this test on the 4DSportsDriving1.1 Feb-25-1991 version *(doesn't alter core files, so it ok I guess).
When unattended the favorite route is the long way around.
When overtaking the opponent en driving on the left side (and crashing on the slalom block)
the opponent will go straight.
When left unattended again I have to put 5 slaloms on the track before the other path is favored.

So the checkpoints apparently weigh heavy in this decision. I think its to avoid collision, but that's me jumping to conclusions again.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Cas

Uhm... I didn't expect this. I have downloaded the files, but I'm working and can't test right now. I think that the most certain conclusion so far is that the path the opponent will follow is not resolved when the track paths are generated before the race, by somehow dynamically during the race. The reasons could be many... To avoid collisions makes sense. I think that, if DSI chose to make this dynamic on purpose, it should've been for a reason like that one or similar, something useful. If they had decided that they wanted to make opponents more random (without losing "replayability", i.e.: determinism) then they could just issue a PRN at certain frequent events that depend on the player, such as pushing and releasing the accelerator.

The random checkpoints sound like a very complex system to have been made just for this, so with them, I would expect that checkpoints be made for something different, but happen to affect the opponent. We know that DSI were very commercial-oriented. If they spent more time on a feature, it was in hope that it'd sell better. Anyway, I don't know, the complexity of car features would be thus unexplained.

Another thing that surprised me is that even letting the opponent drive alone, their choice does depend partially on the contents of the path. I would've bet it was all about number of tiles and perhaps, placement of split points.
Earth is my country. Science is my religion.

Daniel3D

Quote from: Cas on January 26, 2021, 06:12:43 PM
The random checkpoints sound like a very complex system to have been made just for this, so with them, I would expect that checkpoints be made for something different, but happen to affect the opponent.
Good point.
I don't think they are random. I think they are a simple way to track the player.

To be the eyes of the opponent (I don't believe there is real-time tracking and the ability for the opponent to drive around the player is poor.)

A other use for this can be penalty time calculation.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

Quote from: Cas on January 26, 2021, 06:12:43 PM
Another thing that surprised me is that even letting the opponent drive alone, their choice does depend partially on the contents of the path. I would've bet it was all about number of tiles and perhaps, placement of split points.
I've been wondering about this for a long time. I didn't understand why the opponent would choose the long road.
I figured that slowing Stunts like slalom and the loop would have influence. But that wouldn't be enough.

I don't know
If flat corners give a negative or
If banked corners give a positive modifier...
But that I can test I think...
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Duplode

#11
You folks are right: my fanciful checkpoint theory was wrong. Back in 2016, a handful of coincidences about the data I was looking at, plus a dose of impatience after a long series of experiments, led me astray. (See this post for an explanation of what it was all about.)

Going a bit further, I no longer believe the opponent path choices change during a lap. The path choices do change sometimes before a lap is driven or replayed. Though those changes aren't necessarily random, they seem arbitrary, being apparently influenced by which menu options you use. My working hypothesis right now is that starting to drive from the main menu or loading a replay from the options menu leads to the preferred (in the sense Daniel3D has been analysing here) choice being made (for instance, Skid turns left in both Default laps in my previous reply, even though he originally went straight in the second one). Beyond that, all bets are off. That perhaps can be better appreciated with a mazier track, such as ZCT078:



I have attached a sample replay below. By loading or continuing the lap in various ways, you can look for the secret endings.

Cas

I think I should make some more tests on this and verify it. This track really is ideal for these experiments.

By the way, looking at the track map with the graphics from Cartography reminds me of an idea I had had some time ago and never implemented: that in Bliss, one could pick among different track graphic sets, including Bliss original, that of the internal Stunts editor, Cartography and Track Blaster. Of course, I wouldn't be able to include the ones from Stunts with the editor, because it's free software, but I could have it detect the presence of Stunts and read them from there. For Cartography, I could have your permission, but for Track Blaster, I don't think I can get to ask the author, although I'm pretty sure he wouldn't mind.
Earth is my country. Science is my religion.

Daniel3D

#13
Quote from: Duplode on February 01, 2021, 04:21:17 AM
My working hypothesis right now is that starting to drive from the main menu or loading a replay from the options menu leads to the preferred (in the sense Daniel3D has been analysing here) choice being made (for instance, Skid turns left in both Default laps in my previous reply, even though he originally went straight in the second one).
I had a fluke like that when testing the truck.

After I made the nice shot of the two starting line trucks getting ready to race, I did.
And I went straight on default. I drove beautifully through the corkscrew and I wanted to have a animated gif of it.
But in the replay my opponent kept crashing into me just before.
(I distinctly remember him taking the long road)

So one thing is sure. The opponent driven path is not stored in the replay. It is regenerated, and can differ from the original run.
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.

Daniel3D

Quote from: Cas on February 01, 2021, 06:02:53 AM
I wouldn't be able to include the ones from Stunts with the editor, because it's free software, but I could have it detect the presence of Stunts and read them from there.
Why not? Bliss is not a commercial product so there is no financial gain. And those using the editor probably have Stunts anyway.
You should make the source of the set very clear with a link to more information if possible.
(At least, that's how I see it)
Edison once said,
"I have not failed 10,000 times,
I've successfully found 10,000 ways that will not work."
---------
Currently running over 20 separate instances of Stunts or 4D Sports Driving.