import java.util.*;

public class AI {
	//Native method declarations -JTO
	native int start(int argc, String[] args);
// Movement methods -JNE
	native void turnLeft(int flag);
	native void turnRight(int flag);
	native void turn(int deg);
	native void turnToDeg(int deg);		//OOOrder -JNE
	native void thrust(int flag);
	native void setTurnSpeed(double s);
// Shooting methods -JNE
	native void fireShot();
	native void fireMissile();
	native void fireTorpedo();
	native void fireHeat();
	native void dropMine();
	native void detachMine();
	native void detonateMines();
	native void fireLaser();
// Item usage methods -JNE
	native void tankDetach();
	native void cloak();
	native void ecm();
	native void transporter();
	native void tractorBeam();
	native void pressorBeam();
	native void phasing();
	native void emergencyShield();
	native void hyperjump();
	native void nextTank();
	native void prevTank();
	native void toggleAutopilot();
	native void emergencyThrust();
	native void deflector();
	native void selectItem();
	native void loseItem();
// Lock methods -JNE
	native void lockNext();
	native void lockPrev();
	native void lockClose();
	native void lockNextClose();
	native void loadLock1();
	native void loadLock2();
	native void loadLock3();
	native void loadLock4();
// Modifier methods -JNE
	native void toggleNuclear();
	native void toggleVelocity();
	native void toggleCluster();
	native void toggleLaser();
	native void toggleImplosion();
	native void loadModifiers1();
	native void loadModifiers2();
	native void loadModifiers3();
	native void loadModifiers4();
	native void clearModifiers();
// map features -JNE
	native void connector();
	native void dropBall();
	native void refuel();
// other options -JNE
	native void keyHome();
	native void selfDestruct();
	native void pause();
	native void swapSettings();
	native void talkKey();
	native void toggleCompass();
	native void repair();
	native void reprogram();
	native void talk(String talk_str);
// self properties -JNE
	native int selfX();
	native int selfY();
	native int selfRadarX();
	native int selfRadarY();
	native int selfVelX();
	native int selfVelY();
	native int selfSpeed();
	native double lockHeadingDeg();
	native double lockHeadingRad();
	native short selfLockDist();
	native int selfReload();
	native int selfID();
	native int selfAlive();
	native int selfTeam();
	native int selfLives();
	native double selfTrackingRad();
	native double selfTrackingDeg();
	native double selfHeadingDeg();
	native double selfHeadingRad();
	native String hudName();
	native String hudScore();
	native double hudTimeLeft();
	native double getTurnSpeed();
	native int selfShield();
	native String selfName();
	native double selfScore();
// Closest functions -JNE
	native int closestRadarX();
	native int closestRadarY();
	native int closestItemX();
	native int closestItemY();
	native int closestShipId();
// ID functions -JNE
	native double enemySpeedId(int id);
	native double enemyTrackingRadId(int id);
	native double enemyTrackingDegId(int id);
	native int enemyReloadId(int id);
	native int screenEnemyXId(int id);
	native int screenEnemyYId(int id);
		// (wrap function) -JNE
	native double enemyHeadingDegId(int id);
	native double enemyHeadingRadId(int id);
	native int enemyShieldId(int id);
	native int enemyLivesId(int id);
	native String enemyNameId(int id);
	native double enemyScoreId(int id);
	native int enemyTeamId(int id);
	native double enemyDistanceId(int id);
// idx functions -JNE
	native double enemyDistance(int idx);	// index is the position in the sorted ship buffer -JNE
	native double enemySpeed(int idx);
	native int enemyReload(int idx);
	native double enemyTrackingRad(int idx);
	native double enemyTrackingDeg(int idx);
	native int screenEnemyX(int idx);
	native int screenEnemyY(int idx);
	native double enemyHeadingDeg(int idx);
	native double enemyHeadingRad(int idx);
	native int enemyShield(int idx);
	native int enemyLives(int idx);
	native int enemyTeam(int idx);
	native String enemyName(int idx);
	native double enemyScore(int idx);
		// (turnToDeg(int deg) -JNE
	native double degToRad(int deg);
	native int radToDeg(double rad);
	native int angleDiff(int angle1, int angle2);
	native int angleAdd(int angle1, int angle2);
	native int wallFeeler(int dist, int angle, int flag_wf, int flag_wd);
	native int wallFeelerRad(int dist, double a, int flag_wf, int flag_wd);
	native int wallBetween(int x1, int y1, int x2, int y2, int flag_wf, int flag_wd);
	native int aimdir(int idx);
// Shot functions -JNE
	native int shotAlert(int id);
	native int shotX(int id);
	native int shotY(int id);
	native int shotDist(int id);
	native int shotVel(int id);
	native int shotVelDir(int id);

	//Default declaration for loop to be overridden -EGG
	public void AI_loop() {
	}

	//Load the library -JTO
	static {
		System.loadLibrary("AI");
	}

	public AI() {
		//pass
	}

	//Constructor
	public AI(String args[]) {
		//C-ify our arguments -EGG
		String[] das_args= new String[args.length+1];
		das_args[0] = "xpilot-ng-x11"; //A string is prepended to represent the argv[0]
		System.arraycopy(args, 0, das_args, 1, args.length);
		//Call native method -JTO
		start(das_args.length, das_args);
	}
	
	public static void main(String args[]) {
		AI xp = new AI(args);
	}
}

