Car AI



Idea:

Create my own version of what I would consider AI through genetic development of an alogrithm rather than through evolution of a neural network.


How it works:


The program is a simple genetic algorithm that attemps to maximize the number of "gates" that it passes through in a set amount of time. In each generation, 75 contenstants are created from the previously best performing 5. These contestants then compete within the time limit and a new 5 are generated. This proceeds for the number of generations requested.

So how does the thinking really work?

This program generates algorithms, not neural nets. To control a car, it follows that two algorithms are needed. One to steer and the other to control the speed of the car. Each are given the same inputs which are:
    0: currentSpeed
    1: currentHeading
    2: distance to the nearest wall at heading - 90 degrees
    3: distance to the nearest wall at heading - 15 degrees
    4: distance to the nearest wall at heading degrees
    5: distance to the nearest wall at heading + 15 degrees
    6: distance to the nearest wall at heading + 90 degrees
    7: Empty bank (0)
This data is then fed into an algorithm which at each step has a number of options. Namely: it can either add (ADD), subtract (SUB), multiply (MUL), or divide (DIV) each of the banks by a constant or it can do any of the previous operations using one of the other banks as an input.
These memory slots are then summed and the result is used to determine the angular and linear acceleration of the car.
Example:
[Log] Total best score: 58
[Log] Forward algorithm:
[Log] Thought Process:
    Op0 memory 0 MUL 1.9909918461400171
    Op1 memory 6 SUB 1.0044959492837375
    Op2 memory 6 SUB param 0.0
    Op3 memory 0 DIV param 6.0
    Op4 memory 5 ADD 3.216029925908776
    Op5 memory 1 ADD 9.229154585067505
    Op6 memory 4 ADD 0.9633305590034583
    Op7 memory 1 DIV 0.6477050276102642
    Op8 memory 1 SUB 0.09247026152972995
    Op9 memory 2 MUL 0.1751055982904774
    Op10 memory 1 ADD 11.179253111258982
    Op11 memory 0 DIV 12.356069507922896

[Log] Turn algorithm:
[Log] Thought Process:
    Op0 memory 0 SUB param 3.0
    Op1 memory 6 ADD 0.011786994798383129
    Op2 memory 3 SUB param 0.0
    Op3 memory 0 SUB 5.35517575318139
    Op4 memory 3 MUL 14.351967383468132
    Op5 memory 0 MUL param 3.0
    Op6 memory 2 ADD param 0.0
    Op7 memory 4 SUB 8.557622729657288
    Op8 memory 3 ADD 5.199762634389315
    Op9 memory 6 DIV 0.6158928024353526
    Op10 memory 3 MUL param 6.0
    Op11 memory 0 ADD param 4.0
    Op12 memory 3 SUB 14.925135556501836
    Op13 memory 6 MUL 1.0919596604599546


Results:



Gen 1 Track 0:




Gen 50 Track 0:




Gen 100 Track 0:




Gen 500 Track 0:




Gen 500 Track 1:




Gen 1000 Track 1:




Gen 1000 Track 1:






Other interesting algorithms:


[Log] Total best score: 43
[Log] Forward algorithm:
[Log] Thought Process:
    Op0 memory 0 MUL 4.977407438922135
    Op1 memory 6 SUB 1.765937767776252
    Op2 memory 1 SUB 0.06202127576171461
    Op3 memory 5 DIV 3.542211562965012
    Op4 memory 0 MUL 0.0
    Op5 memory 2 MUL 1.1030984868370532
    Op6 memory 6 SUB 2.1696881860253234
    Op7 memory 5 ADD 0.03613365990284419
    Op8 memory 5 DIV 12.849901629420495
    Op9 memory 4 MUL param 1.0
    Op10 memory 4 DIV param 6.0
    Op11 memory 3 MUL 7.751743031027261E-4
    Op12 memory 1 SUB param 1.0
    Op13 memory 4 MUL 1.7180709008280353
    Op14 memory 5 MUL 0.6939241684053701
    Op15 memory 6 MUL 1.6662045605102807

[Log] Turn algorithm:
[Log] Thought Process:
Op0 memory 0 MUL 1.1635159521787581
Op1 memory 3 ADD 0.9590269237498426
Op2 memory 0 SUB param 2.0
Op3 memory 3 ADD 12.560600975163519
Op4 memory 1 MUL 1.9770087927085752E-4
Op5 memory 1 SUB param 3.0
Op6 memory 3 MUL 0.04198699970536607
Op7 memory 4 SUB param 4.0
Op8 memory 2 SUB param 2.0
Op9 memory 5 MUL 0.006433354621304804

[Log] Total best score: 123
[Log] Thought Process:
Op0 memory 5 ADD 4.929257915070751
Op1 memory 3 MUL 10.284514530329385
Op2 memory 1 DIV 2.5183781842450816
Op3 memory 2 ADD 0.9537686248078034
Op4 memory 4 ADD param 6.0
Op5 memory 5 DIV 0.3376596897238228
Op6 memory 4 MUL 7.674273644540845
Op7 memory 2 SUB 6.56357881919724E-4
Op8 memory 4 MUL param 0.0
Op9 memory 2 MUL 1.3624002738195493
Op10 memory 0 SUB 10.950260608557937
Op11 memory 4 MUL param 5.0
Op12 memory 4 SUB param 0.0
Op13 memory 1 SUB param 1.0
Op14 memory 5 ADD 8.408115389826929
Op15 memory 5 SUB param 0.0
Op16 memory 0 SUB param 4.0
Op17 memory 4 ADD 0.5721068693446313
Op18 memory 2 MUL 8.89707079767778
Op19 memory 2 ADD 14.9504895971747
Op20 memory 2 DIV 8.674547205236566
Op21 memory 4 SUB 2.5731291687524958
Op22 memory 5 MUL param 2.0

[Log] Turn algorithm:
[Log] Thought Process:
Op0 memory 4 SUB param 0.0
Op1 memory 6 DIV param 0.0
Op2 memory 5 MUL param 1.0
Op3 memory 6 DIV 1.6646560735682057
Op4 memory 5 ADD param 5.0
Op5 memory 2 SUB 4.977651223691376
Op6 memory 3 SUB param 4.0
Op7 memory 1 MUL param 3.0
Op8 memory 0 ADD 7.494660512352863
Op9 memory 2 DIV 3.3750695948489744
Op10 memory 3 SUB 1.108781504311783
Op11 memory 3 ADD 8.832498301705474
Op12 memory 2 DIV 15.92625147785468
Op13 memory 2 ADD param 5.0
Op14 memory 1 ADD 1.9041660754037342
Op15 memory 4 ADD 9.082083398509228
Op16 memory 4 MUL 8.265724138462067


All content on this page belongs to Zachary Porter. You may use, reproduce, or modify anything from this website, provided that you give credit to zackporter.com in your usage.