-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuzzle_move.h
53 lines (43 loc) · 1.37 KB
/
puzzle_move.h
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
#ifndef PUZZLEMOVE_H
#define PUZZLEMOVE_H
#include <functional>
#include "board.h"
#include "puzzle_heur.h"
class PuzzleMove
{
public:
// Constructor for starting Board of an A* search
/** Constructor for starting Board of an A* search
@ param b
*/
PuzzleMove(Board &b);
/** Constructor for subsequent search boards
* (i.e. those returned by Board::potentialMoves() )
*/
PuzzleMove(int tile, Board *b, PuzzleMove *parent);
// Destructor
~PuzzleMove();
// Compare to PuzzleMoves based on f distance
bool operator<(const PuzzleMove& p) const;
bool operator>(const PuzzleMove& p) const;
bool operator==(const PuzzleMove& p) const;
//**** Add any other member functions you think appropriate
// Data members can be public
public:
int tileMove_; // tile moved to reach the Board b
Board *b_; // Pointer to a board representing the updated state
int g_; // distance from the start board
int h_; // heuristic distance to the goal
int f_; // g_ + h_ : f-score
PuzzleMove *prev_; // Pointer to parent PuzzleMove
};
// Leave this alone and don't touch it!
struct PuzzleMoveGreater :
public std::binary_function<const PuzzleMove*, const PuzzleMove*,bool>
{
bool operator()(const PuzzleMove *m1, const PuzzleMove *m2) const
{
return *m1 > *m2;
}
};
#endif