本文整理汇总了C++中AI::PlacePieces方法的典型用法代码示例。如果您正苦于以下问题:C++ AI::PlacePieces方法的具体用法?C++ AI::PlacePieces怎么用?C++ AI::PlacePieces使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AI
的用法示例。
在下文中一共展示了AI::PlacePieces方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PlayGame
//Finish later
GameResult UI::PlayGame() {
//create two grids: Player & enemy
Channel<MoveResult> *mr = new Channel<MoveResult>();
Channel<Coordinate> *cs = new Channel<Coordinate>();
UserPlayer cup = UserPlayer(mr, cs);
CurrentGame.SetP1(&cup);
cup.setPlayerBoard(CurrentGame.GetP1Board());
AI ccai = AI(CAI);
ccai.setPlayerBoard(CurrentGame.GetP2Board());
ccai.PlacePieces();
CurrentGame.SetP2(&ccai);
initscr();
WINDOW *PlayerBoard = newwin(23, 24, 1, 1);
WINDOW *AIBoard = newwin(23, 24, 1, 50);
WINDOW *EntryArea = newwin(7, 20, 8, 26);
SetColor(PlayerBoard, 1, COLOR_WHITE, COLOR_BLACK);
SetColor(AIBoard, 1, COLOR_WHITE, COLOR_BLACK);
SetColor(PlayerBoard, 2, COLOR_RED, COLOR_BLACK);
SetColor(AIBoard, 2, COLOR_RED, COLOR_BLACK);
noecho();
//cbreak();
curs_set(0);
UserPlayer up;
keypad(stdscr, TRUE);
std::thread cg(&Game::PlayGame, &CurrentGame);
while (true) {
MoveResult tmp;
mr->get(tmp,false);
clear();
wclear(PlayerBoard);
wclear(AIBoard);
wclear(EntryArea);
mvwprintw(EntryArea, 3, 1, " <-P:E->");
wborder(PlayerBoard, '|', '|', '-', '-', '+', '+', '+', '+');
wborder(AIBoard, '|', '|', '-', '-', '+', '+', '+', '+');
wborder(EntryArea, '|', '|', '-', '-', '+', '+', '+', '+');
//render playerboard
mvwprintw(PlayerBoard, 1, 4, "A B C D E F G H I J");
for (int i = 0; i < 22; i += 2) {
SetColor(PlayerBoard, 2);
string gletter = std::to_string(i / 2);
SetColor(PlayerBoard, 2);
mvwprintw(PlayerBoard, i + 3, 4, "0 0 0 0 0 0 0 0 0 0");
SetColor(PlayerBoard, 1);
if (i % 2 == 0) {
SetColor(PlayerBoard, 1);
mvwprintw(PlayerBoard, i + 3, 1, gletter.c_str());
}
}
//render ai board
mvwprintw(AIBoard, 1, 4, "A B C D E F G H I J");
for (int i = 0; i < 22; i += 2) {
SetColor(AIBoard, 2);
string gletter = std::to_string(i / 2);
SetColor(AIBoard, 2);
mvwprintw(AIBoard, i + 3, 4, "0 0 0 0 0 0 0 0 0 0");
SetColor(AIBoard, 1);
if (i % 2 == 0) {
SetColor(AIBoard, 1);
mvwprintw(AIBoard, i + 3, 1, gletter.c_str());
}
}
RenderToGrid(PlayerBoard, CurrentGame.GetP1Board()->Hits);
RenderToGrid(AIBoard, CurrentGame.GetP2Board()->Hits);
//
refresh();
wrefresh(PlayerBoard);
wrefresh(AIBoard);
wrefresh(EntryArea);
MoveResult cmr;
while (true) {
char ychar = getchar();
while (ychar < 'a' || ychar > 'j') {
ychar = getchar();
}
mvwprintw(EntryArea, 1, 2, &ychar);
wrefresh(EntryArea);
int y = ychar - 'a';
char xchar = getchar();
while (xchar < '0' || xchar > '9') {
xchar = getchar();
}
mvwprintw(EntryArea, 1, 3, &xchar);
wrefresh(EntryArea);
int x = xchar - '0';
cs->put(Coordinate{ x,y });
mr->get(cmr);
if (cmr == InvalidMove) {
mvwprintw(EntryArea, 1, 2, "IM");
continue;
}
if (cmr == Hit) {
mvwprintw(EntryArea, 2, 2, "HIT");
}
else if (cmr == Miss) {
mvwprintw(EntryArea, 2, 2, "MISS");
}
//.........这里部分代码省略.........