FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-pathfinding/pathfinding/core/node.py at python2 · brean/python-pathfinding · GitHub
brean
/
python-pathfinding
Public
Notifications
You must be signed in to change notification settings
Fork
73
Star
383
Code
Issues
24
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
python-pathfinding
/
pathfinding
/
core
/
node.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (42 loc) · 1.37 KB
Breadcrumbs
python-pathfinding
/
pathfinding
/
core
/
node.py
Copy path
File metadata and controls
53 lines (42 loc) · 1.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
# -*- coding: utf-8 -*-
class
Node
(
object
):
"""
basic node, saves X and Y coordinates on some grid and determine if
it is walkable.
"""
def
__init__
(
self
,
x
=
0
,
y
=
0
,
walkable
=
True
,
weight
=
1
):
# Coordinates
self
.
x
=
x
self
.
y
=
y
# Whether this node can be walked through.
self
.
walkable
=
walkable
# used for weighted algorithms
self
.
weight
=
weight
# values used in the finder
self
.
cleanup
()
def
__lt__
(
self
,
other
):
"""
nodes are sorted by f value (see a_star.py)
:param other: compare Node
:return:
"""
return
self
.
f
<
other
.
f
def
cleanup
(
self
):
"""
reset all calculated values, fresh start for pathfinding
"""
# cost from this node to the goal (for A* including the heuristic)
self
.
h
=
0.0
# cost from the start node to this node
# (calculated by distance function, e.g. including diagonal movement)
self
.
g
=
0.0
# overall cost for a path using this node (f = g + h )
self
.
f
=
0.0
self
.
opened
=
0
self
.
closed
=
False
# used for backtracking to the start point
self
.
parent
=
None
# used for recurion tracking of IDA*
self
.
retain_count
=
0
# used for IDA* and Jump-Point-Search
self
.
tested
=
False
Back
|
FazBrowse Home
|
New Git URL