/** preforms propogation and collision detected amongst local neighoubourhood */ public Block[] updateWind() { Block[] n = new Block[neighbours.length + 1]; for (int i = 0; i < n.length; i++) { if (i == n.length - 1) { n[i] = new EarthBlock(); n[i].setXPos(this.getXPos()); n[i].setYPos(this.getYPos()); n[i].setZPos(this.getZPos()); } else { n[i] = new EarthBlock(); n[i].setXPos(neighbours[i].getXPos()); n[i].setYPos(neighbours[i].getYPos()); n[i].setZPos(neighbours[i].getZPos()); } } int tempVelX = 0; int tempVelY = 0; int tempVelZ = 0; int xcounter = 0; int ycounter = 0; int zcounter = 0; double xWind = 0.0; double yWind = 0.0; double zWind = 0.0; int windcounter = 0; for (int i = 0; i < n.length - 1; i++) { Block b = neighbours[i]; // System.out.println("boo "+b.getXPos()+","+b.getVelX()+","+b.getBlockState()); if (b.getXPos() != -1) { // System.out.println("boo "+b.getXPos()+","+b.getVelX()+","+b.getBlockState()); if ((b.getXPos() + b.getVelX() == this.getXPos()) && (b.getYPos() + b.getVelY() == this.getYPos()) && (b.getZPos() + b.getVelZ() == this.getZPos())) { tempVelX = tempVelX + b.getVelX(); tempVelY = tempVelY + b.getVelY(); tempVelZ = tempVelZ + b.getVelZ(); // xWind = xWind+b.getXWindStrength()*b.getVelX(); // yWind = yWind+b.getYWindStrength()*b.getVelY(); // zWind = zWind+b.getZWindStrength()*b.getVelZ(); // System.out.println("hello"); // windcounter++; // add transported pheromones // System.out.println("transfered: // "+b.getWindQueenPheromone()+","+b.getWindStrength()+","+b.getQueenPheromone()); n[n.length - 1].addCementPheromone(b.getWindCementPheromone()); n[n.length - 1].addQueenPheromone(b.getWindQueenPheromone()); n[i].addCementPheromone(-b.getWindCementPheromone()); n[i].addQueenPheromone(-b.getWindQueenPheromone()); // System.out.println(b.getBlockState()); } // if(b.getVelX() != this.getVelX() && b.getVelX() != 0) xcounter++; // if(b.getVelY() != this.getVelY()&& b.getVelY() != 0) ycounter++; // if(b.getVelZ() != this.getVelZ()&& b.getVelZ() != 0) zcounter++; } } // System.out.println(xWind); // System.out.println(windcounter); // System.out.println("currentStrength: "+this.getWindStrength()); // if(windcounter != 0 ) n[n.length-1].setXWindStrength(Math.abs(xWind)); // if(windcounter != 0 ) n[n.length-1].setYWindStrength(Math.abs(yWind)); // if(windcounter != 0 ) n[n.length-1].setZWindStrength(Math.abs(zWind)); // System.out.println("new air wind strength: "+n[n.length-1].getWindStrength()); // use average velocities to calculate update // System.out.println("Air Collisions: "+tempVelX+","+tempVelY+","+tempVelZ); n = xVelocity(tempVelX, xcounter, n); n = yVelocity(tempVelY, ycounter, n); n = zVelocity(tempVelZ, zcounter, n); // keeps a constant flow accross x plane if (this.getXPos() == 0) n[n.length - 1].setVelX(1); if (this.getXPos() == 19) { n[n.length - 1].addCementPheromone(-this.getWindCementPheromone()); n[n.length - 1].addQueenPheromone(-this.getWindQueenPheromone()); } return n; }