public class antorj {
    int id; //kar?ncan?n ad?
    int ssayi; //?ehir say?s?
    int[] gyol; //gidilen güzergah
    int asayi=0; //at??? ad?m say?s?
    double kmesafe; //toplam mesafe
    double omesafe; //mesafe ödülü
    double feramon,guncel;

    public antorj(int x,int y,double z) {
    id=x;
    ssayi=y;
    feramon=z;
    gyol=new int[ssayi];
    kmesafe=0;
    omesafe=400;
    }
 
    public void yuru(map w,double[][] x,int y,int z){
        double tolasilik;
        int isaretci;
        int a;
        int b;        
        int yolsayisi=z;
        int bsehir,isaret,devam,devam2;
        int usehir;
        double of;
        
        a=0;
        b=0;
        isaretci=0;
        tolasilik=0;
        asayi=y; //atilmis adim sayisi
        usehir=gyol[asayi-1];
        b=ssayi-asayi;
        double[][] imkanliyol=new double[ssayi-asayi][2];
        for(int i=0;i<yolsayisi;i++){
            if(a>=b){
                break;
            }
          
            isaretci=0;
            if(x[i][0]==usehir){
                for(int j=0;j<asayi;j++){
                    if (x[i][1]==gyol[j]){
                        isaretci=1;
                          }
                }
                if (isaretci==0){
                imkanliyol[a][1]=x[i][1];
                imkanliyol[a][0]=x[i][2];
                a++;
                }
            } else 
            {
            if(x[i][1]==usehir){
                for(int j=0;j<asayi;j++){
                    if (x[i][0]==gyol[j]){
                        isaretci=1;
                          }
                }
                 if(isaretci==0){
                imkanliyol[a][1]=x[i][0];
                imkanliyol[a][0]=x[i][2];
                 a++;
                 }
                
            }
            }
           
            
        }
        
        for(int i=0;i<ssayi-asayi;i++){
            tolasilik=imkanliyol[i][0]+tolasilik;
            //System.out.print(" imkanli yol : ");
            //System.out.print(gyol[0]);
            //System.out.print(" imkanli yollar : ");
            //System.out.print(imkanliyol[i][1]);
            //System.out.println(" ");
            //System.out.print(" imkanli yol : ");
            //System.out.println(imkanliyol[i][0]);
            
        }

           of=Math.random();
          
            for(int i=0;i<ssayi-asayi;){
             if(of>imkanliyol[i][0]){
                 i++;
                 if(i>=(ssayi-asayi)){
                     gyol[asayi]=(int) imkanliyol[i-1][1];
                 }
             }
             else{
                 //System.out.print(" imkanli yolda sorun var bence : ");
                 //System.out.println(imkanliyol[i][1]);

                 gyol[asayi]=(int) imkanliyol[i][1];
                 break;
             }
            }
           
           
        kmesafe=kmesafe+w.cities[gyol[asayi-1]][(gyol[asayi])+3];

      

    }
    
    public double feramonsal(){
       return feramon;
    }
    public void ferguncel(double[][] x){
        guncel=feramon/kmesafe;
        for(int i=1;i<ssayi;i++){
            x[gyol[i-1]][gyol[i]]=x[gyol[i-1]][gyol[i]]+guncel;
        }
        
        
    }
     public void buharlastir(double[][] x,double y){
        for(int i=0;i<ssayi;i++){
            for(int j=0;j<ssayi;j++){
              x[i][j]=x[i][j]*y;  
            }
                    }
    }
    
}
