fixed species tracking bug

This commit is contained in:
MaxRobinsonTheGreat
2022-03-19 14:25:24 -05:00
parent 4f28f5ac9c
commit 0da27abd37
4 changed files with 33 additions and 14 deletions

View File

@@ -61,7 +61,7 @@ class Anatomy {
break;
}
}
this.checkTypeChange(cell.state);
this.checkTypeChange();
return true;
}
@@ -93,9 +93,7 @@ class Anatomy {
}
getNeighborsOfCell(col, row) {
var neighbors = [];
for (var x = -1; x <= 1; x++) {
for (var y = -1; y <= 1; y++) {
@@ -107,6 +105,19 @@ class Anatomy {
return neighbors;
}
isEqual(anatomy) { // currently unused helper func. inefficient, avoid usage in prod.
if (this.cells.length !== anatomy.cells.length) return false;
for (let i in this.cells) {
let my_cell = this.cells[i];
let their_cell = anatomy.cells[i];
if (my_cell.loc_col !== their_cell.loc_col ||
my_cell.loc_row !== their_cell.loc_row ||
my_cell.state !== their_cell.state)
return false;
}
return true;
}
}
module.exports = Anatomy;