Targeting with Genetic Algorithm

From Robowiki
Jump to navigation Jump to search

Simply it is determining the GF values in the nodes with genetic algorithm.

How To Use Genetic Algorithm In Targeting

Of course there can be lots of other ways but I will say how I used it on WormHole. WormHole improves it's gun with genetic algorithms during the match. Latest version: https://www.dropbox.com/s/gupdskse08umgtv/dsekercioglu.WormHole_1.2.jar?dl=1

Guessing the nodes
Make a standard segmented [GF] gun. Remove the bins so there will be only one GF value there.
Then with genetic algorithm create some chromosomes that has their own stats.
Keep a track of your firing data like {latVelWhenFired, advVelWhenFired, hit GF} so you will be able to use it in fitness method.
Then sort the chromosomes and get the first chromosome in the list. Put the first chromosome's stats to your real stats.
Mutation
Normally mutation in genetic algorithm can hurt the genes or it can make it better.
Generally it is randomised.
In robocode for adapting fast it randomly takes an index (index = size - (int)Math.round(Math.random() * 10)) like this code for using valid data.
If enemy is disabled mutation will help it to adapt quickly.
Problems
It skips turns if there are (too many generations per tick/ too many chromosomes)
It can't hit strange patterns if the enemy doesn't move perpendicular to the robot.


Note: If you have something to say just write it.