Title
j

Joakim Fast

03/01/2018, 4:33 PM
Yes it is
p

poohbar

03/01/2018, 4:39 PM
In pseudocode the algorithm is really simple:
``````p <- generateInitialPopulation
while (end condition is not met):
select best fit survivors using fitness function
mate and mutate survivors
p <- combine offspring and elites into new population
now p has your best population``````
j

Joakim Fast

03/01/2018, 4:40 PM
Yes i've looked into it but i need to have my initial population randomized that i am doing now, im doing the game scheduling problem and the Pair<Int,Int> is one single game
p

poohbar

03/01/2018, 4:42 PM
To generate the random population you can just do:
``````val p = List(n) { rnd.nextInt() to rnd.nextInt() }
// or if you dont like this then:
val p = List(n) { Pair(rnd.nextInt(), rnd.nextInt()) }``````
j

Joakim Fast

03/01/2018, 4:48 PM
I see, but the random numbers cannot be linked to the teams anyhow can they?
p

poohbar

03/01/2018, 4:52 PM
If you want to link each creature to a team just create your own type for storing creatures:
``data class Creature(val x: Int, val y: Int, val t: Team)``
j

Joakim Fast

03/01/2018, 4:52 PM
Oh yes, i've had my teams hardcoded. That's bad practise i guess?
Thats why i wanted to play with the randoms and so on