## Monday, 31 March 2014

### Dancing with the danger

As I mentioned in the last post, negative scoring was meant to be mandatory in the AI, so level 7 brought the posibility to use those negativeness for good.

Now we have here the first example of how good negative scoring can be: A new tendency to not going outside the track, even if a big drop is in the edge of the track attracting you to the dissaster.

Before explanations, a first video with 3 karts:

White one is fearless, like all the karts were before, and have an easy tendency to leave the track if it means getting some more drops.

Orange one is the now standar "fear" level. It avoid going out with the same strength as it tends to run longer (more on this after the video).

Grey kart is very scared about getting out of the track, double than it likes running, so this fear some times make it seems stonish, like blocked by fear.

How does it works? I tried quite a few approaches, basically trying to set a number of seconds the kart was meant to get alive (time to die was called), but it didn't work too nice, nor it was very stable: some times it did it right, some other the player got stuck with fear, and others it just went off the track.

Finally, the solution was quite simple, the simpliest one I tried: If racing in the track score with the "distance raced", then if you get out of the track, score this meters raced outside with minus distance raced. That simple. Need m ore fear? Use double negative scoring... but only "fear" levels between 0.5 and 1.5 seems to work reasonably nice, being 1 the "magic number" that makes all work smooth.

I mixed this with the "cut engnes off" that happends when you go out, so the distance raced outside the track depends solely on the "inertia" you had when you leaved it. This inertia is the energy of the "impact" if you should crash on a fence on the track limits, so it makes a lot of sense... once you know it works like a charm.

How good this approach is? Superb, the stability a player with this modified "raced distance" goal is incredible! I prepared this other video with more karts and rockets flying arond ina really narrow track trying to avoid crashing (again, white players don't have any fear, yellow to grey have more fear, being orange players the "standard" ones).

There is quite a lot of movement on this one, but the stability of the AI on keeping all the payers inside -except for the white ones- is really remarkable.

By the way, now the karts have the ability to drive backwards at 50% speed, really nice to get away from scaring hard situations if needed.

OK, the base AI is -almost surely- finish with level 7, and "distance raced" goal is now refined and capable of getting the player inside the track on even the worst conditions, so we are ready to move on into new goals: next video should be about feeling "hunger", or variable strength goals.