import java.util.ArrayList;

public class Prologin extends Interface {

	public static Position lastPortal = null;

	public void partie_init() {
		System.out.print("Init");
	}

	static int maxScore = Integer.MIN_VALUE;
	static ArrayList<Action> bestMove = null;

	public void jouer_tour() {

		// test

	
		Position p = Interface.position_agent(Interface.moi());

		p.x++;

		System.out.println(Interface.deplacer(p));
		 

		// new
//		find(Interface.NB_POINTS_ACTION, Interface.NB_POINTS_DEPLACEMENT);
//		for (Action action : bestMove) {
//			action.makeAction();
//		}
//
//		int moi = Interface.moi();
//		Position pos = Interface.position_agent(moi);
//		Position[] pInRange = Util.getPortalInRange(moi, Interface.points_deplacement());
//		if (pInRange.length != 0) {
//			Interface.deplacer(pInRange[0]);
//			if (Interface.portail_joueur(pInRange[0]) == -1) { // neutre
//				Interface.capturer();
//				if (lastPortal != null)
//					Interface.lier(lastPortal);
//			} else if (Interface.portail_joueur(pInRange[0]) == Interface.adversaire()) { // adv
//				Interface.neutraliser();
//				Interface.capturer();
//				if (lastPortal != null)
//					Interface.lier(lastPortal);
//			} else { // me
//
//			}
//			lastPortal = pInRange[0];
//		} else {
//			Position n = Util.getNearestPortal(moi);
//			int x = ((n.x - pos.x) / Interface.distance(pos, n)) * Interface.points_deplacement();
//			int y = ((n.y - pos.y) / Interface.distance(pos, n)) * Interface.points_deplacement();
//			n.x = x;
//			n.y = y;
//			Interface.deplacer(n);
//
//		}
	}

	public void partie_fin() {
	}

	public void find(int action, int mouvement) {
		Position[] pInRange = Util.getPortalInRangeSort(Interface.moi(), mouvement);
		if(pInRange.length != 0) {
			
		} else {
			Position n = Util.getNearestPortal(Interface.moi());
			Position pos = Interface.position_agent(Interface.moi());
			int x = ((n.x - pos.x) / Interface.distance(pos, n)) * Interface.points_deplacement();
			int y = ((n.y - pos.y) / Interface.distance(pos, n)) * Interface.points_deplacement();
			n.x = x;
			n.y = y;
			Interface.deplacer(n);
		}
	}

}
