(early WIP) Random Roads

(early WIP) Random Roads

Postby tempAnon093 » 30 Nov 2019, 10:07

(NO UPLOAD YET: I still want to work on this during December so that it is half-decent before sharing)

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. Benau has suggested exposing 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 03 Dec 2019, 12:28, edited 3 times in total.
tempAnon093
 
Posts: 135
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: 157
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: 135
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.
eltomito
 
Posts: 136
Joined: 15 Mar 2013, 09:25

Who is online

Users browsing this forum: No registered users and 1 guest