working on AI junk
This commit is contained in:
parent
dc544a609b
commit
6fe1b333fd
2 changed files with 18 additions and 26 deletions
41
Engine.cpp
41
Engine.cpp
|
@ -18,7 +18,7 @@ void Engine::startGame(){
|
|||
//cout<<"CHANGE THIS TO PARSE THINGS\n";
|
||||
cout<<"Enter choice: \n";
|
||||
|
||||
int choice;
|
||||
int choice = -1;
|
||||
cin >> choice;
|
||||
cout << "OK" << endl;
|
||||
|
||||
|
@ -38,30 +38,13 @@ void Engine::startGame(){
|
|||
cout<<"\nEnter command: ";
|
||||
cin>>move;
|
||||
b->interpret(move, *b);
|
||||
}
|
||||
|
||||
|
||||
vector<moves> possibleMoves = b->viewPossibleMoves();
|
||||
|
||||
if (choice == 1)
|
||||
{
|
||||
cout << "easyAI";
|
||||
easyAI();
|
||||
}
|
||||
|
||||
else
|
||||
while(b->getTurn() == 'X' )
|
||||
{
|
||||
while(b->getTurn() == 'X' )
|
||||
{
|
||||
b->displayBoard();
|
||||
cout<<"\nEnter command: ";
|
||||
cout<<"OK\n";
|
||||
cin>>move;
|
||||
b->interpret(move, *b);
|
||||
}
|
||||
AI();
|
||||
}
|
||||
|
||||
//b->snapshot();
|
||||
gameOver = b->isGameOver();
|
||||
|
||||
b->snapshot(record, *b);
|
||||
|
@ -81,12 +64,11 @@ void Engine::startGame(){
|
|||
void Engine::easyAI()
|
||||
{
|
||||
//1) see all possible movements
|
||||
|
||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||
|
||||
//obvious moves
|
||||
if (false){
|
||||
return;
|
||||
b->changeTurns();
|
||||
}
|
||||
|
||||
//random
|
||||
|
@ -96,13 +78,22 @@ void Engine::easyAI()
|
|||
|
||||
//3) execute movement
|
||||
int temp = randomChoice;
|
||||
|
||||
move(listOfMoves[randomChoice]);
|
||||
b->move(listOfMoves[randomChoice]);
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::AI(){
|
||||
//do things here
|
||||
vector<moves> listOfMoves = b->viewPossibleMoves();
|
||||
|
||||
cout << "rows: \n\n";
|
||||
for (int i = 0; i < listOfMoves.size(); ++i){
|
||||
cout << "i: " << listOfMoves[i].row << "\n";
|
||||
}
|
||||
|
||||
cout << "columns: \n\n";
|
||||
for (int i = 0; i < listOfMoves.size(); ++i){
|
||||
cout << "i: " << listOfMoves[i].column << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
void Engine::minMax(){
|
||||
|
|
3
test.cpp
3
test.cpp
|
@ -4,5 +4,6 @@ using namespace std;
|
|||
|
||||
int main()
|
||||
{
|
||||
//
|
||||
Engine e;
|
||||
e.startGame();
|
||||
}
|
||||
|
|
Reference in a new issue