private int getNextDir(int[] from,int to,boolean closer,Game.DM measure)
	{
		int dir=-1;

		double min=Integer.MAX_VALUE;
		double max=-Integer.MAX_VALUE;
			
		for(int i=0;i<from.length;i++)
		{
			if(from[i]!=-1)
			{
				double dist=0;
					
				switch(measure)
				{
					case PATH: dist=getPathDistance(from[i],to); break;
					case EUCLID: dist=getEuclideanDistance(from[i],to); break;
					case MANHATTEN: dist=getManhattenDistance(from[i],to); break;
				}
					
				if(closer && dist<min)
				{
					min=dist;
					dir=i;	
				}
				
				if(!closer && dist>max)
				{
					max=dist;
					dir=i;
				}
			}
		}
		
		return dir;
	}