{"id":17004,"date":"2024-10-17T15:22:05","date_gmt":"2024-10-17T07:22:05","guid":{"rendered":"http:\/\/192.168.10.115\/?p=17004"},"modified":"2024-10-17T15:22:05","modified_gmt":"2024-10-17T07:22:05","slug":"2024-10-17-%e8%b7%af%e5%be%84%e8%a7%84%e5%88%92-jump-point-search%e7%ae%97%e6%b3%95","status":"publish","type":"post","link":"http:\/\/222.128.65.89:18086\/index.php\/2024\/10\/17\/17004\/","title":{"rendered":"2024-10-17 \u8def\u5f84\u89c4\u5212\u2014\u2014Jump Point Search\u7b97\u6cd5"},"content":{"rendered":"\n<p>\u8def\u5f84\u89c4\u5212\u2014\u2014Jump Point Search\u7b97\u6cd5<\/p>\n\n\n\n<p>\u7b97\u6cd5\u539f\u7406<\/p>\n\n\n\n<p>\u8df3\u70b9\u641c\u7d22\u7b97\u6cd5(Jump Point Search)\uff0c\u7b80\u79f0JPS\uff0c\u662f\u7531\u6fb3\u5927\u5229\u4e9a\u4e24\u4f4d\u6559\u6388\u4e8e2011\u5e74\u63d0\u51fa\u7684\u57fa\u4e8eGrid\u683c\u5b50\u7684\u5bfb\u8def\u7b97\u6cd5\u3002JPS\u7b97\u6cd5\u5728\u4fdd\u7559A Star\u7b97\u6cd5\u7684\u6846\u67b6\u7684\u540c\u65f6\uff0c\u8fdb\u4e00\u6b65\u4f18\u5316\u4e86A Star\u7b97\u6cd5\u5bfb\u627e\u540e\u7ee7\u8282\u70b9\u7684\u64cd\u4f5c\u3002<br>A Star\u7b97\u6cd5\u53ef\u89c1\uff1aA Star<\/p>\n\n\n\n<p>JPS\u4e0eA Star\u7b97\u6cd5\u7684\u4e3b\u8981\u533a\u522b\u5728\u540e\u7ee7\u8282\u70b9\u7684\u62d3\u5c55\u7b56\u7565\u4e0a\uff0c\u4e0d\u540c\u4e8eA Star\u7b97\u6cd5\u4e2d\u76f4\u63a5\u83b7\u53d6\u5f53\u524d\u8282\u70b9\u6240\u6709\u975e\u5df2\u8bbf\u95ee\u8fc7\u7684\u53ef\u8fbe\u90bb\u5c45\u8282\u70b9\u6765\u8fdb\u884c\u62d3\u5c55\u7684\u7b56\u7565\uff0cJPS\u6839\u636e\u5f53\u524d\u8282\u70b9\u7684\u65b9\u5411\uff0c\u5e76\u57fa\u4e8e\u641c\u7d22\u8df3\u70b9\u7684\u7b56\u7565\u6765\u62d3\u5c55\u540e\u7ee7\u8282\u70b9\uff0c\u9075\u5faa\u201c\u4e24\u4e2a\u5b9a\u4e49\u3001\u4e09\u4e2a\u89c4\u5219\u201d\u3002<\/p>\n\n\n\n<p>\u5b9a\u4e49\u4e00\uff0c\u5f3a\u8feb\u90bb\u5c45(forced neighbor)\uff1a<br>\u5982\u679c\u8282\u70b9n\u662fx\u7684\u90bb\u5c45\uff0c\u5e76\u4e14\u8282\u70b9n\u7684\u90bb\u5c45\u6709\u969c\u788d\u7269\uff0c\u5e76\u4e14\u4eceparent(x)\u7ecf\u8fc7x\u518d\u5230n\u7684\u8def\u5f84\u957f\u5ea6\u6bd4\u5176\u4ed6\u4efb\u4f55\u4eceparent(x)\u4e0d\u7ecf\u8fc7x\u5230n\u7684\u8def\u5f84\u77ed\uff0c\u5176\u4e2dparent(x)\u4e3a\u8def\u5f84\u4e2dx\u7684\u524d\u4e00\u4e2a\u70b9\uff0c\u5219n\u4e3ax\u7684\u5f3a\u8feb\u90bb\u5c45\uff0cx\u4e3an\u7684\u8df3\u70b9\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"687\" height=\"405\" src=\"http:\/\/192.168.10.115\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-164.png\" alt=\"\" class=\"wp-image-17005\" srcset=\"http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-164.png 687w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-164-300x177.png 300w\" sizes=\"(max-width: 687px) 100vw, 687px\" \/><\/figure>\n\n\n\n<p>\u4e3e\u4f8b\u6765\u5177\u4f53\u8bf4\uff0c\u5982\u4e0a\u56fe<br>\u5148\u770b\u76f4\u7ebf\u65b9\u5411(straight)\uff0cx\u7684\u7236\u8282\u70b9\u662f4\uff0c\u5982\u679c\u4ece4\u7ecf\u8fc7x\u5230\u8fbe\u8282\u70b9node\u4e0e\u4ece4\u4e0d\u7ecf\u8fc7\u5230\u8fbe\u8282\u70b9node\u76f8\u6bd4\uff0c\u524d\u8005\u8def\u5f84\u8f83\u957f\u5219\u6ca1\u5fc5\u8981\u52a0\u5165\u5230x\u7684\u90bb\u5c45\u8282\u70b9(\u5982\u8282\u70b91\u30012\u30013\u30016\u30017\u30018)\uff0c\u5176\u4e2d\u8282\u70b93\u4e0e8\u4e24\u8005\u8def\u5f84\u662f\u76f8\u7b49\u7684\uff0c\u8fd9\u65f6\u8def\u5f84\u5177\u6709\u5bf9\u79f0\u6027\uff0c\u800cJPS\u7684\u6838\u5fc3\u4fbf\u662f\u6253\u7834\u8fd9\u79cd\u5bf9\u79f0\uff0c\u6240\u4ee5\u8282\u70b93\u548c8\u4e5f\u662f\u4e0d\u9700\u8981\u52a0\u5165\u7684\uff0c\u8fd9\u4e9b\u8282\u70b9\u79f0\u4e3ainferior neighbors\u52a3\u6027\u8282\u70b9\uff1b\u524d\u8005\u8def\u5f84\u8f83\u77ed\u5219\u9700\u8981\u5c06\u8282\u70b9node\u52a0\u5165\u5230x\u7684\u90bb\u5c45\u8282\u70b9(\u5982\u8282\u70b95)\uff0c\u8fd9\u79cd\u8282\u70b9\u79f0\u4e3anatural neighbors\u81ea\u7136\u8282\u70b9\uff1b<br>\u518d\u6765\u770b\u5bf9\u89d2\u7ebf\u65b9\u5411(diagonal)\uff0cx\u7684\u7236\u8282\u70b9\u662f6\uff0c\u540c\u7406\uff0c\u52a3\u6027\u8282\u70b9\u67091\u30012\u30017\u30018\uff0c\u81ea\u7136\u8282\u70b9\u67092\u30013\u30015\uff1b<\/p>\n\n\n\n<p>\u5982\u679c\u6709\u969c\u788d\u7269\uff0c\u5982\u4e0b\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"440\" src=\"http:\/\/192.168.10.115\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-165.png\" alt=\"\" class=\"wp-image-17006\" srcset=\"http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-165.png 675w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-165-300x196.png 300w\" sizes=\"(max-width: 675px) 100vw, 675px\" \/><\/figure>\n\n\n\n<p>\u5f53\u539f\u5148\u7684\u8282\u70b92\u5904\u6709\u969c\u788d\u7269\u65f6\uff0c\u4ece\u7236\u8282\u70b94\u7ecf\u8fc7x\u5230\u8fbe\u8282\u70b93\u6bd4\u4e0d\u7ecf\u8fc7x\u5230\u8fbe\u8282\u70b93\u8def\u5f84\u66f4\u77ed\uff0c\u8fd9\u65f6\u8282\u70b93\u4fbf\u4e0d\u662finferior neighbor\u4e86\uff0c\u9700\u8981\u4f5c\u4e3ax\u7684\u6709\u6548\u90bb\u5c45\u8282\u70b9\u8fdb\u4e00\u6b65\u8003\u8651\uff0c\u8fd9\u79cd\u8282\u70b9\u5c31\u662fforced neighbor\u5f3a\u8feb\u90bb\u5c45\u4e86\u3002\u540c\u6837\uff0c\u5bf9\u89d2\u7ebf\u65b9\u5411\u79fb\u52a8\u65f6\uff0c\u539f\u5148\u7684\u8282\u70b94\u5904\u6709\u969c\u788d\u7269\u65f6\uff0c\u4ece\u7236\u8282\u70b96\u7ecf\u8fc7x\u5230\u8fbe\u8282\u70b91\u6bd4\u4e0d\u7ecf\u8fc7\u8282\u70b9x\u5230\u8fbe\u8282\u70b91\u8def\u5f84\u66f4\u77ed\uff0c\u8fd9\u65f6\u8282\u70b91\u4fbf\u662fforced neighbor\u52a0\u5165\u5230openlist\u4e86\u3002<\/p>\n\n\n\n<p><strong>\u5b9a\u4e49\u4e8c\uff0c\u8df3\u70b9(Jump Point)\uff1a<\/strong><br>1.\u5982\u679c\u70b9y\u662f\u8d77\u70b9\u6216\u8005\u76ee\u6807\u70b9\uff0c\u5219y\u662f\u8df3\u70b9\uff1b<br>2.\u5982\u679cy\u6709\u5f3a\u8feb\u90bb\u5c45\u5219y\u662f\u8df3\u70b9\uff1b<br>3.\u5982\u679cparent(y)\u5230y\u662f\u5bf9\u89d2\u79fb\u52a8\uff0c\u5e76\u4e14y\u7ecf\u8fc7\u6c34\u5e73\u6216\u5782\u76f4\u65b9\u5411\u79fb\u52a8\u53ef\u4ee5\u5230\u8fbe\u8df3\u70b9\uff0c\u5219y\u662f\u8df3\u70b9\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"336\" src=\"http:\/\/192.168.10.115\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-1024x336.png\" alt=\"\" class=\"wp-image-17007\" srcset=\"http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-1024x336.png 1024w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-300x98.png 300w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-768x252.png 768w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-1536x503.png 1536w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-2048x671.png 2048w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-166-1800x590.png 1800w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u5148\u770bJumping Straight\uff0c\u4ecep(x)\u5230x\uff0c\u5411\u5de6\u4e00\u76f4\u63a8\u8fdb\u76f4\u5230y\uff0c\u8282\u70b9y\u6709\u4e00\u4e2aforced neigbor\u8282\u70b9z\uff0c\u90a3\u4e48\u8282\u70b9y\u4fbf\u4f5c\u4e3a\u8df3\u70b9\u52a0\u5165\u5230openlist\uff0c\u6b64\u5904\u5bf9\u5e94\u4e8e\u5b9a\u4e492\u3002<br>\u518d\u770bJumping Diagonally\uff0c\u4ecep(x)\u6cbf\u7740\u5bf9\u89d2\u65b9\u5411\u5230x\uff0c\u7136\u540e\u8282\u70b9x\u6cbf\u7740\u6c34\u5e73\u65b9\u5411\u548c\u5782\u76f4\u65b9\u5411\u641c\u7d22\uff0c\u5747\u6ca1\u6709\u53d1\u73b0\u611f\u5174\u8da3\u7684\u8282\u70b9\uff0c\u4e8e\u662f\u7ee7\u7eed\u6cbf\u7740\u5bf9\u89d2\u65b9\u5411\u63a8\u8fdb\uff0c\u4e00\u76f4\u5230\u8282\u70b9y\uff0c\u8282\u70b9y\u6cbf\u7740\u6c34\u5e73\u65b9\u5411\u641c\u7d22\u65f6\u53d1\u73b0\u4e86\u611f\u5174\u8da3\u8282\u70b9z\uff0c\u8282\u70b9z\u6709forced neighbor\u8282\u70b9\uff0c\u90a3\u4e48\u8282\u70b9y\u4fbf\u4f5c\u4e3a\u8df3\u70b9\u6210\u4e3a\u4e86\u8282\u70b9x\u7684\u540e\u7ee7\u8282\u70b9\uff0c\u6b64\u5904\u5bf9\u5e94\u4e8e\u5b9a\u4e493\uff0c\u88ab\u52a0\u5165\u5230openlist\u4e2d\uff0c\u8282\u70b9z\u88ab\u6807\u8bb0\u4e3a\u7279\u6b8a\u70b9\uff0c\u4e4b\u540e\u8fd4\u56de\u5230y\uff0c\u5e76\u6cbf\u7740\u5782\u76f4\u65b9\u5411\u641c\u7d22\uff0c\u5782\u76f4\u65b9\u5411\u4e0a\u65e0\u7279\u6b8a\u70b9\uff0c\u90a3\u4e48\u8282\u70b9x\u7684\u8fd9\u4e2a\u65b9\u5411\u4e0a\u7684\u5de5\u4f5c\u4fbf\u7ed3\u675f\u4e86\uff0c\u4e4b\u540e\u6cbf\u7740\u53e6\u4e00\u4e2a\u5bf9\u89d2\u65b9\u5411\u641c\u7d22\uff0c\u6709forced neighbor\u8282\u70b9w\uff0c\u90a3\u4e48\u8282\u70b9w\u4e5f\u4f5c\u4e3a\u8df3\u70b9\u88ab\u52a0\u5165\u5230openlist\u4e2d\uff0c\u6b64\u5904\u5bf9\u5e94\u4e8e\u5b9a\u4e492\u3002<\/p>\n\n\n\n<p><strong>\u89c4\u5219\u4e00\uff1a<\/strong>JPS\u641c\u7d22\u8df3\u70b9\u7684\u8fc7\u7a0b\u4e2d\uff0c\u5982\u679c\u76f4\u7ebf\u65b9\u5411(\u4e3a\u4e86\u548c\u5bf9\u89d2\u7ebf\u533a\u5206\uff0c\u76f4\u7ebf\u65b9\u5411\u4ee3\u8868\u6c34\u5e73\u65b9\u5411\u548c\u5782\u76f4\u65b9\u5411\uff0c\u4e14\u4e0d\u5305\u62ec\u5bf9\u89d2\u7ebf\u7b49\u659c\u7ebf\u65b9\u5411)\u548c\u5bf9\u89d2\u7ebf\u65b9\u5411\u90fd\u53ef\u4ee5\u79fb\u52a8\uff0c\u5219\u9996\u5148\u5728\u76f4\u7ebf\u65b9\u5411\u641c\u7d22\u8df3\u70b9\uff0c\u518d\u5728\u5bf9\u89d2\u7ebf\u65b9\u5411\u641c\u7d22\u8df3\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u89c4\u5219\u4e8c\uff1a<\/strong>1.\u5982\u679c\u4eceparent(x)\u5230x\u662f\u76f4\u7ebf\u79fb\u52a8\uff0cn\u662fx\u7684\u90bb\u5c45\uff0c\u82e5\u6709\u4eceparent(x)\u5230n\u7684\u8def\u5f84\u4e0d\u7ecf\u8fc7x\u4e14\u8def\u5f84\u957f\u5ea6\u5c0f\u4e8e\u6216\u7b49\u4e8e\u4eceparent(x)\u7ecf\u8fc7x\u5230n\u7684\u8def\u5f84\uff0c\u5219\u8d70\u5230x\u540e\u4e0b\u4e00\u4e2a\u70b9\u4e0d\u4f1a\u8d70\u5230n\uff1b<br>2.\u5982\u679c\u4eceparent(x)\u5230x\u662f\u5bf9\u89d2\u7ebf\u79fb\u52a8\uff0cn\u662fx\u7684\u90bb\u5c45\uff0c\u82e5\u6709\u4eceparent(x)\u5230n\u7684\u8def\u5f84\u4e0d\u7ecf\u8fc7x\u4e14\u8def\u5f84\u957f\u5ea6\u5c0f\u4e8e\u4eceparent(x)\u7ecf\u8fc7x\u5230n\u7684\u8def\u5f84\uff0c\u5219\u8d70\u5230x\u540e\u4e0b\u4e00\u4e2a\u70b9\u4e0d\u4f1a\u8d70\u5230n\u3002<\/p>\n\n\n\n<p><strong>\u89c4\u5219\u4e09\uff1a<\/strong>\u53ea\u6709\u8df3\u70b9\u624d\u4f1a\u52a0\u5165openlist\uff0c\u56e0\u4e3a\u8df3\u70b9\u4f1a\u6539\u53d8\u884c\u8d70\u65b9\u5411\uff0c\u800c\u975e\u8df3\u70b9\u4e0d\u4f1a\u6539\u53d8\u884c\u8d70\u65b9\u5411\uff0c\u6700\u540e\u5bfb\u627e\u51fa\u6765\u7684\u8def\u5f84\u70b9\u4e5f\u90fd\u662f\u8df3\u70b9\u3002<\/p>\n\n\n\n<p><strong>\u7b97\u6cd5\u6d41\u7a0b:<\/strong><\/p>\n\n\n\n<p>\u9996\u5148\u68c0\u67e5\u5f53\u524d\u8282\u70b9\u662f\u5426\u6709\u5f3a\u8feb\u90bb\u5c45\uff0c\u5982\u679c\u6709\uff0c\u90a3\u4e48\u6b64\u8282\u70b9\u4fbf\u53ef\u4ee5\u4f5c\u4e3a\u8df3\u70b9\u52a0\u5165\u5230openlist\u4e2d\uff0c\u5982\u679c\u6ca1\u6709\uff0c\u90a3\u4e48\u9075\u5faa\u4e09\u4e2a\u89c4\u5219\u6cbf\u7740\u6c34\u5e73\u65b9\u5411\u3001\u5782\u76f4\u65b9\u5411\u548c\u5bf9\u89d2\u65b9\u5411\u5bfb\u627e\u8df3\u70b9\u3002<\/p>\n\n\n\n<p>\u7b97\u6cd5\u5b9e\u73b0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"\"\"\n    Filename: jps.py\n    Description: Plan path using Jump-Point-Search Algorithm\n    Author: Benxiaogu:https:\/\/github.com\/Benxiaogu\n    Date: 2024-08-18\n\"\"\"\nimport heapq\nimport math\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.animation as animation\n\n\nclass JPS:\n    def __init__(self,grid,start,goal,board_size):\n        self.grid = grid\n        self.start = self.Node(start,0,0)\n        self.goal = self.Node(goal,0,0)\n        self.board_size = board_size\n        self.path = &#91;]\n\n    class Node:\n        def __init__(self, position, g, h, parent=None):\n            self.position = position    # position of node\n            self.g = g                  # distance from node to start\n            self.h = h                  # heuristic value from node to goal\n            self.parent = parent        # parent node\n\n        def __eq__(self, other) -> bool:\n            return self.position == other.position\n        \n        def __lt__(self, other):\n            # Prioritise nodes based on heuristic value\n            return self.g+self.h &lt; other.g+other.h or (self.g+self.h==other.g+other.h and self.h&lt;other.h)\n\n    def plan(self):\n        open = &#91;]\n        closed = &#91;]\n        self.searched = &#91;] # Used to record nodes that are searched\n\n        nexts = &#91;(-1,0),(0,1),(0,-1),(1,0),(-1,1),(1,1),(1,-1),(-1,-1)]\n\n        self.start.h = self.heuristic(self.start.position)\n        heapq.heappush(open, self.start)\n\n        while open:\n            # Select the node closest to the start node\n            current_node = heapq.heappop(open)\n            if current_node.position in closed:\n                continue\n\n            # self.searched.append(current_node.position)\n            closed.append(current_node.position)\n            \n            # Find the goal\n            if current_node == self.goal:\n                self.goal = current_node\n                while current_node:\n                    self.path.append(current_node.position)\n                    current_node = current_node.parent\n                self.path = self.path&#91;::-1]\n\n                return self.goal.g\n\n            for next in nexts:\n                jumppoint = self.Jumping(current_node.position,next)\n                if jumppoint and jumppoint not in closed:\n                    h = self.heuristic(jumppoint)\n                    g = current_node.g+self.calculate_cost(current_node.position, jumppoint)\n                    jp_node = self.Node(jumppoint,g,h,current_node)\n                    heapq.heappush(open,jp_node)\n                    self.searched.append(jumppoint)\n                    if jp_node == self.goal:\n                        break\n\n        \n        return -1\n    \n    def Jumping(self, node, direction):\n        new_node = (node&#91;0]+direction&#91;0], node&#91;1]+direction&#91;1])\n        \n        if self.grid&#91;new_node&#91;0]]&#91;new_node&#91;1]] == 1:\n            return None\n\n        if new_node == self.goal.position:\n            return new_node\n\n        # Find forced neighbor at horizaontal and vertical direction\n        if self.findForcedNeighbor(new_node, direction):\n            return new_node\n        \n        # If current direction of search is diagonal, then search jump point horizaontally or vertically\n        if direction&#91;0]!=0 and direction&#91;1]!=0:\n            y_dir = (direction&#91;0],0)\n            x_dir = (0,direction&#91;1])\n            if self.Jumping(new_node,x_dir) or self.Jumping(new_node,y_dir):\n                return new_node\n        \n        return self.Jumping(new_node,direction)\n\n    def findForcedNeighbor(self, node, direction):\n        \"\"\"\n            If there be forced neighbor, return Ture otherwise False\n        \"\"\"\n        y,x = node\n\n        # vertical\n        if direction&#91;0]!=0 and direction&#91;1]==0:\n            if (self.grid&#91;y]&#91;x+1] != 0 and self.grid&#91;y+direction&#91;0]]&#91;x+1] == 0) or \\\n                (self.grid&#91;y]&#91;x-1] != 0 and self.grid&#91;y+direction&#91;0]]&#91;x-1] == 0):\n                return True\n        \n        # horizontal\n        if direction&#91;0]==0 and direction&#91;1]!=0:\n            if (self.grid&#91;y+1]&#91;x] != 0 and self.grid&#91;y+1]&#91;x+direction&#91;1]] == 0) or \\\n                (self.grid&#91;y-1]&#91;x] != 0 and self.grid&#91;y-1]&#91;x+direction&#91;1]] == 0):\n                return True\n        \n        # diagonal\n        if direction&#91;0]!=0 and direction&#91;1]!=0:\n            if (self.grid&#91;y-direction&#91;0]]&#91;x] != 0 and self.grid&#91;y-direction&#91;0]]&#91;x+direction&#91;1]] == 0) or \\\n                (self.grid&#91;y]&#91;x-direction&#91;1]] != 0 and self.grid&#91;y+direction&#91;0]]&#91;x-direction&#91;1]] == 0):\n                return True\n        \n        return False\n\n    # def heuristic(self, node):\n    #     # Manhattan distance from current node to goal node\n    #     return abs(node&#91;0] - self.goal.position&#91;0]) + abs(node&#91;1] - self.goal.position&#91;1])\n    \n    # def heuristic(self, node):\n    #     # Chebyshev Distance\n    #     D = 1\n    #     D2 = math.sqrt(2)\n    #     dx = abs(node&#91;0] - self.goal.position&#91;0])\n    #     dy = abs(node&#91;1] - self.goal.position&#91;1])\n    #     return D * (dx + dy) + (D2 - 2 * D) * min(dx, dy)\n    \n    def heuristic(self, node):\n        # Euclidean Distance\n        D = 1\n        dy = abs(node&#91;0] - self.goal.position&#91;0])\n        dx = abs(node&#91;1] - self.goal.position&#91;1])\n        return D * math.sqrt(dx * dx + dy * dy)\n    \n    def calculate_cost(self, start, end):\n        # The distance from the current node to the next jump point\n        return math.sqrt((start&#91;0] - end&#91;0]) ** 2 + (start&#91;1] - end&#91;1]) ** 2)\n        \n<\/code><\/pre>\n\n\n\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"640\" height=\"480\" src=\"http:\/\/192.168.10.115\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-167.png\" alt=\"\" class=\"wp-image-17008\" srcset=\"http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-167.png 640w, http:\/\/222.128.65.89:18086\/wp-content\/uploads\/2024\/10\/\u56fe\u7247-167-300x225.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u8def\u5f84\u89c4\u5212\u2014\u2014Jump Point Search [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1],"tags":[],"class_list":["post-17004","post","type-post","status-publish","format-standard","hentry","category-technology-frontier","category-home"],"views":0,"_links":{"self":[{"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/posts\/17004"}],"collection":[{"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/comments?post=17004"}],"version-history":[{"count":1,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/posts\/17004\/revisions"}],"predecessor-version":[{"id":17009,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/posts\/17004\/revisions\/17009"}],"wp:attachment":[{"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/media?parent=17004"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/categories?post=17004"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/222.128.65.89:18086\/index.php\/wp-json\/wp\/v2\/tags?post=17004"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}