Author Topic: RandTrack : random race-track generator  (Read 18370 times)

De-M-oN

  • Posts: 126
Re: Random race-track generation
« Reply #15 on: July 29, 2014, 12:07:46 PM »
The game does both loading screens and after it tries to render the game it crashes with a black screen and no input possible at all. total crash. Have to restart dosbox.

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: Random race-track generation
« Reply #16 on: July 30, 2014, 01:40:55 AM »
That's disappointing :(

I will need to investigate to find the problem.

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: Random race-track generation
« Reply #17 on: July 30, 2014, 05:51:33 AM »
This one should work.

Same track : TR2.TRI (Autumn Valley)

De-M-oN

  • Posts: 126
Re: Random race-track generation
« Reply #18 on: July 30, 2014, 11:20:47 AM »
works fine now :)

-> Timetrial: Works :)
-> Head-To-Head (1 opponent): Works (of course with wrong ai speeds though, but there is no way to edit this (no program or specs for this available) so far anyway and even if there would - I think it would be incredible difficult to make the ai decent by automatic system. So yeah - it was expected and I dont care.)
-> Single Race (7 opponents): same problem like with test_01. Again: I wouldnt care. AI speeds are wrong anyway.
So the most important mode: the time races - work. Awesome and big thanks so far.

Track works perfectly fine. No invisible walls, road has no bugs on roadsides, game registers perfectly fine the laps.

If I've edited a track with the tracked editor - it seemed not to update the new car starting positions and I slided out of the wall into the track and started basically on the roadside and not straight due to this xD

Seeing that your track doesnt have this bug and I start perfectly fine on the middle of the right road is a nice impressive surprise to see :)

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: Random race-track generation
« Reply #19 on: July 30, 2014, 10:14:28 PM »
The starting position for the player car has been my biggest head-ache so far.  When it is wrong, the game will just lock up (not start).

I am certain that the position is not stored in the TRI files, and I don't think it is stored in the INFO files (like TR2INFO).

I am fairly sure that the game engine assumes the track always begins at coordinate (0 0 0) and always goes directly north for a while (e.g. 24 to 32 virtual nodes == 6 to 8 segments).  I have looked at all the tracks in my viewer program, and they all begin like that.

So if you edit the track and move it around, it can cause the game to lock-up because it cannot place the car on the track.

Also the player car always faces due north, which is why in my test track it seems to be facing a bit to the left, the track is a pure circle so at that point the track curves to the right.

For the lap times and number of laps, I am sure that information is not stored in the TRI and INFO files.  I cannot see any other files where it is stored, so it is probably hard-coded in the game EXE and hence cannot be changed.

My next step is to get some decent 2D track layouts working, and after that add some slopes and slanting (twisting) to the tracks.  I also need to create the User Interface.

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: Random race-track generation
« Reply #20 on: July 31, 2014, 07:26:02 PM »
I noticed two NFS1 tracks which do not exist in the game's main menu : TR4.TRI and TR5.TRI

Should these tracks be generated?

De-M-oN

  • Posts: 126
Re: Random race-track generation
« Reply #21 on: August 01, 2014, 11:55:29 AM »
Quote
I am fairly sure that the game engine assumes the track always begins at coordinate (0 0 0) and always goes directly north for a while

hmm thats interesting. I hope this doesnt disturb the randomizing in some way ???

Quote
For the lap times and number of laps, I am sure that information is not stored in the TRI and INFO files.
right.
The lap times are stored in the config.dat file (so this file doesnt just store game settings, controls etc, it does store the lap times and speeds as well.)

Quote
I cannot see any other files where it is stored, so it is probably hard-coded in the game EXE and hence cannot be changed.

The number of laps is very sure hardcoded. For long tracks it lets you choose between 2,6,12 laps (default 6) and short tracks it is 4,8,16

But since Rusty Springs (TR1) is the one and only track which is considered a short track and with this the one and only track which allows more laps you can fairly sure assume the 2,6,12 cluster.
So - Since I can choose between 2,6, or 12 laps (at track description - press enter while you've the track selector active (or click with left mouse onto the picture of the track) ) I dont even care so much anyway. If I need/want more/less laps I can just choose more/less.

Quote
I noticed two NFS1 tracks which do not exist in the game's main menu : TR4.TRI and TR5.TRI

Should these tracks be generated?

TR4.tri is the track "Lost Vegas" and has to be unlocked first. You can unlock it by winning the tournament. I'm sorry that my game isnt unlocked at the moment. I couldn't find my old config.dat file at this point.
If you win the tournament twice you also have access to the rally versions of the tracks (other road texture and other more arcade physics)
Rusty Springs' Rally version is even a complete else track (or better said a modified rusty springs) It now has lots of slopes like a rally track.
-> And this track is the TR5.tri

Lost Vegas should be supported in any case. Its an awesome track.
TR5 has very very low priority to me though. I'm also not sure if its even necessary to support it. The tracks are new shapes anyway then. And rally mode physics work for every track. The only problem would be if you intend to drive rusty springs in rally mode the game will try to access tr5 instead of tr1. This could be solved by using for tr1 and tr5 the same file.
Or ..... an idea for tr5 could be that tr5 has an extra high probability for slopes? That could be an idea I think ;D

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: Random race-track generation
« Reply #22 on: August 01, 2014, 08:56:12 PM »
Thanks for that info.

I like your idea of doing weird or special stuff on TR5.

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: RandTrack : random race-track generator
« Reply #23 on: August 03, 2014, 06:25:51 AM »
One thing I have been thinking about is exactly how to generate the tracks.  Obviously I cannot make this program do anything useful until that is decided.  But now I have a fairly clear concept how to make both open tracks and closed circuits using roughly the same method, as follows :

Basically, there will be a set of pre-made shapes, whose lengths will generally be quite short but long pieces will be possible too.  Then we concatenate a series of these shapes together to form the track,  while making sure the track never gets too close to itself or crosses itself.

For closed circuits, we pick pieces which are either straights or turning clockwise (though sometimes we make the whole track go anti-clockwise).  When the track is long enough, we can adjust the track so that the end point meets up at the start point: first by adjusting the angles of each node, then by adjusting the position of each node.

These pre-made pieces can specify other details.  For example, could have some which are "city" (and hence we place buildings and lamp-posts nearby) and some are "country" (place trees or cactuses or whatever nearby).  Some pieces could be tunnels, or bridges, or a dark area with many large trees nearby.

De-M-oN

  • Posts: 126
Re: RandTrack : random race-track generator
« Reply #24 on: August 04, 2014, 07:02:08 AM »
Quote
An approach which should be feasable and produce truly random tracks is this: start with a predetermined shape (e.g. circle, but have several) which consists of number of short line segments, maybe 100.  Then "iterate" to produce a new track by deformation, moving each vertex by a small random amount, while maintaining angle limits and ensuring vertices don't get too close to the track.  Keep iterating for so long, e.g. 500 times.  Would probably need to test the result is OK (e.g. not returned to a boring circle).  You could also create some features at the beginning (straights, chicanes, hairpins) and maintain those features during the iteration process.

What about this method? Your screen shows awesome results.
Any engine limit which prevents now this method? Or do you think the new method is better?
If first method is possible, but 2nd has advantages: Maybe a combination of both like oblige does currently?
Can user contribute shapes in a way if 2nd method is used - so that we have a very big archive to have it as less as repetitive as possible ?

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: RandTrack : random race-track generator
« Reply #25 on: August 05, 2014, 02:23:27 AM »
I did consider that method, but I think it has a serious flaw: it would generate a lot of "bumpiness" or ripples in the track, like ~~~~~~, and not make curves on a large enough scale.

The method shown in the earlier screenshot is the simple method of joining two pre-made track-halves together.  For closed tracks it might be good enough (with a few more pieces), but it is not usable for open roads.

The method I am actually using should produce good results.  Below is a screenshot of the "rough" track (without smoothing).  The overall shape is interesting, yet it was made with only TWO pieces (a curve and a straight).

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: RandTrack : random race-track generator
« Reply #26 on: August 07, 2014, 05:04:09 AM »
I have 2D layouts working fairly well now.

The attached zip has a closed track and an open track, TR2.TRI and CY1.TRI (Stadt)

Of course there is much more to do, there is no scenery to look at, and no slopes or twists yet.  But the user interface has been finished and is usable.

De-M-oN

  • Posts: 126
Re: RandTrack : random race-track generator
« Reply #27 on: August 08, 2014, 03:59:52 PM »
awesome :-)

I found a minor bug though:

Your city1 seems to be longer than original length. The map shows finish line at original position and you drive the rest of the track out of the map:

http://abload.de/img/dosbox_2014_08_09_00_kou2b.png

If not fixable I dont care ;D

But this seems you can even alter the lengths of the track. Thats awesome. That even exceeds the possibilities I would have with the editor. The editor wouldnt allow me to make the track longer.

And you randomize even the scenery? Random tunnels on track and so on? wow ...
impressive work like always by you.
Thank you sooo much :)

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: RandTrack : random race-track generator
« Reply #28 on: August 08, 2014, 10:19:03 PM »
Yes it is quite odd how the map lines disappear at the end, even though everything else seems OK.

Scenery (objects, buildings) and tunnels will be randomized.  Tunnels are interesting in that the road segments at the side are folded over the top of the road to make the tunnel.

TRACKED is quite limited.  It was also displaying the bitmaps on some tracks wrong, so I have made my own viewer for textures and sprites :

andrewj

  • Developer
  • *****
  • Posts: 1422
Re: RandTrack : random race-track generator
« Reply #29 on: August 13, 2014, 06:51:27 AM »
I found the following track fun to play, and thought you might too.

The track is TR1 (Rusty Springs).  It has slopes, but no scenery (making random scenery is proving to be a big challenge).