@@ -116,14 +116,17 @@ public void addNeuronID(final long nodeID, final List<NEATNeuronGene> vec,
116116
117117 /**
118118 * Choose a parent to favor.
119- *
119+ *
120+ * @param rnd
121+ * A random number generator.
120122 * @param mom
121123 * The mother.
122124 * @param dad
123125 * The father.
124126 * @return The parent to favor.
125127 */
126- private NEATGenome favorParent (final NEATGenome mom , final NEATGenome dad ) {
128+ private NEATGenome favorParent (final Random rnd , final NEATGenome mom ,
129+ final NEATGenome dad ) {
127130
128131 // first determine who is more fit, the mother or the father?
129132 // see if mom and dad are the same fitness
@@ -133,7 +136,7 @@ private NEATGenome favorParent(final NEATGenome mom, final NEATGenome dad) {
133136 // if mom and dad are the same fitness and have the same number
134137 // of genes,
135138 // then randomly pick mom or dad as the most fit.
136- if (Math . random () > 0 ) {
139+ if (rnd . nextDouble () < 0.5 ) {
137140 return mom ;
138141 } else {
139142 return dad ;
@@ -219,7 +222,7 @@ public void performOperation(final Random rnd, final Genome[] parents,
219222 final NEATGenome mom = (NEATGenome ) parents [parentIndex + 0 ];
220223 final NEATGenome dad = (NEATGenome ) parents [parentIndex + 1 ];
221224
222- final NEATGenome best = favorParent (mom , dad );
225+ final NEATGenome best = favorParent (rnd , mom , dad );
223226 final NEATGenome notBest = (best == mom ) ? mom : dad ;
224227
225228 final List <NEATLinkGene > selectedLinks = new ArrayList <NEATLinkGene >();
0 commit comments