davidrmiller / biosim4

Biological evolution simulator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pair check is incorrect

altivecer opened this issue · comments

In survival-criteria.cpp, in the case CHALLENGE_PAIRS there is a pair of for loops that have a bad check for the end of the loop

        for (int16_t x = indiv.loc.x - 1; x < indiv.loc.x + 1; ++x) {
            for (int16_t y = indiv.loc.y - 1; y < indiv.loc.y + 1; ++y) {

should be

        for (int16_t x = indiv.loc.x - 1; x <= indiv.loc.x + 1; ++x) {
            for (int16_t y = indiv.loc.y - 1; y <= indiv.loc.y + 1; ++y) {

same issue for the inner pair.

                        for (int16_t x1 = tloc.x - 1; x1 < tloc.x + 1; ++x1) {
                            for (int16_t y1 = tloc.y - 1; y1 < tloc.y + 1; ++y1) {

should be

                        for (int16_t x1 = tloc.x - 1; x1 <= tloc.x + 1; ++x1) {
                            for (int16_t y1 = tloc.y - 1; y1 <= tloc.y + 1; ++y1) {

Great catch! I'm testing it now and the results of that challenge are much better behaved. Thanks for finding and reporting this.

Thanks, looks interesting.