## Thursday, 4 June 2015

### Fractal AI: An Almost Perfect Lap!

The main problem with fractals is that they tend to grow exponentially, so keeping this growth under control is a difficult task in many aspects.

Some posts ago I commented about the need of combining Fractal AI with some kind of "Exclusion Principle", meaning it that the fractal needed to avoid high density zones in order to work optimally.

Today I had some spare time to work on this and now I am presenting you the first videos of this exclusion at work. It did improve AI quite a lot! Just see the video and judge:

Please note the track was quite wet and that I ordered it to suicide at the end. Also, this AI is still in a "beta" stage.

For instance, the actual coding of this "exclusion principle" only uses agent's positions X and Y to detect dense areas. It is a position-only exclusion principle, but the complete one should also take angle and velocities into account, as it is the positon and momentum of the particles that need to be "excluded".

Why is this necessary in an AI implementation? Well, we are not in a physical simulation, so I would only choose to implement it if I think it is for better, as it is in this case: Imagine two futures that started by choosing oposite initial directions. Both futures will initially diverge, as one kart will turn left while the other turn right. But they can then change direction and both future's traces can then cross in a given point. When future 1 is in this position, so it is future 2, as they cross there, but they will be driving in different directions.

If I should detect a crash in this situation, I will delete one of them, loosing a geniune "diferent course" of the future, never knowing what would had happened "if".

May be future 1 was just to crash in the next moment, while future 2 was not. So, if in this situation I delete future 2, both futures will disapear, the good future 2 first, and then the other crashing one.

I prefered to implement exclusion in two phases just to be able to tell how important momentum or angle is for AI. Surely they both will be, but not as much of an improvement as the position excluson alone is, I spect.

So the AI on the video still lacks some features to be showing 100% of its power:

a) Exclusion principle is only applied to positions, not momentums or angles, as it should be.

b) Implementation of position exclusion uses a hand-choosen distance parameter. I has to be the AI the one to chose it automatically in next versions.

c) Cloning rate is poorly choosen now. A simple heuristic is used now. AI will do it in next versions, with same solution as in b).
All that said, the kart is "almost" optimally driven for my highly bised taste, and when the above is addresed, I think it will drive almost optimally, only given one single parameter for the AI, the "evaporation rate", and some CPU power, the more the best.

But, to be honest, this was not the first video I recorded today... it was the third one.

First one was a little dissaster! I used 100% of exclusion, meaning all futures were colliding with all the rest in the first seconds, along with a poor implementation of it. This made almost all of the futures to collapse and only 3 or 4 of them "survived" the first second or so.

Those few surviving futures were then the only ones being scanned deeper into the future, so the kart became blind to most of the available future outcomes, and driving blind is never a good idea.

Watch this "trully first" video before I delete it!

And here is video 2. It is nice, and shows some nice fractals, but the track had quite more friction, so driving it was not so challenging as is the third video I showed you first.