working on AI

This commit is contained in:
Rebecca Schofield 2015-10-20 19:01:30 -05:00
parent 67c3b463db
commit c9ab7c2622
4 changed files with 16 additions and 25 deletions

View file

@ -87,8 +87,7 @@ void Board::changeTurns()
}
void Board::displayBoard()
{
cout<<"\n\n";
{
cout<<"; A B C D E F G H"<<endl;
for (int i = 0; i < 8; ++i)
{
@ -466,15 +465,6 @@ string Board::myToUpper(string input)
}
void Board::displayPossibleMoves(vector<moves> input)
{
cout<<"\n\nList of possible Moves:"<<endl;
for (int i = 0; i < input.size(); ++i)
{
cout<<"possible move: "<<input[i].row<<" "<<input[i].column<<" "<<input[i].moveType<<endl;
}
}
void Board::undo(Board& tablero)
{
vector<Board> record;
@ -545,17 +535,19 @@ void Board::easyAI()
vector<moves> listOfMoves = viewPossibleMoves();
//2) pick a movement
srand(time(NULL));
int randomChoice = rand() % (listOfMoves.size()-1) - 0; // choose a move betwen listOfMoves[0] to last element
//3) execute movement
int temp = randomChoice;
move(listOfMoves[randomChoice]);
//cout<<"\n\nMove executed by AI: "<<listOfMoves[temp].column<<" "<<listOfMoves[temp].row<<" "<<listOfMoves[temp].moveType<<endl; uncomment for debugging purposes
//obvious moves
if (){
//
}
//random
else {
srand(time(NULL));
int randomChoice = rand() % (listOfMoves.size()-1) - 0; // choose a move betwen listOfMoves[0] to last element
//3) execute movement
int temp = randomChoice;
move(listOfMoves[randomChoice]);
}
}

View file

@ -37,7 +37,6 @@ public:
bool isThisMovePossible(int r, int c, string moveType);
vector<moves> viewPossibleMoves();
string myToUpper(string input);
void displayPossibleMoves(vector<moves> input);
void undo(Board& tablero);
void interpret(string input, Board& tablero);
void snapshot(vector<Board>& inputVec, Board inputBoard);

BIN
a.out

Binary file not shown.

View file

@ -40,7 +40,6 @@ int main()
vector<moves> possibleMoves = b.viewPossibleMoves();
//displayPossibleMoves(possibleMoves); for debugging purposes - AI
if (choice == 1)
{
@ -53,6 +52,7 @@ int main()
{
b.displayBoard();
cout<<"\nEnter command: ";
cout<<"OK\n";
cin>>move;
b.interpret(move,b);
}