Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void findSatisfied(Actor[][] world, double threshold){
- for (int i = 0; i < world.length; i++){
- for (int j = 0; j < world[i].length; j++){
- if (world[i][j] != null){
- Actor[] tmp = new Actor[8];
- for (int k = 0; k < tmp.length; k++){
- tmp[k] = null;
- }
- int tmpCount = 0;
- if (i - 1 >= 0){
- tmp[tmpCount] = world[i - 1][j];
- tmpCount++;
- if (j + 1 < world.length){
- tmp[tmpCount] = world[i - 1][j + 1];
- tmpCount++;
- }
- if (j - 1 >= 0){
- tmp[tmpCount] = world[i - 1][j - 1];
- tmpCount++;
- }
- }
- if (i + 1 < world.length) {
- tmp[tmpCount] = world[i + 1][j];
- tmpCount++;
- if (j - 1 >= 0){
- tmp[tmpCount] = world[i + 1][j - 1];
- tmpCount++;
- }
- if (j + 1 < world.length){
- tmp[tmpCount] = world[i + 1][j + 1];
- tmpCount++;
- }
- }
- if (j + 1 < world.length){
- tmp[tmpCount] = world[i][j + 1];
- tmpCount++;
- }
- if (j - 1 >= 0){
- tmp[tmpCount] = world[i][j - 1];
- tmpCount++;
- }
- double percent = getNeighbourPercent(tmp, world[i][j].color);
- if (percent >= threshold){
- world[i][j].isSatisfied = true;
- }
- }
- }
- }
- }
RAW Paste Data