answersLogoWhite

0

What is tic tac toe 2.0?

User Avatar

Anonymous

12y ago
Updated: 8/20/2019

// Tic-Tac-Toe

// Plays the game of tic-tac-toe against a human opponent

#include

<iostream>

#include

<string>

#include

<vector>

#include

<algorithm>

using

namespace std;

// global constants

const

char X = 'X';

const

char O = 'O';

const

char EMPTY = ' ';

const

char TIE = 'T';

const

char NO_ONE = 'N';

void

instructions();

char

askYesNo(string question);

int

askNumber(string question, int high, int low = 0);

char

humanPiece();

char

opponent(char piece);

void

displayBoard(const vector<char>* const pBoard);

char

winner(const vector<char>* const pBoard);

bool

isLegal(const vector<char>* const pBoard, int move);

int

humanMove(const vector<char>* const pBoard, char human);

int

computerMove(vector<char> board, char computer);

void

announceWinner(char winner, char computer, char human);

// main function

int

main()

{

int

move;

const

int NUM_SQUARES = 9;

vector

<char> board(NUM_SQUARES, EMPTY);

instructions();

char

human = humanPiece();

char

computer = opponent(human);

char

turn = X;

displayBoard(&board);

while

(winner(&board) human;

board

[move] = EMPTY;

}

if

(!found)

{

++move;

}

}

}

if

(!found)

{

move = 0;

unsigned

int i=0;

const

int BEST_MOVES[] = {4, 0, 2, 6, 8, 1, 3, 5, 7};

while

(!found && i< board.size())

{

move = BEST_MOVES[i];

if

(isLegal(move, &board))

{

found =

true;

}

++i;

}

}

cout <<

" I Shall take square number" << move << endl;

return

move;

}

void

announceWinner(char winner, char computer, char human)

{

if

(winner == computer)

{

cout <<

winner << "'s won!\n";

cout <<

"As I predicted, human, I am triumphant once more - proof\n";

cout <<

"that computers are superior to humans in all regards.\n";

}

else

if (winner == human)

{

cout <<

winner << "'s won!\n";

cout <<

"No, no! It cannot be! Somehow you tricked me, human.\n";

cout <<

"But never again! I, the computer, so swear it!\n";

}

else

{

cout <<

"It's a tie.\n";

cout <<

"You were most lucky, human, and somehow managed to tie me.\n";

cout <<

"Celebrate... for this is the best you will ever achieve.\n";

}

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Can you achieve a tic tac toe 5 in a row in a game of tic tac toe"?

No, you cannot achieve a 5 in a row in a game of tic-tac-toe.


What is tic tac toe called in America?

We also call it tic tac toe!


What lyrics say tic tac toe?

Kyper - Tic Tac Toe D Cole - Tic Tac toe still looking for a 3rd for a hiphop dance


Where was tic tac toe invented?

The game Tic Tac Toe is originally from ancient Egypt. http://theeasyanswers.com


What is s in t s 9?

9 Squares in Tic Tac Toe


What is a winning row in tic-tac-toe called?

O = tic, X = tac, a line aka win = toe


How many pieces are used in a game of tic-tac-toe?

A game of tic-tac-toe uses nine pieces.


Where was tic-tac-toe invented?

tic tac toe was invented in stamford Connecticut, man it was the easiest thing. they played a game and called it ticdas to but the Americans borrowed it and named it tic tac toe and know it is fdamouse around the whole world


Who invented the game Tic-Tac-Toe?

ME!!


Is tic tac toe copyrighted?

Of Course Not!!


What are the ultimate tic-tac-toe rules and how do they differ from traditional tic-tac-toe?

Ultimate tic-tac-toe is a variation of the classic game where each square on the board is actually a smaller game of tic-tac-toe. Players must win three smaller games in a row to win the overall game. The main difference from traditional tic-tac-toe is that players must think strategically about which smaller game to play in, adding an extra layer of complexity to the game.


What is a slogan for tic tac toe?

&quot;Three in a row, tic tac toe!&quot; - It's short, sweet, and to the point, just like the game itself. Just make sure you don't end up with a stalemate, that's a snooze fest.