MCPcopy Create free account
hub / github.com/davidrmiller/biosim4 / displaySensorActionReferenceCounts

Function displaySensorActionReferenceCounts

src/analysis.cpp:318–351  ·  view source on GitHub ↗

Print how many connections occur from each kind of sensor neuron and to each kind of action neuron over the entire population. This helps us to see which sensors and actions are most useful for survival.

Source from the content-addressed store, hash-verified

316// each kind of action neuron over the entire population. This helps us to
317// see which sensors and actions are most useful for survival.
318void displaySensorActionReferenceCounts()
319{
320 std::vector<unsigned> sensorCounts(Sensor::NUM_SENSES, 0);
321 std::vector<unsigned> actionCounts(Action::NUM_ACTIONS, 0);
322
323 for (unsigned index = 1; index <= p.population; ++index) {
324 if (peeps[index].alive) {
325 const Indiv &indiv = peeps[index];
326 for (const Gene &gene : indiv.nnet.connections) {
327 if (gene.sourceType == SENSOR) {
328 assert(gene.sourceNum < Sensor::NUM_SENSES);
329 ++sensorCounts[(Sensor)gene.sourceNum];
330 }
331 if (gene.sinkType == ACTION) {
332 assert(gene.sinkNum < Action::NUM_ACTIONS);
333 ++actionCounts[(Action)gene.sinkNum];
334 }
335 }
336 }
337 }
338
339 std::cout << "Sensors in use:" << std::endl;
340 for (unsigned i = 0; i < sensorCounts.size(); ++i) {
341 if (sensorCounts[i] > 0) {
342 std::cout << " " << sensorCounts[i] << " - " << sensorName((Sensor)i) << std::endl;
343 }
344 }
345 std::cout << "Actions in use:" << std::endl;
346 for (unsigned i = 0; i < actionCounts.size(); ++i) {
347 if (actionCounts[i] > 0) {
348 std::cout << " " << actionCounts[i] << " - " << actionName((Action)i) << std::endl;
349 }
350 }
351}
352
353
354void displaySampleGenomes(unsigned count)

Callers 1

displaySampleGenomesFunction · 0.85

Calls 3

sensorNameFunction · 0.85
actionNameFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected