private int getNextYForEnemy(int x, int y, DataPoint dp) { double dist = computeDistance(x, y, dp.getCoordX(), dp.getCoordY()); if (dist <= ENEMY_DIST_BY_TURN) { return dp.getCoordY(); } else { return (int) (y + ((dp.getCoordY() - y) * ENEMY_DIST_BY_TURN / dist)); } }
private int getNextYForEnemy(Enemy en, DataPoint dp) { double dist = computeDistance(en.getCoordX(), en.getCoordY(), dp.getCoordX(), dp.getCoordY()); if (dist <= ENEMY_DIST_BY_TURN) { return dp.getCoordY(); } else { return (int) (en.getCoordY() + ((dp.getCoordY() - en.getCoordY()) * ENEMY_DIST_BY_TURN / dist)); } }
private DataPoint findClosestDPForEnemy(Enemy en) { DataPoint closestDataPoint = null; int closestDistanceFromDP = 0; for (DataPoint dp : dataPointList) { int dist = computeDistance( getNextXForEnemy(en, dp), getNextYForEnemy(en, dp), dp.getCoordX(), dp.getCoordY()); if (closestDistanceFromDP == 0) { closestDistanceFromDP = dist; closestDataPoint = dp; } else { if (dist < closestDistanceFromDP) { closestDistanceFromDP = dist; closestDataPoint = dp; } } } return closestDataPoint; }
private int getLeftTurnNumberBeforeEnemyReachData(Enemy en, DataPoint dp) { int dist = computeDistance( getNextXForEnemy(en, dp), getNextYForEnemy(en, dp), dp.getCoordX(), dp.getCoordY()); return Math.round(dist / ENEMY_DIST_BY_TURN); }