# ReallyReallySimpleWallSmoothing

Robo Home | Changes | Preferences | AllPages

"Really, really simple wall smoothing" is my method of WallSmoothing that emerged completely by accident. I wanted to build a standard PerpendicularMovement bot. I built in a simple trig-based, sort-of-works wall avoidance algorithm - and suddenly, I discovered that my rate of hitting walls had cut by about four-fifths. Basically, since it tries to only move forward if there isn't a wall in the way, and you are curving around the enemy, if the enemy is in the center of the field you will move around him forever while asymptotically never quite hitting the walls. My rough version of this is:

```public void onScannedRobot(ScannedRobotEvent e) {
setTurnRight(Util.normalRelativeAngle(e.getBearing() + 90));

double x = getX();
double y = getY();

double angleUR = Math.atan(y / (getBattleFieldWidth() - x));
double angleLR = Math.atan((getBattleFieldHeight() - y) / (getBattleFieldWidth() - x));
double angleLL = Math.atan((getBattleFieldHeight() - y) / x);
double angleUL = Math.atan(y / x);

double axis;
axis = y;
} else {
axis = x;
}
double backDistanceToWall = (axis / Math.cos(Util.normalAbsoluteAngle(heading - 180))) - 36;