MCPcopy Create free account
hub / github.com/OpenNFS/OpenNFS / Mutate

Method Mutate

src/RaceNet/TrainingGround.cpp:29–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29void TrainingGround::Mutate(RaceNet &toMutate) {
30 for (uint8_t mut_Idx = 0; mut_Idx < 5; ++mut_Idx) {
31 unsigned long layerToMutate = rand() % toMutate.net.W.size();
32
33 auto &m = toMutate.net.W[layerToMutate];
34
35 int h = m.getHeight();
36 int w = m.getWidth();
37
38 int xNeuronToMutate = rand() % h;
39 int yNeuronToMutate = rand() % w;
40
41 m.put(xNeuronToMutate, yNeuronToMutate, m.get(xNeuronToMutate, yNeuronToMutate) * Utils::RandomFloat(0.5, 1.5));
42 }
43}
44
45// Move this to agent class?
46float TrainingGround::EvaluateFitness(shared_ptr<Car> &car_agent) {

Callers

nothing calls this directly

Calls 5

RandomFloatFunction · 0.85
putMethod · 0.80
getMethod · 0.80
getHeightMethod · 0.45
getWidthMethod · 0.45

Tested by

no test coverage detected