Advertisement

GA coding question

Started by October 08, 2004 01:11 PM
0 comments, last by Kylotan 20 years, 1 month ago
Hello. I'm trying to implement a simple GA using the Traveling Salesman Probem. I'm using "AI Techniques for Game Programming". For my GA code, I need to have random numbers between 0 to N (# cities). This will be a solution (chromosome). How can I have them be random and not have duplicates? Thanks for the help.
http://www.rivetcode.com
Pick all the numbers in turn, stick them in a list, array, or whatever, and then shuffle them. std::random_shuffle() will do this for you in C++ and random.shuffle() works in Python.

This topic is closed to new replies.

Advertisement