int main (){ printf("Start game\n"); initBoard(); /*ボードの初期化*/ showBoard(); /*ボードの表示*/ initStone(); /*石の初期化*/ initPlayer(); /*プレーヤーの初期化*/ cont = 1; /*継続判定の初期化*/ judge = 0; /*勝ち判定初期化*/ printf("\n"); while (cont == 1){ input(); /*マス目の選択受付*/ showBoard(); checkWin(); /*勝ち判定*/ if (judge == 1){ break; /*勝ち判定ありの場合、ループ脱出*/ } else { check(); /*ゲーム継続可能性(空きマスがあるか)の判定*/ changeStone(); changePlayer(); printf("\n"); } } printf("\n"); dispWinner(); /*judgeの値により勝者表示OR引分宣言*/ return 0; }
void Board2048::runGame(){ srand(time(0)); try { /* check board */ if(board.size()==0){ throw exception(); } /* rand a key to put on the board */ randKey(2); /* Show the initial board */ assert(getKeyNum()==2); showBoard('N'); while(1){ /* get input char */ getInput(); if(b_quit == 'q') break; else if(b_quit=='n'){ b_quit = ' '; continue; } moveBoard(); randKey(1); showBoard('N'); checkOver(); if(b_quit == 'q') break; } cout<<endl; }catch(exception e){ cout<<"Board was NOT initialized"<<endl; } }
void movePlayer(int x, int y) //need to figure out how to move with the keypresses { if(GetAsyncKeyState(VK_UP)) { board[y][x] = 0; board[y - 1][x] = 1; system("CLS"); //just for testing right now showBoard(); } if(GetAsyncKeyState(VK_DOWN)) { board[y][x] = 0; board[y + 1][x] = 1; system("CLS"); showBoard(); } if(GetAsyncKeyState(VK_LEFT)) { board[y][x] = 0; board[y][x - 1] = 1; system("CLS"); showBoard(); } if(GetAsyncKeyState(VK_RIGHT)) { board[y][x] = 0; board[y][x + 1] = 1; system("CLS"); showBoard(); } if(GetAsyncKeyState(VK_ESCAPE)) { playing = false; } }
int main(int argc, char * argv[]) { bool compFirst = argc == 1; printf("\nConnect Four\n"); printf("============\n"); printf("\n"); bool fiar = false; bool over = false; int playCount = 0; Board board; player computer = compFirst ? PLAYER_ONE : PLAYER_TWO; player human = compFirst ? PLAYER_TWO : PLAYER_ONE; showBoard(board); while (1) { over = compFirst ? computerMoves(board, computer, playCount) : playerMoves(board, human, playCount); if (over) break; if (compFirst) showBoard(board); over = compFirst ? playerMoves(board, human, playCount) : computerMoves(board, computer, playCount); if (over) break; if (!compFirst) showBoard(board); } board.displayBoard(); return 0; }
void GameManager::runGame() { if (!isGameEnded()) { emit showBoard(); if (playersNumber == 2) { if (currentID == FIRST_PLAYER) { std::cout << "First player: your move" << std::endl; emit startMoveFirst(); } else { std::cout << "Second player: your move" << std::endl; emit startMoveSecond(); } } if (playersNumber == 1) { if (currentID == FIRST_PLAYER) { std::cout << "First player: your move" << std::endl; emit startMoveFirst(); } else { std::cout << "Second player: your move" << std::endl; emit startMoveSecond(); } } return; } gameEnding(); }
void Board2048::getInput(){ char ch; bool go(false); while(!go && (ch = getch())){ switch(ch){ case 'w': b_way = 'U'; go = true; break; case 's': b_way = 'D'; go = true; break; case 'a': b_way = 'L'; go = true; break; case 'd': b_way = 'R'; go = true; break; case 'q': go = true; break; default: break; } } if(ch == 'q') showBoard('Q'); }
int main(int argc, char* argv[]) { #if defined(WIN32) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif chess::Engine* engine = new chess::Engine(); int player = 1; engine->startup(player); unsigned char board[90]; int state = engine->getState(board); while ((state & 0xf) < 3) { showBoard(board); if (engine->getPlayer() == player) { if (!youMove(engine)) break; } else { if (!aiMove(engine)) break; } state = engine->getState(board); } showBoard(board); if ((state & 0xF) == chess::Engine::BLACK_WIN) { if (player == 1) printf("You win!\n"); else printf("You lost!\n"); } else if ((state & 0xF) == chess::Engine::RED_WIN) { if (player == 0) printf("You win!\n"); else printf("You lost!\n"); } else if ((state & 0xF) == chess::Engine::DRAW) { printf("Draw with computer!\n"); } else { printf("User cancel or error!\n"); } delete engine; #if defined(WIN32) _CrtDumpMemoryLeaks(); #endif return 0; }
int maze_main() { removeCursor(); //커서깜박이지우기 setCursor(POINT_X, POINT_Y); //보드시작좌표 showBoard(); //미로판보여주기 character_static(); //케릭터움직이기 getchar(); return 0; }
int main(int argc, char const *argv[]) { int x = 0, y = 0; char done = '-'; char mainboard[3][3]; initBoard(mainboard); do { showBoard(mainboard); playerMove(mainboard); done = boardCheck(mainboard, 'X'); if (done != '-') break; computerMove(mainboard); done = boardCheck(mainboard,'O'); if(done!='-') break; } while (done == '-'); if (done == 'X') printf("You won\n"); else printf("Computer Won\n"); showBoard(mainboard); return 0; }
/// \brief The thread to print Board to screen /// \param arg Void /// \return void* NULL void* t_NetworkShow(void* arg){ if(BoardWin!=NULL)delwin(BoardWin); BoardWin = newwin(row-6, col, 1, 0); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS , NULL); int oldtype; while(1){ pthread_testcancel(); pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &oldtype); pthread_mutex_lock(&MBoard); pthread_testcancel(); pthread_mutex_lock(&MScr); wclear(BoardWin); curs=0; showBoard(BoardWin,0,5); curs=1; showBoard(BoardWin,0,col/2); pthread_mutex_unlock(&MScr); pthread_cond_wait (&CBoard, &MBoard); pthread_testcancel(); pthread_mutex_unlock(&MBoard); pthread_setcanceltype(oldtype, NULL); } return NULL; }
main() { ch = getchar(); for (j=0; ;j++) { getNextToken(); if (0 == tokenLen) break; strcpy(inputStrings[j % MAX_strings],str); printf("%s\n",inputStrings[j % MAX_strings]); if (0 == strcmp(str,"DimX")) { getNextToken(); dimX = numeric(str); } else if (0 == strcmp(str,"DimY")) { getNextToken(); dimY = numeric(str); for (x = 0; x < dimX; x++) for (y = 0; y < dimY; y++) { board[x][y] = EMPTY; boardLabels[x][y] = -1; } } else if (0 == strcmp(str,"HexBlackLabelledPiece")) update(BLACK, j-6, j-5, j); else if (0 == strcmp(str,"HexWhiteLabelledPiece")) update(WHITE, j-6, j-5, j); else if (0 == strcmp(str,"HexBlackPiece")) update(BLACK, j-2, j-1, -1); else if (0 == strcmp(str,"HexWhitePiece")) update(WHITE, j-2, j-1, -1); else if (0 == strcmp(str,"HexBlackMarkedPiece")) update(BLACKMARKED, j-2, j-1, -1); else if (0 == strcmp(str,"HexWhiteMarkedPiece")) update(WHITEMARKED, j-2, j-1, -1); else if (0 == strcmp(str,"HexDeadCell")) update(EMPTYMARKED, j-2, j-1, -1); } showBoard(dimX,dimY); showBoardLabels(dimX,dimY); }
int main() { std::cout << "Running of Denoising AutoEncoder begins." << std::endl; std::vector<dataInBatch> shuffled = loadData("data/train-images-idx3-ubyte", "data/train-labels-idx1-ubyte", 100); dataInBatch trainingData = shuffled[0]; dataInBatch trainingLabel = shuffled[1]; std::vector<dataInBatch> shuffledT = loadData("data/t10k-images-idx3-ubyte", "data/t10k-labels-idx1-ubyte", 100); dataInBatch testingData = shuffledT[0]; dataInBatch testingLabel = shuffledT[1]; AutoEncoder ae(6); std::vector<size_t> k; k.push_back(500); k.push_back(300); ae.setLayer(k); dataInBatch corruptedTrainingData = corruptImage(trainingData, 0.2); dataInBatch corruptedTestingData = corruptImage(testingData, 0.2); ae.denoise(0.2); ae.train(trainingData, 6); ae.fineTuning(trainingData, corruptedTrainingData); ae.reconstruct(testingData); dataInBatch reTest = ae.g_reconstruction(); dimension boardDIM(6, 6, 1); dimension imgDIM(28, 28, 1); imageBoard board(boardDIM, imgDIM); std::vector<imageIndex> selectionIndex = generateSelections(); std::vector<cv::Mat> samples = sampleSelection(corruptedTestingData, selectionIndex); dataToPixel(samples); board.s_referenceSet(samples); std::vector<cv::Mat> samplesN = sampleSelection(reTest, selectionIndex); dataToPixel(samplesN); board.s_imageSet(samplesN); showBoard(board, 0, "Reconstruction visualization"); return 0; }
Player::Player(QObject *parent) : QObject(parent) { isChosen = false; isCommited = false; score = 0; } //Connections void Player::connectToBoard(QObject* board) { connect(this, SIGNAL(chooseLetter(QPair<QPair<int,int>,QChar>&)), board, SLOT(chooseLetterFirst(QPair<QPair<int,int>,QChar>&))); connect(this, SIGNAL(pushLetter(QPair<int,int>&)), board, SLOT(pushLetterFirst(QPair<int,int>&))); connect(this, SIGNAL(commitWord()), board, SLOT(gotCommitQuery())); connect(this, SIGNAL(showBoard()), board, SLOT(showBoardToPlayer())); } void Player::connectToManager(QObject* gameManager) { connect(this, SIGNAL(moveEnded()), gameManager, SLOT(stepEnded())); connect(this, SIGNAL(dontMakeMove()), gameManager, SLOT(gameEnding())); } void Player::connectToInterface(QObject *graphicBoard) { connect(this, SIGNAL(afterLetterChosed(QPair<QPair<int,int>, QChar>)), graphicBoard, SLOT(afterCellChoosen(QPair<QPair<int,int>, QChar>))); connect(this, SIGNAL(afterLetterPushed(QPair<int,int>)), graphicBoard, SLOT(afterCellPushed(QPair<int,int>))); connect(this, SIGNAL(afterWordCommited(QString)), graphicBoard, SLOT(afterWordCommited(QString))); connect(this, SIGNAL(resetWord(const QPair<int,int>&)), graphicBoard, SLOT(onPlayerResetWord(const QPair<int,int>&)));
void Board2048::checkOver(){ if(getMaxKey()>=2048){ showBoard('O'); } }
/*MAIN*/ int main() { struct mossa *testa; /*Puntator to list's head*/ struct mossa *nuova; /*Puntator to list's tail*/ struct mossa *nuova_da_ordinare; /*Puntator to new move BEFORE is sorted*/ struct mossa *testa_da_ordinare; /*Puntator to tail's head to be sorted*/ struct mossa *temp; /*Puntator to temporary structure*/ struct mossa *puntatore_ad_array_struct; /*Puntator to structure's array*/ testa=NULL;/*Initializing head to NULL*/ testa_da_ordinare=NULL;/*Initializing head to be sorted to NULL*/ char name1[31], name2[31], *name, rigioca, deb[51]; char r4[201]=MENU; int i, controlli, sottoScacco=0, partita=1, player=0, numero_celle, contatore3=0; time_t prima_della_mossa=0; pedina pedine[33]; pedina *board[8][8], *testBoard[8][8], *toTest; posizione pos1, pos2; presentazione(); name=name1; daCapo(pedine, board, name1, name2, name, &numero_celle); /*----------*/ do { i=0, controlli=0; while (controlli==0) { printf("\n%s\n", r4); switch (userInput()) { case 'n': clear(); daCapo(pedine, board, name1, name2, name, &numero_celle); showBoard(board); player=0; continue; case 'q': uscita(); showBoard(board); continue; case 'h': help(); showBoard(board); continue; #ifndef _WIN32 case 'x': save(pedine, board, name1, name2, player, numero_celle, testa); continue; case 'c': testa = load(pedine, board, name1, name2, name, &player, &numero_celle); debug("Initializing head's test"); temp=testa; while(temp != NULL) { sprintf(deb, "player: %s\n", (temp->player==0)?name1:name2); debug(deb); sprintf(deb, "move: %s\n", temp->coordinate); debug(deb); sprintf(deb, "duration: %.2lf secs\n", temp->durata_mossa); debug(deb); temp=temp->next; contatore3++; } debug("End head's test"); continue; #endif case 's': stallo(); showBoard(board); continue; } showBoard(board); if(prima_della_mossa==0) { time(&prima_della_mossa); } if (getCoordinate(board, &pos1, &pos2, name, player) && pos1.loc->player==player && checkMove(pedine, board, &pos1, &pos2, player, 0)) { numero_celle=conteggio_celle(numero_celle); testa=newtime(player, testa, nuova, &pos1, &pos2, prima_della_mossa, numero_celle, name1, name2); prima_della_mossa=0; controlli = 1; } else { printf("\nWrong coordinates, re-enter\n"); } } toTest = (player==0)? pedine+27 : pedine+3; //Re avversario if (scacco(toTest->l, toTest->n, player, board, pedine, player)) {sottoScacco=1; printf("\nScacco al RE\n"); } if (sottoScacco) { debug("UNDER CHECK"); if(roundRe(toTest->l, toTest->n, player, board, pedine, player)) { debug("maybe mate??\n"); if(checkMatto(toTest->l, toTest->n, board, pedine, player)) { clear(); printf("\nCheck mate!!!!!\n"); rigioca=vittoria(player,name1,name2,testa,puntatore_ad_array_struct,numero_celle); if(rigioca=='y') { clear(); daCapo(pedine, board, name1, name2, name, &numero_celle); showBoard(board); player=0; continue; } else { printf("\nThank for playing! Have a nice day."); getch(); exit(0); } } else {debug("not mate..");} } } sprintf(deb, "%c --> moved=%d", pos1.loc->tipo, pos1.loc->moved); debug(deb); sprintf(deb, "%c (%d,%d) in %c (%d,%d)", pos1.loc->tipo, pos1.l+1, pos1.n+1, (*board[pos2.n][pos2.l]).tipo, pos2.l+1, pos2.n+1); debug(deb); sottoScacco=0; clear(); nexTurn(&player); name=(player==0)?name1:name2; } while(partita != 0); return 0; }
int UBApplication::exec(const QString& pFileToImport) { QPixmapCache::setCacheLimit(1024 * 100); QString webDbPath = UBSettings::userDataDirectory() + "/web-databases"; QDir webDbDir(webDbPath); if (!webDbDir.exists(webDbPath)) webDbDir.mkpath(webDbPath); QWebSettings::setIconDatabasePath(webDbPath); QWebSettings::setOfflineStoragePath (webDbPath); QWebSettings *gs = QWebSettings::globalSettings(); gs->setAttribute(QWebSettings::JavaEnabled, true); gs->setAttribute(QWebSettings::PluginsEnabled, true); gs->setAttribute(QWebSettings::LocalStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, true); gs->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); gs->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true); gs->setAttribute(QWebSettings::DnsPrefetchEnabled, true); mainWindow = new UBMainWindow(0, Qt::FramelessWindowHint); // deleted by application destructor mainWindow->setAttribute(Qt::WA_NativeWindow, true); mainWindow->actionCopy->setShortcuts(QKeySequence::Copy); mainWindow->actionPaste->setShortcuts(QKeySequence::Paste); mainWindow->actionCut->setShortcuts(QKeySequence::Cut); connect(mainWindow->actionBoard, SIGNAL(triggered()), this, SLOT(showBoard())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(showInternet())); connect(mainWindow->actionWeb, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(showDocument())); connect(mainWindow->actionDocument, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionQuit, SIGNAL(triggered()), this, SLOT(closing())); connect(mainWindow, SIGNAL(closeEvent_Signal(QCloseEvent*)), this, SLOT(closeEvent(QCloseEvent*))); boardController = new UBBoardController(mainWindow); boardController->init(); webController = new UBWebController(mainWindow); documentController = new UBDocumentController(mainWindow); boardController->paletteManager()->connectToDocumentController(); UBDrawingController::drawingController()->setStylusTool((int)UBStylusTool::Pen); applicationController = new UBApplicationController(boardController->controlView(), boardController->displayView(), mainWindow, staticMemoryCleaner); connect(applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), boardController->paletteManager(), SLOT(slot_changeMainMode(UBApplicationController::MainMode))); connect(applicationController, SIGNAL(desktopMode(bool)), boardController->paletteManager(), SLOT(slot_changeDesktopMode(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), applicationController, SLOT(showDesktop(bool))); connect(mainWindow->actionDesktop, SIGNAL(triggered(bool)), this, SLOT(stopScript())); #ifndef Q_WS_MAC connect(mainWindow->actionHideApplication, SIGNAL(triggered()), mainWindow, SLOT(showMinimized())); #else connect(mainWindow->actionHideApplication, SIGNAL(triggered()), this, SLOT(showMinimized())); #endif mPreferencesController = new UBPreferencesController(mainWindow); connect(mainWindow->actionPreferences, SIGNAL(triggered()), mPreferencesController, SLOT(show())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), applicationController, SLOT(showTutorial())); connect(mainWindow->actionTutorial, SIGNAL(triggered()), this, SLOT(stopScript())); connect(mainWindow->actionSankoreEditor, SIGNAL(triggered()), applicationController, SLOT(showSankoreEditor())); connect(mainWindow->actionCheckUpdate, SIGNAL(triggered()), applicationController, SLOT(checkUpdateRequest())); toolBarPositionChanged(UBSettings::settings()->appToolBarPositionedAtTop->get()); bool bUseMultiScreen = UBSettings::settings()->appUseMultiscreen->get().toBool(); mainWindow->actionMultiScreen->setChecked(bUseMultiScreen); connect(mainWindow->actionMultiScreen, SIGNAL(triggered(bool)), applicationController, SLOT(useMultiScreen(bool))); connect(mainWindow->actionWidePageSize, SIGNAL(triggered(bool)), boardController, SLOT(setWidePageSize(bool))); connect(mainWindow->actionRegularPageSize, SIGNAL(triggered(bool)), boardController, SLOT(setRegularPageSize(bool))); connect(mainWindow->actionImportUniboardDocuments, SIGNAL(triggered()), this, SLOT(importUniboardFiles())); connect(mainWindow->actionCut, SIGNAL(triggered()), applicationController, SLOT(actionCut())); connect(mainWindow->actionCopy, SIGNAL(triggered()), applicationController, SLOT(actionCopy())); connect(mainWindow->actionPaste, SIGNAL(triggered()), applicationController, SLOT(actionPaste())); applicationController->initScreenLayout(bUseMultiScreen); boardController->setupLayout(); if (pFileToImport.length() > 0) { UBApplication::applicationController->importFile(pFileToImport); } #if defined(Q_WS_MAC) static AEEventHandlerUPP ub_proc_ae_handlerUPP = AEEventHandlerUPP(ub_appleEventProcessor); AEInstallEventHandler(kCoreEventClass, kAEReopenApplication, ub_proc_ae_handlerUPP, SRefCon(UBApplication::applicationController), true); #endif if (UBSettings::settings()->appStartMode->get() == "Desktop") applicationController->showDesktop(); else applicationController->showBoard(); return QApplication::exec(); }
void Game_functions::ship_menu(string type, string IP_ADDR){ string input; cout << "Hi, What's your name?:"; cin >> player_name; showBoard(); cout << "Nice to meet you " << player_name << endl; cout << "Say me something to start" << endl; cin >> input; cout << "Choose the position for your ships" << endl; do{ showBoard(); cout << "#1 Aircraft" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> aircraft_letter; } while(getLetter(aircraft_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> aircraft_number; } while(!cin || aircraft_number>24 || aircraft_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> aircraft_pos; } while(!cin || verPos(aircraft_pos)==false); } while(canSetShip(getLetter(aircraft_letter), aircraft_number, Aircraft, aircraft_pos)==false); setShip(Aircraft, aircraft_pos, aircraft_letter, aircraft_number); do{ showBoard(); cout << "#1 Battleship" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> battleship1_letter; } while(getLetter(battleship1_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> battleship1_number; } while(!cin || battleship1_number>24 || battleship1_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> battleship1_pos; } while(!cin || verPos(battleship1_pos)==false); } while(canSetShip(getLetter(battleship1_letter), battleship1_number, Battleship, battleship1_pos)==false); setShip(Battleship, battleship1_pos, battleship1_letter, battleship1_number); do{ showBoard(); cout << "#2 Battleship" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> battleship2_letter; } while(getLetter(battleship2_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> battleship2_number; } while(!cin || battleship2_number>24 || battleship2_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> battleship2_pos; } while(!cin || verPos(battleship2_pos)==false); } while(canSetShip(getLetter(battleship2_letter), battleship2_number, Battleship, battleship2_pos)==false); setShip(Battleship, battleship2_pos, battleship2_letter, battleship2_number); do{ showBoard(); cout << "#1 Cruiser" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> cruiser_letter; } while(getLetter(cruiser_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> cruiser_number; } while(!cin || cruiser_number>24 || cruiser_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> cruiser_pos; } while(!cin || verPos(cruiser_pos)==false); } while(canSetShip(getLetter(cruiser_letter), cruiser_number, Cruiser, cruiser_pos)==false); setShip(Cruiser, cruiser_pos, cruiser_letter, cruiser_number); do{ showBoard(); cout << "#1 Frigate" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> frigate1_letter; } while(getLetter(frigate1_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> frigate1_number; } while(!cin || frigate1_number>24 || frigate1_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> frigate1_pos; } while(!cin || verPos(frigate1_pos)==false); } while(canSetShip(getLetter(frigate1_letter), frigate1_number, Frigate, frigate1_pos)==false); setShip(Frigate, frigate1_pos, frigate1_letter, frigate1_number); do{ showBoard(); cout << "#1 Submarine" << endl; do{ cout << "Letter: "; cin.clear(); cin.ignore(256, '\n'); cin >> submarine_letter; } while(getLetter(submarine_letter)==666); do{ cout << "Number: "; cin.clear(); cin.ignore(256, '\n'); cin >> submarine_number; } while(!cin || submarine_number>24 || submarine_number<0); do{ cout << "Pos (v for vertical, h for horizontal):"; cin.clear(); cin.ignore(256, '\n'); cin >> submarine_pos; } while(!cin || verPos(submarine_pos)==false); } while(canSetShip(getLetter(submarine_letter), submarine_number, Submarine, submarine_pos)==false); setShip(Submarine, submarine_pos, submarine_letter, submarine_number); clear_screen(); cout << "Let's start the grid..." << endl; if (type=="server"){ nett.make_server(); } else if(type=="client"){ nett.connect_to_server(IP_ADDR.c_str()); } }
//Print string of board cards in _board vector void Round::printBoard() { cout << "Board: " << showBoard() << endl << endl; };
void startingPos(int x, int y) //sets the starting position to 1 { board[y][x] = 1; showBoard(); std::cout << std::endl; }