luxiaotao1123
2024-09-09 ea7e27ff897da58be02c14a6f18adbf387a56ee1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.zy.acs.manager.core.service.astart;
 
import lombok.Data;
 
import java.io.Serializable;
import java.util.Optional;
 
@Data
public class RetreatNavigateNode implements Comparable<RetreatNavigateNode>, Cloneable, Serializable {
 
    private static final long serialVersionUID = 1L;
 
    protected int x;  //坐标x
    protected int y;  //坐标y
    protected int z;  //坐标z(高度)
 
    protected int F;  //综合花费的步数
    protected int G;  //已经花费的步数
    protected int H;  //将要花费的步数
 
    protected RetreatNavigateNode parent;    //父节点
    protected Boolean turningPoint;   //是否为拐点
    protected String direction;   //行走方向
    protected Integer lastDistance;   // 距离上个节点距离
    protected Integer moveDistance;   // 总行走距离
 
    protected String codeData;
 
    protected int weight;
 
    public RetreatNavigateNode(int x, int y) {
        this.x = x;
        this.y = y;
    }
 
    public RetreatNavigateNode(int x, int y, String codeData) {
        this.x = x;
        this.y = y;
        this.codeData = codeData;
    }
 
    public void initNode(RetreatNavigateNode father, int weight) {
        this.parent = father;
        if (this.parent != null) {
            this.G = father.G + Optional.ofNullable(this.lastDistance).orElse(0);
            this.H = father.H + weight;
        } else {
            this.G = 0;
            this.H = weight;
        }
 
        this.F = this.G + this.H;
    }
 
    @Override
    public int compareTo(RetreatNavigateNode o) {
        // asc
        return Integer.compare(this.F, o.F);
    }
 
    @Override
    public RetreatNavigateNode clone() {
        try {
            return (RetreatNavigateNode) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
 
 
}