Skip to content

Instantly share code, notes, and snippets.

@halfdan
Created December 5, 2011 22:40
Show Gist options
  • Save halfdan/1435736 to your computer and use it in GitHub Desktop.
Save halfdan/1435736 to your computer and use it in GitHub Desktop.
// Generate random genes
ts.genes = make([]ga.Gene, ts.nGenes)
var proto = make([]int, ts.geneLength)
var i int = 0
for key, _ := range coords {
proto[i] = key
i++
}
// Initialize all len(genes) and shuffle
for i := 0; i < len(ts.genes); i++ {
ts.genes[i].Data = make([]int, len(proto))
copy(ts.genes[i].Data, proto)
shuffleArray(&(ts.genes[i].Data))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment