davidrmiller / biosim4

Biological evolution simulator
Other
3.21k stars 460 forks source link

Typo in random gene creation? #32

Closed jeremy-pereira closed 2 years ago

jeremy-pereira commented 2 years ago

I'm looking to create my own evolution simulation and this code base seemed like an excellent place to start, so I was perusing the code and I came across the gene declaration and the makeRandomWeight code.

struct Gene { //__attribute__((packed)) Gene {

    // <SNIP>

    static int16_t makeRandomWeight() { return randomUint(0, 0xefff) - 0x8000; }
};

Why 0xefff? Are you deliberately trying to create weights that are biased towards the negative? Or is it a typo for 0xffff?

davidrmiller commented 2 years ago

That looks like a typo or a lingering remnant of some previous design change. Eventually, mutations should overwhelm the effects of this starting bias, but you're right, this does look like biased starting conditions. I'll fix that. Thanks for finding this.

Edit: fixed in main branch.