ETrobocon2017 - 片山研究所モデルベース開発推進事業部
str
apps
explorer
PuzzleExplorer.h
[詳解]
1
/*
2
$ g++-7 PuzzleExplorerTest.cpp ../explorer/Block.cpp ../explorer/Node.cpp ../explorer/PuzzleExplorer.cpp gtest_main.o gtest-all.o -I../explorer -I../../googletest/googletest/include
3
*/
4
#ifndef _INC_PUZZLE_EXPLORER_
5
#define _INC_PUZZLE_EXPLORER
6
7
#include "
Block.h
"
8
#include "
Node.h
"
9
#include <stdio.h>
10
11
#include <queue>
12
13
using namespace
std
;
14
15
#define TARGET_BLACK 0
16
#define TARGET_RED 1
17
#define TARGET_YELLOW 5
18
#define TARGET_BLUE 2
19
#define TARGET_GREEN 10
20
21
class
PuzzleExplorer
22
{
23
public
:
24
PuzzleExplorer
();
25
~
PuzzleExplorer
();
26
void
init(
int
*blockPositions);
27
BlockColor
getNodeColor(
int
num);
28
Node
** getMyNeighbor();
29
void
setMyPosition(
int
num);
30
int
getNearestBlockPosition();
31
int
* getRoot(
int
startNode,
int
goalNode);
32
int
getCost(
Node
node1,
Node
node2);
33
34
private
:
35
int
myPosition;
36
Block
blockList[5];
37
Node
nodeList[16];
38
const
int
neighborList[16][5] = {
39
{6,8,9,13,14},
40
{2,5,10,-1,-1},
41
{1,3,5,6,-1},
42
{2,4,6,7,-1},
43
{3,7,11,-1,-1},
44
{1,2,8,10,-1},
45
{0,2,3,8,9},
46
{3,4,9,11,-1},
47
{0,5,6,12,13},
48
{0,6,7,14,15},
49
{1,5,12,-1,-1},
50
{4,7,15,-1,-1},
51
{8,10,13,-1,-1},
52
{0,8,12,14,-1},
53
{0,9,13,15,-1},
54
{9,11,14,-1,-1}
55
};
56
const
int
nodePositionList[16][2] = {
57
{6,3},
58
{0,0},
59
{4,0},
60
{8,0},
61
{12,0},
62
{2,1},
63
{6,1},
64
{10,1},
65
{4,2},
66
{8,2},
67
{1,3},
68
{11,3},
69
{3,4},
70
{5,4},
71
{7,4},
72
{9,4}
73
};
74
int
root[16]={};
75
void
setNodes();
76
void
setBlocks(
int
*blockPositions);
77
void
setNeighborNode();
78
79
};
80
81
#endif //_INC_PUZZLE_EXPLORER
Node
Definition:
Node.h:9
std
BlockColor
BlockColor
Definition:
BlockColor.h:5
Block
Definition:
Block.h:9
Node.h
Block.h
PuzzleExplorer
Definition:
PuzzleExplorer.h:21
構築:
1.8.13