package astar0 import ( "slices" ) func Abs(n int32) int32 { y := n >> 31 return (n ^ y) - y } func Min(a, b int32) int32 { if a < b { return a } else { return b } } func InList(list []*Node, x, y int32) bool { for _, itemNode := range list { if itemNode.x == x && itemNode.y == y { return true } } return false } func GetRectanglePoint(list []*Node) (minX, minY, maxX, maxY int32) { var ( xList []int32 yList []int32 ) for _, node := range list { xList = append(xList, node.x) yList = append(yList, node.y) } minX = slices.Min(xList) minY = slices.Min(yList) maxX = slices.Max(xList) maxY = slices.Max(yList) return } func BuildPathing(node *Node) []*Node { if node == nil { return nil } var list []*Node for { list = append([]*Node{node}, list...) if node.parent == nil { break } node = node.parent } return list }