Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想做一个益智配对游戏,但算法有问题。
这是我的游戏 - 一个棋盘,例如 4x4 - 16 个包含 8 对字母的单元。字母被打乱了。
要求是:
示例图片:
我应该使用什么最有效的算法来匹配一对字母?
我不想写代码,也不想讲太多细节,所以这里只是一个算法的粗略草图。遍历所有字母:
迭代时您对最短路径感兴趣,因此您必须始终迭代直到结束,或者如果您找到了可能的最短路径(相邻对)。