private void applyRule(int row, int column, Individual[][] a_lattice) { /* * TODO: clever way to do this with iteration * */ // placeholder Individual currentIndividual = a_lattice[row][column]; if (currentIndividual.state == 'I') { // infect neighbours Individual neighbour = getLeft(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } // update the time spent infected // if this time exceeds the infectious period then turn Removed ('R') currentIndividual.updateDiseaseState(); neighbour = getRight(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } // update the time spent infected // if this time exceeds the infectious period then turn Removed ('R') currentIndividual.updateDiseaseState(); neighbour = getDown(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } // update the time spent infected // if this time exceeds the infectious period then turn Removed ('R') currentIndividual.updateDiseaseState(); neighbour = getUp(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } // update the time spent infected // if this time exceeds the infectious period then turn Removed ('R') currentIndividual.updateDiseaseState(); neighbour = getUpLeft(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } neighbour = getDownLeft(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } neighbour = getUpRight(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } neighbour = getDownRight(row, column, a_lattice); if (neighbour.getDiseaseState() == 'S' && Math.random() < beta) { // transmission happens neighbour.infect(); if (currentIndividual.isPrimaryCase) { this.countOfSecondaryInfections++; } } } }