4 回答
TA贡献1828条经验 获得超3个赞
if(igap > 0): genn(igap, igap-1)if(igap > 1): genn(igap, igap-2)if igap < len(formation) - 1: genn(igap, igap+1)if igap < len(formation) - 2: genn(igap, igap+2)
if(igap > 0 and formation[igap-1] == fCamel): genn(igap, igap-1)if(igap > 1 and formation[igap-2] == fCamel): genn(igap, igap-2)if (igap < len(formation) - 1) and formation[igap+1] == bCamel: genn(igap, igap+1)if (igap < len(formation) - 2) and formation[igap + 2] == bCamel: genn(igap, igap+2)
额外提速
openlist.put((current.g + heuristicf(neighbor), node(neighbor, current.g + 1, current)))
openlist.put((heuristicf(neighbor), node(neighbor, current.g + 1, current)))
TA贡献2041条经验 获得超4个赞
class node: def __init__(self, a, g, p): self.arrangement = a self.g = g self.parent = p
node = collections.namedtuple('node', 'arrangement, g, parent')
[fCamel, fCamel, gap, bCamel, bCamel]
fCamel
添加回答
举报