int main(int argc, char *argv[]) { srand(time(NULL)); Board *board=choose_game(AWALE); board->print(); board->play_random_move(PLAYER_1); board->print(); board->play_random_move(PLAYER_2); board->print(); board->play_random_move(PLAYER_1); board->print(); std::cout << "----------" << std::endl; Board *copy=board->deepcopy(); Token winner=board->play_random_game(PLAYER_2); if (winner==NOT_PLAYED) std::cout<<"draw"<<std::endl; else std::cout<<"player "<<winner<<" won"<<std::endl; board->print(); delete board; std::cout << "----------" << std::endl; copy->play_random_move(PLAYER_2); copy->print(); delete copy; return 0; }
int main(int argc, char *argv[]) { std::cout.precision(2); std::cout.setf(std::ios::fixed,std::ios::floatfield); srand(static_cast<unsigned int>(time(nullptr))); Game game=OTHELLO; if (argc>1) game=parse_game(argv[1]); Board *board=choose_game(game); float p1time = static_cast<float>(1.); float p2time = static_cast<float>(1.); if (argc>2) p1time = parse_float(argv[2],p1time); if (argc>3) p2time = parse_float(argv[3],p2time); Player *player_a=new PlayerBot(PLAYER_1,p1time,0,0.2); Player *player_b=new PlayerBot(PLAYER_2,p2time,0,0.2); play_game(player_a,player_b,board); delete board; delete player_a; delete player_b; return 0; }
int main(){ card_game *game; char game_choice; game_choice = choose_game(); if(game_choice == 'p') game = new poker; else if(game_choice == 'g') game = new go_fish; game->playGame(); }
int main() { game *g; char game_choice; game_choice = choose_game(); if (game_choice == 'p') g = new poker; else if(game_choice == 'g') g = new gofish; g -> play(); return 0; }
char choose_game() { char letter; cout << "To play poker, please enter a p. To play go fish, please " << "enter a g." << endl; cout << "Please enter a letter now: "; cin >> letter; if((letter != 'g') && (letter != 'p')) letter = choose_game(); return letter; }