(early WIP) Random Roads

(early WIP) Random Roads

Postby tempAnon093 » 30 Nov 2019, 10:07

-----

See update for download link

-----

I recently discovered this pre-made City on BlendSwap (https://www.blendswap.com/blend/23834) and wanted to make a quick track from it. I saw this as an opportunity to test an idea that I have had: a track that randomly changes path each run.

(The textures are broken because the pre-made .blend uses Materials and I haven't learned how to bake materials automatically so it will be a while before this is fixed...)

Here is a video: invidio.us / youtube

This video shows how some of the intersections are scripted to create a semi-random route through the city. This helps make the races more dynamic.

Of course there are major downsides for this much fun:
- AI bots are dumb, so they probably won't be able to finish a dynamic track like this. Maybe I could have the slowest route always open and they use that? Still wouldn't be great.
- speedrunners owned lol I just discovered that custom Add-Ons build, if this map were ever included then the scripting.as file could be modified to use a preset override route.
- probably won't work on online multiplayer for the foreseeable future, unless I use a less random variable such as player count. In version 1.1, Benau has exposed the syncronised random seed to scripting, allowing me to make sure all players have the same random track!

city1.png


The code is a variation of this:

{l Code}: {l Select All Code}
/* Generate random numbers to decide which route to enable */
int random = Utils::randomInt(1, 3);

/* Use these to force a route as enabled (true) or disabled (false) */
bool override_enabled = false;
bool override_1 = false;
bool override_2 = false;

/* This SuperTuxKart map makes each route object call one of these
 *  functions to check whether enable that object or not.
 *
 * If either 'this route is randomly chosen' or 'we override this route',
 *  then return 'true', telling SuperTuxKart to enable this route.
 */

bool route_1_active(Track::TrackObject@ obj){
    if (override_enabled) {
        return override_1;
    } else {
        return (random == 1);
    }
}

bool route_2_active(Track::TrackObject@ obj){
    if (override_enabled) {
        return override_2;
    } else {
        return (random == 2);
    }
}
Last edited by tempAnon093 on 24 Dec 2019, 22:43, edited 6 times in total.
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby benau » 30 Nov 2019, 11:14

We can expose the random seed number in scripting for you, and it's already synchronised in network.
Image
benau
STK Moderator
 
Posts: 283
Joined: 08 Dec 2015, 17:32

Re: (early WIP) Random Roads

Postby tempAnon093 » 30 Nov 2019, 13:44

benau {l Wrote}:We can expose the random seed number in scripting for you, and it's already synchronised in network.

That would be perfect! Thanks :)
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby eltomito » 30 Nov 2019, 19:59

Is it possible to turn selected AI drive paths on and off with a script during the race? That would make it drivable for the AIs.
User avatar
eltomito
 
Posts: 176
Joined: 15 Mar 2013, 09:25

Re: (early WIP) Random Roads

Postby benau » 21 Dec 2019, 10:27

https://github.com/supertuxkart/stk-cod ... 7d8ebc5107

You can use uint getItemManagerRandomSeed() in 1.1-rc1 stk now
Image
benau
STK Moderator
 
Posts: 283
Joined: 08 Dec 2015, 17:32

Re: (early WIP) Random Roads

Postby tempAnon093 » 21 Dec 2019, 10:44

I've done a bit more work on the track. The textures are still horribly broken, but that's not too important ;)

Download .zip here

pic0.jpg


The AI are understandably confused in most races (doubly so because I've only defined a couple of long alternate routes instead of many short ones) but they can complete two of the possible courses without issue.

Here is an example of two separate races:
In this first one, we finish this left turn with a long right turn.

pic2.jpg

But in this race, we are forced to make a surprise U-turn!

pic1.jpg


So even though it is very incomplete, it's still fun to drive.

pic3.jpg


Here is a map. A route is chosen at random from the orange roads. The white roads are future possibilities, but would take a lot more effort to include.

city-map-key.jpg


benau {l Wrote}:https://github.com/supertuxkart/stk-code/commit/b29a42719cd32bcf3af4725aa2b3f97d8ebc5107

You can use uint getItemManagerRandomSeed() in 1.1-rc1 stk now


Perfect timing, thanks a lot!
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby kimden » 24 Dec 2019, 15:38

Really nice track! With random seed exposed, it's already playable online. Though sometimes the path becomes too short in my opinion.
One day, I'll put enough checklines on all your tracks.
User avatar
kimden
 
Posts: 46
Joined: 23 Jun 2019, 18:42

Re: (early WIP) Random Roads

Postby tempAnon093 » 24 Dec 2019, 23:09

Thank you, I'm glad you like it! I agree that sometimes the path is too short, the shortest races can have 15 second laps. In later versions, I could try and open route 'c' and make sure that the shortcut routes (such as 'y') are only used if the rest of the path isn't short.
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby benau » 25 Dec 2019, 05:47

lol your track looks like racing track in Macau
Image
benau
STK Moderator
 
Posts: 283
Joined: 08 Dec 2015, 17:32

Re: (early WIP) Random Roads

Postby Worldblender » 25 Dec 2019, 07:20

I haven't tried this track out yet, but make sure that you publish the Blender source file at some point, and another for the final version.
User avatar
Worldblender
 
Posts: 73
Joined: 15 Aug 2014, 18:46

Re: (early WIP) Random Roads

Postby tempAnon093 » 25 Dec 2019, 08:04

benau {l Wrote}:lol your track looks like racing track in Macau

Haha, yeah. I tried to make it look kinda like some real street circuits.

Worldblender {l Wrote}:I haven't tried this track out yet, but make sure that you publish the Blender source file at some point, and another for the final version.

I'll upload it in a couple of days, I just want to make a couple of small changes first. :)
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby eltomito » 25 Dec 2019, 09:25

Hi! I tried your track and it looks really good! A couple of comments:

1) The graphics are too complex! I get less fps on your track than on Black Forest. Could some of the building models be simplified or completely removed?

2) The road is kinda dull. Could it go up and down a little? Or even a lot? Could you put more bananas? Could it get narrower at some points?

Great work, though!
User avatar
eltomito
 
Posts: 176
Joined: 15 Mar 2013, 09:25

Re: (early WIP) Random Roads

Postby tempAnon093 » 25 Dec 2019, 12:15

eltomito {l Wrote}:1) The graphics are too complex! I get less fps on your track than on Black Forest. Could some of the building models be simplified or completely removed?

Yes, I can do that. I forgot how high the poly count is (it's far, far over the STK recommended limit), I can remove objects and simplify some of them.

eltomito {l Wrote}:2) The road is kinda dull. Could it go up and down a little? Or even a lot? Could you put more bananas? Could it get narrower at some points?

It is a bit dull. This was more of a test/experiment than anything so there is lots of room for improvement!

The city was built from a pre-made Blender project (that is the reason for the current poor FPS, because the creator was caring about quality more than performance). Because it is pre-made, it may not be easy for me to edit it into going up and down but it could be possible. I can certainly add more bananas, obstacles [edit: note to self to add street cones and blockers like on Classic Tollway] and narrow points (it already does become narrow a few times) without much effort.

Thanks for the feedback!
Last edited by tempAnon093 on 29 Apr 2020, 09:05, edited 2 times in total.
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Re: (early WIP) Random Roads

Postby tempAnon093 » 29 Apr 2020, 07:52

I finally learned how to bake textures properly and use gloss maps, so I can start to fix the horrible texture issues!
I initially tried baking the entire buildings into big textures but the quality was very bad on low graphics settings. Now I need to spend more time baking individual textures but the result should be much higher quality and more playable.
tempAnon093
 
Posts: 225
Joined: 02 Feb 2019, 12:09

Who is online

Users browsing this forum: No registered users and 1 guest