// 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";
}
}
It's Not Just A Mint, It's A Tic-Tac
We also call it tic tac toe!
Kyper - Tic Tac Toe D Cole - Tic Tac toe still looking for a 3rd for a hiphop dance
The game Tic Tac Toe is originally from ancient Egypt. http://theeasyanswers.com
9 Squares in Tic Tac Toe
O = tic, X = tac, a line aka win = toe
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
Of Course Not!!
ME!!
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.
ooo
3-D Tic-Tac-Toe - 1975 VG was released on: USA: 1975