public void insert(int i, int j, BioUnit been) { if (this.rightPos(i, j)) { this.cell[i, j] = been; } }
public void next_Rabbit_Carrot_Step() { BioUnit[,] aux = new BioUnit[this.rows, this.cols]; for (var i = 0; i < this.rows; i++) { for (var j = 0; j < this.cols; j++) { aux[i, j] = null; //rule 2, rule 5 //rule 1 if (this.specie(this.cell[i, j]) == "Carrot") { if (this.surrondingNeighborns(i, j, "Rabbit") == 0) { if (this.cell[i, j].will_I_live()) { aux[i, j] = this.cell[i, j]; } } else { //rule 3 this.firstRabbit(i, j).eat(); } } //rule 4 else if (this.specie(this.cell[i, j]) == "Rabbit") { if (this.cell[i, j].will_I_live()) { aux[i, j] = this.cell[i, j]; } } else { //rule 6 if (this.cell[i, j] == null) { if (this.surrondingNeighborns(i, j, "Rabbit") >= 2) { aux[i, j] = new Rabbit(i, j, this); } else if (this.surrondingNeighborns(i, j, "Carrot") >= 3) { aux[i, j] = new Carrot(i, j, this); } } } } } for (var i = 0; i < this.rows; i++) { for (var j = 0; j < this.cols; j++) { this.cell[i, j] = aux[i, j]; } } }