// neighbors returns the natural neigbors of current node, and adds to the
// queue forced neighbors.
//
// NOTE: there's a bit of redundant work here, because forced neighbor
// positions are already computed during the jump. It should not matter in
// practice, because in most situations JPS adds very few nodes to the open
// list, so this function is not called very often, and so is not a bottleneck.
neighbors returns the natural neigbors of current node, and adds to the
queue forced neighbors.

there's a bit of redundant work here, because forced neighbor
positions are already computed during the jump. It should not matter in
practice, because in most situations JPS adds very few nodes to the open
list, so this function is not called very often, and so is not a bottleneck.
// neighbors returns the natural neigbors of current node and adds to the // queue forced neighbors . // // NOTE : there ' s a bit of redundant work here because forced neighbor // positions are already computed during the jump . It should not matter in // practice because in most situations JPS adds very few nodes to the open // list so this function is not called very often and so is not a bottleneck .
func (pr *PathRange) neighbors(neighbors []gruid.Point, n *node, to gruid.Point) []gruid.Point {
	dir := dirnorm(n.Parent, n.P)
	switch {
	case dir.X == 0 || dir.Y == 0:
		neighbors = append(neighbors, n.P.Add(dir))
		if q := left(n.P, dir); !pr.pass(q) {
			if pr.diags || pr.pass(n.P.Add(dir)) {
				p := q.Add(dir)
				cost := diagCost(pr.diags)
				pr.addSuccessor(p, n.P, to, n.Cost+cost)
			}
		}
		if q := right(n.P, dir); !pr.pass(q) {
			if pr.diags || pr.pass(n.P.Add(dir)) {
				p := q.Add(dir)
				cost := diagCost(pr.diags)
				pr.addSuccessor(p, n.P, to, n.Cost+cost)
			}
		}
	default:
		diag := false
		q0 := n.P.Shift(dir.X, 0)
		q1 := n.P.Shift(0, dir.Y)
		if !pr.diags {
			diag = pr.pass(q0) || pr.pass(q1)
		}
		neighbors = append(neighbors, q0)
		neighbors = append(neighbors, q1)
		if pr.diags || diag {
			neighbors = append(neighbors, n.P.Add(dir))
		}
		if q := n.P.Shift(-dir.X, 0); !pr.pass(q) {
			if pr.diags || pr.pass(n.P.Add(gruid.Point{0, dir.Y})) {
				cost := diagCost(pr.diags)
				pr.addSuccessor(q.Shift(0, dir.Y), n.P, to, n.Cost+cost)
			}
		}
		if q := n.P.Shift(0, -dir.Y); !pr.pass(q) {
			if pr.diags || pr.pass(n.P.Add(gruid.Point{dir.X, 0})) {
				cost := diagCost(pr.diags)
				pr.addSuccessor(q.Shift(dir.X, 0), n.P, to, n.Cost+cost)
			}
		}
	}
	return neighbors
}
func ( pr * PathRange ) neighbors ( neighbors [ ] gruid . Point , n * node , to gruid . Point ) [ ] gruid . Point { dir := dirnorm ( n . Parent , n . P ) switch { case dir . X == 0 || dir . Y == 0 : neighbors = append ( neighbors , n . P . Add ( dir ) ) if q := left ( n . P , dir ) ; ! pr . pass ( q ) { if pr . diags || pr . pass ( n . P . Add ( dir ) ) { p := q . Add ( dir ) cost := diagCost ( pr . diags ) pr . addSuccessor ( p , n . P , to , n . Cost + cost ) } } if q := right ( n . P , dir ) ; ! pr . pass ( q ) { if pr . diags || pr . pass ( n . P . Add ( dir ) ) { p := q . Add ( dir ) cost := diagCost ( pr . diags ) pr . addSuccessor ( p , n . P , to , n . Cost + cost ) } } default : diag := false q0 := n . P . Shift ( dir . X , 0 ) q1 := n . P . Shift ( 0 , dir . Y ) if ! pr . diags { diag = pr . pass ( q0 ) || pr . pass ( q1 ) } neighbors = append ( neighbors , q0 ) neighbors = append ( neighbors , q1 ) if pr . diags || diag { neighbors = append ( neighbors , n . P . Add ( dir ) ) } if q := n . P . Shift ( - dir . X , 0 ) ; ! pr . pass ( q ) { if pr . diags || pr . pass ( n . P . Add ( gruid . Point { 0 , dir . Y } ) ) { cost := diagCost ( pr . diags ) pr . addSuccessor ( q . Shift ( 0 , dir . Y ) , n . P , to , n . Cost + cost ) } } if q := n . P . Shift ( 0 , - dir . Y ) ; ! pr . pass ( q ) { if pr . diags || pr . pass ( n . P . Add ( gruid . Point { dir . X , 0 } ) ) { cost := diagCost ( pr . diags ) pr . addSuccessor ( q . Shift ( dir . X , 0 ) , n . P , to , n . Cost + cost ) } } } return neighbors }
neighbors returns the natural neigbors of current node, and adds to the
queue forced neighbors.
neighbors returns the natural neigbors of current node and adds to the queue forced neighbors .