answersLogoWhite

0

What is tic tac toe 2.0?

Updated: 8/20/2019
User Avatar

Wiki User

11y ago

Best Answer

// 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

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is tic tac toe 2.0?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is a slogan for tic tac toe?

It's Not Just A Mint, It's A Tic-Tac


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


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


Is tic tac toe copyrighted?

Of Course Not!!


Who invented the game Tic-Tac-Toe?

ME!!


What is tic tac on toast?

You may be referring to a cooking utensil you can purchase. It's a sort of tic-tac-toe stamp you press into the bread before toasting it. Then you can play tic-tac-toe with butter, jelly, etc. at breakfast.


What do you call the winner of tic-tac-toe?

ooo


What are the release dates for 3-D Tic-Tac-Toe - 1975 VG?

3-D Tic-Tac-Toe - 1975 VG was released on: USA: 1975