-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNode.h
56 lines (48 loc) · 1.17 KB
/
Node.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
54
55
56
#ifndef Node_H
#define Node_H
#include<iostream>
#include<vector>
#include<deque>
#include<map>
#include<utility>
#define EMPTY -1 //used in Node class
#define WALL -2
#define HEAD 0
#define TAIL 1
#define ROW 0
#define COL 1
#define GOAL_SNAKE 0
using namespace std;
struct Node
{
static short width, height, n_snakes;//board width and height are same across all Nodes
vector<deque<pair<short,short>>> snakes;
vector<vector<short>> board; //each cell has a number, -1 means empty,
// Snakes are represented by a double ended queue of coordinates
Node(){}
// width, height, and number of wrigglers
Node(short width_in, short height_in,short n_snakes_in);
string get_string() const;
bool operator==(const Node& rhs) const;
};
struct Action_Node
{
short snake_index;
bool terminal_type; //head0 or tail1
pair<short,short> destination;
int prev_action; // index of parent action node index
};
//where should I properly place the code below
//Define custom hash function for Node type
namespace std
{
template <>
struct hash<Node>
{
size_t operator()(const Node& target) const
{
return (hash<string>()(target.get_string()));
}
};
}
#endif