private void efectuarCicle(){
//        Iterator it = Main.exploradors.iterator();
//        Agent ag;
//        while(it.hasNext()){
//            ag= (Agent) it.next();
//            int x= ag.getPosicioI();
//            int y= ag.getPosicioJ();
//            ag.avança();
//           
//        }
        Iterator it= Main.exploradors.iterator();
        if (Main.t.getTresorsRestants() != 0) {
            while(it.hasNext()){
                Agent a= (Agent) it.next();
                if (!a.isAcabat()) {
                    a.actualitzaBC();
                    a.pensa();
                    Casella desti = a.seguentSegur();
                    if (desti == null) {
                        a.setAcabat(true);
                    } else {
                        a.moure(desti);
                    }
                }
            }
        } else {
            while(it.hasNext()){
                Agent a= (Agent) it.next();
                Casella c = a.desferCami();
                if (c != null)
                    a.mourePoderos(c);
                else
                    a.setAcabat(true);
            }
        }
    }