Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Someone at work once made a Robocode tournament, and we spent a day paid playing with it.

Most people went for an "if-based" strategy. If close to wall turn, if pointing towards enemy shoot, etc. And when that works apply some more rules and geometric calculations.

I did mine trying using neural nets. One net that would learn the movement patterns of opponents (offline) and predict positions and shoot there (since bullets have move time). That actually worked fairly well with a really simple net.

For movement, however, deep-RL etc wasn't that big yet, so I struggled a bit. What to train on? So I used genetic algorithms to train this part of the net. Not the best results, but it worked. Mind you these were simple homemade nets, not sure deep learning even was a concept then.

Hard to write a good fitness function. I tried to deduct the fitness if it hit a wall. Then it would just stand still. Tried to then increase fitness based on movement, then it would just oscillate at one spot. Etc. Etc. GAs exploit all loopholes, pretty interesting.

Great fun. Great tool to explore programming at all levels.



If you were going to use genetic algorithms, you should have gone all in- seed with a randomized neural network, have them compete, and breed the winners.

Literally survival of the fittest!


Hehe, yeah, I did something similar later, using game score as the fitness score (so still a chance of breeding even though you didn't win) in a kind of tournament selection. The problem is each generation then takes loads of time to simulate, compared to just observing their behavior for a short time.

But that worked much better as a fitness score, yes. It's very true that what you measure is what will be optimized for. Both for employees and robots.


I had a professor who said that the first thing a GA discovers is that you didn't describe the problem carefully enough.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: