Search code examples
algorithmgenetic-algorithmevolutionary-algorithm

Can a genetic algorithm strategy (chromosome) use memory?


I've been wanting to implement a genetic algorithm that devises a strategy for the parachuting robots problem.

Basically two robots land on random locations of an infinite one dimensional world divided into discrete squares. Each robot leaves a parachute where it lands.

The goal is to write an algorithm that if both robots follow its guaranteed to make them meet.

Possible actions. Move left, move right, wait a turn. Possible states: standing on a parachute, not standing on a parachute.

From what I understand about encoding strategies as a chromosome I could do something like this.

0 move left
1 move right 
3 wait

And for states first index would be no parachute and second would be with a parachute so

03 - move left if you are not on a parachute and wait if you are.

The actual solution to the problem involves strategies like: move left and wait in a loop unless you see a parachute and then stop waiting (to catch up with the other robot) how can strategies like that be encoded as a chromosome? Thanks.


Solution

  • If you want to use a genetic algorithm to solve the problem, I believe your best shot is to use a list of 2-digit ints as chromosome. each digit would represent an action taken for one of the states. so if we say:

    0 means move left

    1 means move right

    3 means wait

    Then 01 would mean

    if(state == noParachute){
        moveLeft();
    }else{
        moveright();
    }
    

    You could just let the length of the chromosome increase over time to get more complex solutions.

    A different aproach would be to use a neural network and train it using NEAT.