MCPcopy Create free account
hub / github.com/catabriga/graphwar / getFunctionToReproduce

Method getFunctionToReproduce

src/Graphwar/ComputerPlayer.java:261–278  ·  view source on GitHub ↗
(EvolvableFunction[] functions, double totalPoints)

Source from the content-addressed store, hash-verified

259 }
260
261 private int getFunctionToReproduce(EvolvableFunction[] functions, double totalPoints)
262 {
263 double randomPoints = totalPoints*random.nextDouble();
264
265 for(int i=0; i<functions.length; i++)
266 {
267 if(totalPoints > randomPoints)
268 {
269 totalPoints -= functions[i].points;
270 }
271 else
272 {
273 return i;
274 }
275 }
276
277 return 0;
278 }
279
280 private double getTotalPoints(EvolvableFunction[] functions)
281 {

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected