davidrmiller / biosim4

Biological evolution simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why is index 0 reserved in the individuals vector?

hornta opened this issue · comments

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.