qq_3029507703 2023-04-18 09:07 采纳率: 100%
浏览 15
已结题

A*算法C++走斜线

img

img


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

vector<Note *> Astar::getSurroundNotes(const Note *currentNote) const
{
    vector<Note *> 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;
}
  • 写回答

2条回答 默认 最新

  • 赵4老师 2023-04-18 10:20
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 5月3日
  • 已采纳回答 4月25日
  • 创建了问题 4月18日