A*算法C++走斜线

img

img


你好,这个走斜线怎么改呀

vector Astar::getSurroundNotes(const Note *currentNote) const
{
    vector surroundNotes;
    for (int x = currentNote->x - 1; x <= currentNote->x + 1; ++x)
        for (int y = currentNote->y - 1; y <= currentNote->y + 1; ++y)
            if (isReachable(currentNote, new Note(x, y)))
                surroundNotes.push_back(new Note(x, y));
    return surroundNotes;
}

修改isReachable函数(如果原来仅上下左右可达,改为四面八方均可达)