/** * Returns the cost in actionpoints for a given number of steps in the current direction. * * @param steps the number of steps the worm is going to move. * @return The cost of steps (integer) in the current direction, rounded up to the next integer. * |(steps*(int) Math.round((Math.abs(Math.cos(this.getDirection())) * |+Math.abs((4*Math.sin(this.getDirection())))))) */ @Basic @Raw private int computeCostStep(int steps) { return Math.abs( (int) Math.round( (steps) * (Math.abs(Math.cos(this.getDirection())) + Math.abs((4.0 * Math.sin(this.getDirection())))))); }
/** * Returns the cost in actionpoints for a turn of a given angle. * * @param angle the angle over which the worm would like to turn in radians. * @return the cost in actionpoints for a turn of a given angle rounded up to the nearest integer. * |(int) Math.abs(Math.round(((60*angle)/(2*Math.PI)))) */ @Basic @Raw private int computeCostTurn(double angle) { return (int) Math.abs(Math.round(((60 * angle) / (2 * Math.PI)))); }
/** * Returns the cost in actionpoints to move in the current direction. * * @param prevXpos The x-position of the worm before he moved. * @param prevYpos The y-position of the worm before he moved. */ @Raw private int computeCost2(double prevXpos, double prevYpos) { return (int) (Math.round(Math.abs(this.getXpos() - prevXpos)) + Math.round(4 * Math.abs(this.getYpos() - prevYpos))); }