Skip to content

Commit 03aaf70

Browse files
committed
Population ID accessible from Python
1 parent 889809a commit 03aaf70

5 files changed

Lines changed: 12 additions & 5 deletions

File tree

examples/ball_keeper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def main():
298298

299299

300300
g = NEAT.Genome(0, 6, 0, 2, False,
301-
NEAT.ActivationFunction.TANH, NEAT.ActivationFunction.UNSIGNED_SIGMOID, 0, params, 0)
301+
NEAT.ActivationFunction.TANH, NEAT.ActivationFunction.UNSIGNED_SIGMOID, 0, params, 0, 1)
302302
pop = NEAT.Population(g, params, True, 1.0, rnd.randint(0, 1000))
303303

304304
best_genome_ever = None

setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22

3-
from __future__ import print_function
3+
#from __future__ import print_function
44
from setuptools import setup, Extension
55
import sys
66
import os
@@ -23,8 +23,8 @@ def _single_compile(obj):
2323
list(multiprocessing.pool.ThreadPool(N).imap(_single_compile,objects))
2424
return objects
2525

26-
import distutils.ccompiler
27-
distutils.ccompiler.CCompiler.compile=parallelCCompile
26+
#import distutils.ccompiler
27+
#distutils.ccompiler.CCompiler.compile=parallelCCompile
2828

2929

3030
''' Note:

src/Population.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ Population::Population(const Genome& a_Seed, const Parameters& a_Parameters,
155155
m_InnovationDatabase.Init(a_Seed);
156156

157157
m_BestGenome = m_Species[0].m_Individuals[0];//GetLeader();
158+
159+
m_ID = 0;
158160

159161
//Sort();
160162

@@ -187,6 +189,7 @@ Population::Population(const std::string a_sFileName)
187189
m_Generation = 0;
188190
m_NumEvaluations = 0;
189191
m_NextSpeciesID = 1;
192+
m_ID = 0;
190193
m_GensSinceBestFitnessLastChanged = 0;
191194
m_GensSinceMPCLastChanged = 0;
192195

src/Population.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class Population
142142

143143
// The list of species
144144
std::vector<Species> m_Species;
145+
146+
int m_ID;
145147

146148

147149
////////////////////////////
@@ -355,6 +357,7 @@ class Population
355357
ar & m_NumEvaluations;
356358
ar & m_GensSinceLastArchiving;
357359
ar & m_QuickAddCounter;
360+
ar & m_ID;
358361

359362
//ar & m_TempSpecies;
360363
//ar & m_BehaviorArchive;

src/PythonBindings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ BOOST_PYTHON_MODULE(_MultiNEAT)
405405
.def_readwrite("Species", &Population::m_Species)
406406
.def_readwrite("Parameters", &Population::m_Parameters)
407407
.def_readwrite("RNG", &Population::m_RNG)
408+
.def_readwrite("ID", &Population::m_ID)
408409

409410
.def_pickle(Population_pickle_suite())
410411
;

0 commit comments

Comments
 (0)