davidrmiller / biosim4

Biological evolution simulator
Other
3.21k stars 460 forks source link

Why is index 0 reserved in the individuals vector? #82

Closed hornta closed 2 years ago

davidrmiller commented 2 years ago

Hi @hornta, the reason for reserving index 0 is to make it trivially easy to distinguish between unoccupied and occupied grid points. Class Grid holds a 2D array of 16-bit unsigned integers where each integer is zero if that grid point is unoccupied, otherwise it's the index of the individual in class Peeps. That makes it easy to test if a grid point is occupied or not, but then we have to either offset all the Peeps indexes by one or else not use index 0 in Peeps. Good luck with the porting project, it sounds interesting.