Here is the code to the robot we worked on. Fr Robo Komodo shall be missed =****(

package sf ;

import java.awt.Color ;

import robocode.* ;

public class FatherRoboKomodo extends Robot

{

boolean clockwise = false ;

long time = 0 ;

public void run ()

{

findNearestWall () ;

walls () ;

}

public void findNearestWall ()

{

double battleFieldWidth = getBattleFieldWidth () ;

double battleFieldHeight = getBattleFieldHeight () ;

double angleFacing = getHeading () ;

double xPos = getX () ;

double yPos = getY () ;

double distanceToLeftWall = xPos ;

double distanceToBottomWall = yPos ;

double distanceToRightWall = (battleFieldWidth – xPos) ;

double distanceToTopWall = (battleFieldHeight – yPos) ;

double [] distanceToWalls = { distanceToLeftWall , distanceToBottomWall , distanceToRightWall , distanceToTopWall } ;

if ( smallest ( distanceToWalls ) == distanceToLeftWall ) {

if ( angleFacing <= 90 ) {

turnLeft ( 90 + angleFacing ) ;

} else if ( angleFacing > 270 ) {

turnLeft ( angleFacing – 270 ) ;

} else if ( angleFacing < 270 && angleFacing > 90 ) {

turnRight ( 270 – angleFacing ) ;

}

} else if ( smallest ( distanceToWalls ) == distanceToBottomWall ) {

if ( angleFacing > 180 ) {

turnLeft ( angleFacing – 180 ) ;

} else if ( angleFacing < 180 ) {

turnRight ( 180 – angleFacing ) ;

}

} else if ( smallest ( distanceToWalls ) == distanceToRightWall ) {

if ( angleFacing < 90 ) {

turnRight ( 90 – angleFacing ) ;

} else if ( angleFacing >= 270 ) {

turnRight ( 360 – angleFacing + 90 ) ;

} else if ( angleFacing > 90 && angleFacing < 270 ) {

turnLeft ( angleFacing – 90 ) ;

}

} else if ( smallest ( distanceToWalls ) == distanceToTopWall ) {

if ( angleFacing < 180 ) {

turnLeft ( angleFacing ) ;

} else if ( angleFacing > 180 ) {

turnRight ( 360 – angleFacing ) ;

}

}

}

public void findFurthestWall ()

{

double sentryAllowance = ( getHeight () * 1.5 ) ;

double battleFieldWidth = getBattleFieldWidth () ;

double battleFieldHeight = getBattleFieldHeight () ;

double angleFacing = getHeading () ;

double xPos = getX () ;

double yPos = getY () ;

double distanceToLeftWall = xPos ;

double distanceToBottomWall = yPos ;

double distanceToRightWall = (battleFieldWidth – xPos) ;

double distanceToTopWall = (battleFieldHeight – yPos) ;

double [] distanceToWalls = { distanceToLeftWall , distanceToBottomWall , distanceToRightWall , distanceToTopWall } ;

if ( smallest ( distanceToWalls ) == distanceToLeftWall ) {

if ( angleFacing <= 90 ) {

turnLeft ( 90 + angleFacing ) ;

} else if ( angleFacing > 270 ) {

turnLeft ( angleFacing – 270 ) ;

} else if ( angleFacing < 270 && angleFacing > 90 ) {

turnRight ( 270 – angleFacing ) ;

}

back (battleFieldWidth – xPos – sentryAllowance) ;

} else if ( smallest ( distanceToWalls ) == distanceToBottomWall ) {

if ( angleFacing > 180 ) {

turnLeft ( angleFacing – 180 ) ;

} else if ( angleFacing < 180 ) {

turnRight ( 180 – angleFacing ) ;

}

back (battleFieldHeight – yPos – sentryAllowance) ;

} else if ( smallest ( distanceToWalls ) == distanceToRightWall ) {

if ( angleFacing < 90 ) {

turnRight ( 90 – angleFacing ) ;

} else if ( angleFacing >= 270 ) {

turnRight ( 360 – angleFacing + 90 ) ;

} else if ( angleFacing > 90 && angleFacing < 270 ) {

turnLeft ( angleFacing – 90 ) ;

}

back (xPos – sentryAllowance) ;

} else if ( smallest ( distanceToWalls ) == distanceToTopWall ) {

if ( angleFacing < 180 ) {

turnLeft ( angleFacing ) ;

} else if ( angleFacing > 180 ) {

turnRight ( 360 – angleFacing ) ;

}

back (yPos – sentryAllowance) ;

}

}

public void walls ()

{

double sentryAllowance = ( getHeight () * 1.5 ) ;

double battleFieldWidth = getBattleFieldWidth () ;

double battleFieldHeight = getBattleFieldHeight () ;

turnGunLeft (90) ;

while ( true ) {

double xPos = getX () ;

double yPos = getY () ;

if ( clockwise == true ) {

if ( getHeading () == 180 ) {

back ( battleFieldHeight – yPos – sentryAllowance ) ;

turnRight ( 90 ) ;

} else if ( getHeading () == 0 ) {

back ( yPos – sentryAllowance ) ;

turnRight ( 90 ) ;

} else if ( getHeading () == 270 ) {

back ( battleFieldWidth – xPos – sentryAllowance ) ;

turnRight ( 90 ) ;

} else if ( getHeading () == 90 ) {

back ( xPos – sentryAllowance ) ;

turnRight ( 90 ) ;

}

} else if ( clockwise == false ) {

if ( getHeading () == 0 ) {

ahead ( battleFieldHeight – yPos – sentryAllowance ) ;

turnLeft ( 90 ) ;

} else if ( getHeading () == 180 ) {

ahead ( yPos – sentryAllowance ) ;

turnLeft ( 90 ) ;

} else if ( getHeading () == 90 ) {

ahead ( battleFieldWidth – xPos – sentryAllowance ) ;

turnLeft ( 90 ) ;

} else if ( getHeading () == 270 ) {

ahead ( xPos – sentryAllowance ) ;

turnLeft ( 90 ) ;

}

}

changeColour () ;

}

} //walls

public void onHitRobot ( HitRobotEvent e )

{

stop() ;

findFurthestWall() ;

if ( clockwise == true ) {

clockwise = false ;

} else {

clockwise = true ;

}

}//hit robot

public void changeColour ()

{

setAllColors ( new Color ( ( (int) ( Math.random () * 256 ) ) , ( ( int ) ( Math.random () * 256 ) ) , ( ( int ) ( Math.random () * 256 ) ) ) ) ;

}//colour

public void onScannedRobot ( ScannedRobotEvent e )

{

double biggestFireDistance = Math.sqrt(getBattleFieldWidth()*getBattleFieldWidth() + getBattleFieldHeight()*getBattleFieldHeight()); //max firedistance = diagonal

double bulletPercentage = ( 100 – ( ( ( e.getDistance () ) / biggestFireDistance ) * 100 ) ) ;

fire ( Rules.MAX_BULLET_POWER * bulletPercentage / 100 ) ;

}//scan

public void onHitByBullet(HitByBulletEvent e)

{

if (e.getTime() > time + 30){

time = e.getTime() ;

if(getHeading()% 90 == 0) {//stops this from happening if turning

if(clockwise == false){

if (e.getBearing() >= 270 || e.getBearing() <= 90) {//if you are heading towards the direction of opponent who fired the bullet

stop () ;

findFurthestWall () ;

turnRight(90) ;

clockwise = true ;

}

}else{

if(e.getBearing() >= 90 && e.getBearing() <= 270) {//same as above, just in opposite direction

stop() ;

findFurthestWall () ;

turnRight(90) ;

clockwise = false ;

}

}

}

}

}

//————————————————–Some Calculation Methods————————————————–\\

public double smallest ( double [] numbers )

{

double smallest = numbers [0] ;

for ( int i = 0 ; i < numbers.length ; i++ ) {

if ( numbers [i] < smallest ) {

smallest = numbers [i] ;

}

}

return smallest ;

}

}