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