public void simulatePart(int from,int to){
 vector2d sep,ali,coh,lead,rand,pred, avoid, predH,toAim,forag;
 ArrayList<boid> tempBoids;
 Random randGen = new Random();     
for(int i=from;i<to;i++){ 
          if (boids.get(i).getType()==2){continue;}
          tempBoids=getNeighbourhoodOptmTopological(boids.get(i),mainBoids.mainWin.getNumNeight());
          
          sep= boids.get(i).separate(tempBoids).multi(cofSep);
          if(sep.getSLength()<cofSep*cofSep || cofSep==0){
          ali= boids.get(i).alignment(tempBoids).multi(cofAli);
          coh= boids.get(i).cohesion(tempBoids).multi(cofCoh);
          }else{ali=new vector2d(0,0);coh=new vector2d(0,0);}
          lead= boids.get(i).followLeader(tempBoids);
          toAim=boids.get(i).goToAim(globalAim).multi((cofAli+cofCoh)/1.5);
          rand=new vector2d(randGen.nextDouble()*2-1,randGen.nextDouble()*2-1);
          avoid=boids.get(i).better_avoid(pom,AvoidMode, AvoidRec);
          
          pred=boids.get(i).predator(tempBoids);
          forag=boids.get(i).foraging(food, katWidzenia);
          
          lead.multi(leadCof);
          rand.multi(randCof);
          pred.multi(cofPred);
          avoid.multi(cofAvoid);

           if(!critical_sit && !foraging_situation){ boids.get(i).setAcceleration(((sep.add(ali)).add(coh)).add(lead).add(rand).add(pred).add(avoid).add(toAim).add(forag).multi(skala));}
           else{
               if(foraging_situation && !critical_sit){
                   boids.get(i).setAcceleration(forag.add(sep).multi(skala));
                   foraging_situation=false;
               }
               else{
                    boids.get(i).setAcceleration(pred.multi(skala));
                    critical_sit=false; foraging_situation=false;
               }
           }
       }
}