So today I was playing with the ships, because it was so cool. I tried to add some things, by myself, to it such as obstacles and a success scoreboard.
Problem #1: Somehow, the ships managed to make it through the obstacle.
The ships could go through walls…
For some inexplicable reason, so it seemed, some of the ships were passing through the barrier while others didn’t. I tried extending the wall from x > 0 to x > -2000, just to make sure that none of the ships were slipping through that way. This problem still occurred, so I found out that it was the way my code was written, which allowed the location of the ship to change before it could stop the ship. And, when the ship has already passed the wall, it will carry on as if there wasn’t one to begin with. Thus, instead of rewriting the code, I decided to just make the wall thicker, so that the ship wouldn’t pass through in a single cycle.
Problem #2: The ships counter was acting weird.
272 successes when there were only 50 ships?
I turned off the wall, to save time. But the success counter just went up really weirdly. I realised that it was cos of a stupid mistake. I made the counter increment every time the frame refreshed and it didn’t reset until a new cycle, therefore accounting for the massive digit. That was fixed easily.
No matter how many cycles, for some populations, the ships seem to never progress beyond hitting the walls. For other populations, the ships eventually reach the target. I attribute this to the initial genes of the population and the low rate of mutation.
By increasing the population from 50 to 100, I allowed greater chances of success, and by altering the obstacle so that it was a bit lower and shorter allowed the ships to get through it easier. Also, by making the wall a bit lower allowed the ships that hit it, to have a lower fitness and therefore a smaller effect on the mating pool.
I also decreased the mutation rate to 0.005 in order to lower variation.
Final Simulation (click to view the whole thing):
As you can see, like before, the ships initially accelerated in random directions. Eventually, a lone ship who has somehow, either by mutation or some combination of genes, gone past the wall. In the next cycle, there are more ships that get closer and more, until eventually, most get to the target. The success counter is still a bit erroneous because it only takes into account the ships that reach the depot in the cycle and not those that would have reached it given just a bit more time. This is why the success rate is a bit low, even though most of the ships can be extrapolated to reach the target.