math - 8 谜题中的曼哈顿距离

标签 math prolog sliding-tile-puzzle

谁能解释一下如何计算这个例子中的 8 个拼图问题中的曼哈顿距离 http://ai.ia.agh.edu.pl/wiki/pl:prolog:pllib:sliding_puzzle

如何计算:

a(0,0). a(1,0). a(2,1). a(3,2). a(4,3). a(5,4). a(6,3). a(7,2). a(8,1). b(0,0). b(1,1). b(2,0). b(3,1). b(4,2). b(5,3). b(6,2). b(7,3). b(8,2). c(0,0). c(1,2). c(2,1). c(3,0). c(4,1). c(5,2). c(6,3). c(7,4). c(8,3). d(0,0). d(1,1). d(2,2). d(3,3). d(4,2). d(5,3). d(6,2). d(7,2). d(8,0). e(0,0). e(1,2). e(2,1). e(3,2). e(4,1). e(5,2). e(6,1). e(7,2). e(8,1). f(0,0). f(1,3). f(2,2). f(3,1). f(4,0). f(5,1). f(6,2). f(7,3). f(8,2). g(0,0). g(1,2). g(2,3). g(3,4). g(4,3). g(5,2). g(6,2). g(7,0). g(8,1). h(0,0). h(1,3). h(2,3). h(3,3). h(4,2). h(5,1). h(6,0). h(7,1). h(8,2).
i(0,0). i(1,4). i(2,3). i(3,2). i(4,1). i(5,0). i(6,1). i(7,2). i(8,3).

在这段代码中?

最佳答案

a,b,c,...,i 是固定单元格名称。该表是手工编码的,以加快达到目标所需的步骤数 - 例如,采用d(8,0)。,这只有意义,因为goal(1/2/3/8/0/4/7/6/5).,即当单元格 d 包含 8 时>, 需要 0 个步骤...

关于math - 8 谜题中的曼哈顿距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23438418/

相关文章:

algorithm - 解决8个难题的有效方法是什么?

java - 我试图解决 '15 puzzle' ,但我得到 'OutOfMemoryError'

c - 什么决定了将用于存储临时值的数据类型?

序言: Combining DCG grammars with other restrictions

prolog - 在 Prolog 中处理列表列表

list - 将两个列表相乘

c++ - 计算折扣适用价格(30%、20% 和 15% 的折扣)

java - 量化等级法

algorithm - 在图形轴上自动选择对数和线性刻度

algorithm - 如何为 SA 算法制定 8-Puzzle?