Skip to content
Permalink
2c8cede8d9
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
79 lines (68 sloc) 1.49 KB
#include "AI.h"
AI::AI()
{
// Constructor
void AI::setTargetGrid(Grid *grid)
{
gridPtr = grid;
}
void AI::aiTurn()
{
// Calls the correct AI move for the selected difficulty
if(difficulty == Impossible)
{
impossibleAITurn();
}
else
{
normalAITurn();
}
}
void AI::normalAITurn()
{
// AI logic for normal difficulty
}
void AI::impossibleAITurn()
{
// AI logic for impossible difficulty
}
char AI::getSymbol()
{
// Returns the symbol the AI player is using
return this->symbol;
}
void AI::setSymbol(char playerSymbol)
{
// Sets the AI symbol to the opposite of the player's
if(playerSymbol == 'O')
{
symbol = 'X';
}
else
{
symbol = 'O';
}
}
void AI::setDifficulty()
{
// ALlows the player to choose the difficulty and sets values accordingly
int choice = 0;
std::cout << "There are two difficulties to choose from, which would you like?" << std::endl;
std::cout << " 1 - Normal\n 2 - Impossible\n" << std::endl;
std::cin >> choice;
switch(choice)
{
case 1:
difficulty = Normal;
std::cout << "\nNormal difficulty has been selected" << std::endl;
break;
case 2:
difficulty = Impossible;
std::cout << "\nImpossible difficulty has been selected" << std::endl;
break;
default:
difficulty = Normal;
std::cout << "\nInvalid option, defaulting to Normal difficulty" << std::endl;
break;
}
}