Is the code source for the game referee available somewhere?
I think I have an issue with floating points precision.
If you take a look at the following replay: Coding Games and Programming Challenges to Code Better you can see that, at turn 13, my AI says "13,457 178,300 1" meaning it found a move sequence achieving 178,300 points. It never finds anything better and thus executes the sequence until the end.
Despite this, it ends up scoring only 110k. This is quite difficult to debug and the âHordeâ test case is the most obvious one.
This specific replay is using double but Iâve also tried with float and got the same kind of errors. (Iâm using C++)
If anyone experienced the same kind of issue, I would be glad to know what I can do to try and fix it.
EDIT: I managed to solve my issue, it had nothing to do with floating-point precision, it was a typical human-made mistake!
You know were Ash must go (x2,y2) and his starting point (x1,y1)
You could compute hypotenuse as square root((x2-x1)(x2-x1)+(y2-y1)(y2-y1))
and use it to compute x3,y3 with his dmax (1000 here)
I need to know what is special about the âSplit-second reflexâ test set. My code fails but I donât know why. Does anyone know its particularity?
Thx
Hi
Iâve managed to simulate the game locally and I can also visualize it. Now I want to implement my GA but Iâm having trouble to implement Crossover and Mutation. My DNA is a sequence of Direction Vectors from Ashâs Position along with a magnitude ranging from 0 (Ash stands still for this turn) to 1000 (Ash moves at max speed). I calculate the score for all those game states at the end and now I want to Crossover 2 Games that did reach a good score. But how? Lets say Gamestate A finished the game in 30 turns and B in 40. I have no clue how to do the Crossover with DNA squences that have a different length. And even if I figure it outâŠthe result is likely to produce a non-finished game state. So the DNA squence from the result of the Crossover with A and B could be more or less than 30 or 40 turns. Can someone help my out with a hint?
Would this be working for you: always have a fixed amount of genes (say 40) during crossover, while ignoring any extra genes during simulation? e.g. in one simulation, the game ends in 30 turns, so ignore the extra 10 genes; in another simulation, all the genes are considered because the game ends in 40 turns.
Thanks for your quick reply
Yeah Iâve also thought about that but Iâve produced a lot of unfinished gamestates. I found that bug while visualizing it and saw that Ash stopped moving due his movement queue was out of moves while there were still Humans and Zombies left. My GA could âdecideâ to kite the zombies a long time to get them all on one spot to make the highest score but eventually it takes only 15 Turns to win or lose. I can try to check the crossover result if its finished when doing all those moves and if not⊠I dont know⊠maybe fill it with some random moves until its over? But I doubt this GA can converge⊠But I can give that a try
I discovered GA a few days ago and I am trying to implement one for this problem. I managed to get some results offline (like achieving the max score for the combo opportunity test) but my algo takes too much time.
Basically at generation 0, I defined my genomes/individuals as an array of random x,y moves. Then Iâm passing those genomes into my fitness function, which is a simulation of a complete game and returns a final score game. Finally I proceed with the selection / crossover / mutation sequence.
After trying this, I realized that I am having it wrong right from the start. Simulating a whole game for each genome is taking too much time, and generating an array of random coordinates for a complete game is still way too random as all of my generation 0 genomes frequently returns a score of 0, even if I have a 200 or 300 population size.
So what do you mean by âyou must have simulation for turns aheadâ ? A fitness function simulating a complete game doesnât seem to work for me. Do I need to predict the state of the game for only one turn in the future with a fitness function returning something other than the general score ? And repeating this GA each turn ?
Simulating a whole game shouldnât take too much time, itâs a linear for loop with 200-300 iterations, updating character positions on each, if you could profile you simulation, see if you have unnecessary memory allocations or copying of big data structures also the language youâre using could affect the performance.
You could simulate the game not until the end but you must come up with very good evaluation function on not finished game, which is very tricky.
The idea of the complete random first population is to give you good distribution over the search space.
Alright, I will try to check the efficiency of my code. I am also using an interpreted language so it might be a part of the problem as well. But even if my code is too slow for the game, it is still very satisfying to get some very good scores offline with this first GA, as I am relatively new to programming.
So thanks a lot for your very useful posts regarding GA, it helped me a lot!
Same experience. YNext XNext is not actually the next coordinate of the zombie. instead, I think it is the target coordinate. so every game loop, the value will always be the same for that zombie until the first target is killed. But then, YNext value is weird.
I am struggle on the âreflexâ case. all other ok for the moment. so i work in Python 3 with âtableâ base on dict for Zombies and Humans in fill it first.
then i check the distance variation and movement ratio between Ash/zombies/Humans for determine save and loss.
only on reflex during debug i found third data input instead of 2. two had Id 1 but with different move ratio and specially one of the Zombie id 1 looks wrong regarding positionnal on debug interface + move ratio found in write debug.
could someone help me where i am wrong ? or someone already notice that issue ?