From 5d1aa071ca6f385a8ec9bb2b5135d259f0f225eb Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 04 十二月 2025 10:59:45 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/common/model/NavigateNode.java | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/zy/common/model/NavigateNode.java b/src/main/java/com/zy/common/model/NavigateNode.java
new file mode 100644
index 0000000..a4b3af6
--- /dev/null
+++ b/src/main/java/com/zy/common/model/NavigateNode.java
@@ -0,0 +1,64 @@
+package com.zy.common.model;
+
+import lombok.Data;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * A*瀵昏矾绠楁硶Node鑺傜偣
+ */
+@Data
+public class NavigateNode implements Comparable<NavigateNode>, Cloneable, Serializable {
+
+ private int x;//鍧愭爣x
+ private int y;//鍧愭爣y
+ private int F;//缁煎悎鑺辫垂鐨勬鏁�
+ private int G;//宸茬粡鑺辫垂鐨勬鏁�
+ private int H;//灏嗚鑺辫垂鐨勬鏁�
+ private int value;
+ @ToString.Exclude
+ private NavigateNode Father;//鐖惰妭鐐�
+ private List<String> directionList;//琛岃蛋鏂瑰悜
+ private String nodeValue;//鑺傜偣鏁版嵁
+ private String nodeType;//鑺傜偣绫诲瀷
+
+ public NavigateNode(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ //閫氳繃缁撶偣鐨勫潗鏍囧拰鐩爣缁撶偣鐨勫潗鏍囧彲浠ヨ绠楀嚭F锛� G锛� H涓変釜灞炴��
+ //闇�瑕佷紶鍏ヨ繖涓妭鐐圭殑涓婁竴涓妭鐐瑰拰鏈�缁堢殑缁撶偣
+ public void init_node(NavigateNode father, NavigateNode end) {
+ this.Father = father;
+ if (this.Father != null) {
+ //璧拌繃鐨勬鏁扮瓑浜庣埗鑺傜偣璧拌繃鐨勬鏁板姞涓�
+ this.G = father.G + this.G;
+ } else { //鐖惰妭鐐逛负绌轰唬琛ㄥ畠鏄涓�涓粨鐐�
+ this.G = 0;
+ }
+
+ //浠ヤ笅璁$畻鏂规涓虹畻娉曞師濮嬫柟妗堬紝娌℃湁鍘绘嫄鐐规柟妗堛�傚凡琚玈olution璁$畻鏃惰嚜鍔ㄨ鐩栥��
+ //璁$畻閫氳繃鐜板湪鐨勭粨鐐圭殑浣嶇疆鍜屾渶缁堢粨鐐圭殑浣嶇疆璁$畻H鍊�(鏇煎搱椤挎硶锛氬潗鏍囧垎鍒彇宸�肩浉鍔�)
+ this.H = Math.abs(this.x - end.x) + Math.abs(this.y - end.y);
+ this.F = this.G + this.H;
+ }
+
+ @Override
+ public int compareTo(NavigateNode o) {
+ return Integer.compare(this.F, o.F);
+ }
+
+ @Override
+ public NavigateNode clone() {
+ try {
+ return (NavigateNode) super.clone();
+ } catch (CloneNotSupportedException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+}
--
Gitblit v1.9.1