本文整理汇总了C++中Case::getNextCase方法的典型用法代码示例。如果您正苦于以下问题:C++ Case::getNextCase方法的具体用法?C++ Case::getNextCase怎么用?C++ Case::getNextCase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Case
的用法示例。
在下文中一共展示了Case::getNextCase方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
int moveNum = 0;
freopen("input.txt", "r", stdin);
for (int y = 0; y < 8; y++)
{
scanf("%s", map[y]);
}
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x++)
{
if (map[y][x] == WHITE)
{
setBit(&nowCase.m_State, x, y, 1);
}
if (map[y][x] == GOAL)
{
goalX.push_back(x);
goalY.push_back(y);
}
}
}
for (;;)
{
printBoard();
char key = getch();
switch (key)
{
case 'a':
nowCase = nowCase.getNextCase(LEFT);
break;
case 'w':
nowCase = nowCase.getNextCase(UP);
break;
case 's':
nowCase = nowCase.getNextCase(DOWN);
break;
case 'd':
nowCase = nowCase.getNextCase(RIGHT);
break;
}
}
return 0;
}
示例2: main
int main()
{
int moveNum = 0;
Case firstCase;
freopen("input.txt", "r", stdin);
for (int y = 0; y < 8; y++)
{
scanf("%s", map[y]);
}
#ifdef FILE
freopen("output.txt", "w", stdout);
#endif
for (int y = 0; y < 8; y++)
{
for (int x = 0; x < 8; x++)
{
if (map[y][x] == WHITE)
{
setBit(&firstCase.m_State, x, y, 1);
}
if (map[y][x] == GOAL)
{
setBit(&goalState, x, y, 1);
}
if (map[y][x] == BLACK)
{
setBit(&wallState,x,y,1);
}
}
}
moveCase.push(firstCase);
alreadyEntered.insert(firstCase.m_State);
for (int move = 0;; move++)
{
int caseSize = moveCase.size();
if (caseSize == 0)
{
printf("path not found.\n");
return 0;
}
printf("move : %d, case : %d\n", move, caseSize);
for (int i = 0; i < caseSize; i++)
{
Case nowCase = moveCase.front();
Case nextCase;
moveCase.pop();
//도착
if (nowCase.m_State == goalState)
{
printf("%s\n", nowCase.m_Move.c_str());
return 0;
}
for (int j = 0; j < 4; j++)
{
nextCase = nowCase.getNextCase(moveList[j]);
if (!isChecked(nextCase.m_State))
{
moveCase.push(nextCase);
alreadyEntered.insert(nextCase.m_State);
}
}
}
}
return 0;
}