Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

from Node import Node 

 

class AStarNode(Node): 

# step cost 

g = 0 

 

# heuristic cost 

h = 0 

 

def __init__(self, graph, move, parent, g, h): 

""" 

Initialize AStarNode class 

 

@type graph: Map 

@param graph: Map that moves can be made on  

@type move: Move 

@param move: Move that resulted in the above graph 

@type parent: AStarNode 

@param parent: Parent node of this. Contains previous moves to get 

the current board. 

@type g: number 

@param g: Step cost for this node 

@type h: number 

@param h: Heuristic cost for this node 

""" 

super(AStarNode, self).__init__(graph, move, parent) 

self.g = g 

self.h = h 

 

def cost(self): 

""" 

Cost for this node. 

 

@rtype: number 

@return: The cost to get to this state 

""" 

return self.g + self.h