private static void Move(IHIPathfinderValues values)
    {
        values.Tiles[values.X[values.BinaryHeap[1]]][values.Y[values.BinaryHeap[1]]] = 2;


        values.BinaryHeap[1] = values.BinaryHeap[values.Count];
        values.Count--;

        short location = 1;
        while (true)
        {
            short high = location;
            if (2*high + 1 <= values.Count)
            {
                if (values.F[values.BinaryHeap[high]] >= values.F[values.BinaryHeap[2*high]])
                    location = (short) (2*high);
                if (values.F[values.BinaryHeap[location]] >= values.F[values.BinaryHeap[2*high + 1]])
                    location = (short) (2*high + 1);
            }
            else if (2*high <= values.Count)
            {
                if (values.F[values.BinaryHeap[high]] >= values.F[values.BinaryHeap[2*high]])
                    location = (short) (2*high);
            }

            if (high == location)
                break;
            short temp = values.BinaryHeap[high];
            values.BinaryHeap[high] = values.BinaryHeap[location];
            values.BinaryHeap[location] = temp;
        }
    }