//package duckPOWER;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class Champion extends Api
{
	//private Map map = new Map();
	//private Goal goal = new Goal();
	private int collectDuckId; 
	
	
	
    /**
     * Fonction appelée au début de la partie.
     */
    public void partie_init()
    {
    	collectDuckId = troupes_joueur(Api.moi())[0].id;
    	//map.init();
    	
    	
    	//goal.search(map);
    }

    /**
     * Fonction appelée à chaque tour.
     */
    public void jouer_tour()
    {
        
    	/*if (!goal.has) { //objectif en vue ?
    		
    		goal.search(map); //recherche d'un objectif

    	}
    	
    	for (int i = 0; i < 5; i++) {
    		avancer(collectDuckId, goal.path[goal.progress]);
    		goal.progress++;
    		if (goal.progress >= goal.path.length) {
    			goal.has = false;
    			break;
    		}
    	}
    	*/
    	//accomplissement objectif:
    }

    /**
     * Fonction appelée à la fin de la partie.
     */
    public void partie_fin()
    {
        // TODO
    }
}
/*
class Map {

	public List<Position> papis = new ArrayList<>();
	
	public void init() {
		
		Position pos = new Position();
		for (int x = 0; x < Api.LARGEUR; x++) {
			pos.colonne = x;
			for (int y = 0; y < Api.HAUTEUR; y++) {
				pos.ligne=y;
				EtatCase et = Api.info_case(pos);
				if (et.contenu == TypeCase.PAPY) {
					papis.add(et.pos);
				}
			}
		}
		
		
		
		for (Position p : papis) {
			Api.debug_poser_pigeon(p, PigeonDebug.PIGEON_BLEU);
		}
		
	}
	
	
	
}

class Goal{
	
	public boolean has;
	public Direction[] path;
	public int progress = 0;
	
	public void search(Map map){

		Position currentPos = Api.troupes_joueur(Api.moi())[0].maman;

		java.util.Map<Position, BreadScore> breadScore = new HashMap<>();
		Position[] breads = Api.pains();
		
		for (Position pos : map.papis) {
			int dist = Api.trouver_chemin(currentPos, pos).length;
			dist/=5;
			
			if (dist > 0) {
				breadScore.put(pos, new BreadScore(Api.papy_tours_restants(pos), dist));
			}
			
		}
		
		for (Position pos : breads) {
			BreadScore sc = breadScore.get(pos);
			
			if (sc != null) {
				sc.nb=Api.info_case(pos).nb_pains;
			} else {
				int dist = Api.trouver_chemin(Api.troupes_joueur(Api.moi())[0].maman, pos).length;
				dist/=5;
				
				if (dist > 0) {
					breadScore.put(pos, new BreadScore(dist, dist, Api.info_case(pos).nb_pains));
				}
			}
		}
		
		int min = -1;
		Position pMin = null;
		for (Position p : breadScore.keySet()) {
			BreadScore sc = breadScore.get(p);
			
			int a1 = sc.time-sc.distance;//argument a1 <== temps a attendre a l"arrivee sur la case avant pain
			int a2 = sc.distance;//argument a2 <== distance pour atteindre 
			
			if (a1 > 0) {
				a2+=a1;
			}
			
			if (pMin == null && min > a2) {
				min = a2;
				pMin = p;
			}
			
		}
		
		path = Api.trouver_chemin(currentPos, pMin);
		
		
		has = true;
	}

	class BreadScore {
		int time; //temps avant apparition
		int distance;
		int nb = 0;
		
		public BreadScore(int time, int dist) {
			this(time, dist, 0);
		}
		
		public BreadScore(int time, int dist, int nb) {
			this.time = time;
			this.distance = dist;
			this.nb = nb;
		}
	}
}*/


