24 setBlocks(blockPositions);
39 void PuzzleExplorer::setNodes()
41 for(
int i=0; i<16; i++)
46 node.
setPosition(nodePositionList[i][0], nodePositionList[i][1]);
53 void PuzzleExplorer::setBlocks(
int *blockPositions)
55 for(
int i=0; i<5; i++)
57 Block block(blockPositions[i]);
74 void PuzzleExplorer::setNeighborNode()
77 for(
int i=0; i<16;i++)
79 Node* neighbor[5] = {};
81 for(
int j=0; j<5; j++)
84 if(neighborList[i][j] == -1)
86 neighbor[j] =
nullptr;
89 Node* node = &nodeList[neighborList[i][j]];
114 Node node = nodeList[myPosition];
123 for(
int i=0; i<5; i++){
126 if(nodes[i] ==
nullptr)
continue;
134 if(que.front().getHasBlock())
149 Node node = nodeList[startNode];
150 Node goal = nodeList[goalNode];
165 for(
int j=0; j<5; j++)
168 if(explorerNodes[j] ==
nullptr)
continue;
171 int neighborCost =
getCost(*explorerNodes[j], goal);
172 if(cost > neighborCost)
175 nextNode = *explorerNodes[j];
179 root[i] = nextNode.
getNum();
void setPosition(int x, int y)
void setMyPosition(int num)
int getCost(Node node1, Node node2)
void setHasBlock(bool exists)
void init(int *blockPositions)
void setColor(BlockColor blockColor)
BlockColor getNodeColor(int num)
void setNeighbor(Node **nodes)
int * getRoot(int startNode, int goalNode)
int getNearestBlockPosition()