| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package astar0
- import "fmt"
- const (
- statusClose int32 = -1
- statusNormal int32 = 0
- statusOpen int32 = 1
- )
- type Node struct {
- parent *Node
- x int32
- y int32
- f int32
- g int32
- h int32
- value int32
- status int32
- }
- func (p *Node) X() int32 {
- return p.x
- }
- func (p *Node) Y() int32 {
- return p.y
- }
- func (p *Node) Value() int32 {
- return p.value
- }
- func (p *Node) Status() int32 {
- return p.status
- }
- func (p *Node) String() string {
- return fmt.Sprintf("(%d,%d)", p.x, p.y)
- }
- func (p *Node) Clean() {
- p.parent = nil
- p.f = 0
- p.g = 0
- p.h = 0
- p.status = statusNormal
- }
- func (p *Node) IsClose() bool {
- return p.status == statusClose
- }
- func (p *Node) IsOpen() bool {
- return p.status == statusOpen
- }
- func newNode(x, y, value int32) *Node {
- return &Node{
- x: x,
- y: y,
- value: value,
- status: statusNormal,
- }
- }
|