Update main.cpp

This commit is contained in:
William Bracho Blok 2015-10-17 19:18:47 -05:00
parent cdee60611e
commit 406547118b

View file

@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <vector> #include <vector>
#include <stdlib.h> #include <stdlib.h>
#include <stdlib.h> #include <stdio.h>
using namespace std; using namespace std;
@ -31,6 +31,35 @@ using namespace std;
// } // }
// }; // };
string myToUpper(string input)
{
string output;
for (int i = 0 ; i < input.size(); ++i)
{
int numeric;
if ((input[i] - 0 >= 97) && (input[i] - 0 <= 122))
{
numeric = input[i] - 32;
output.push_back((char)numeric);// = 'Q';//(char) numeric;
}
else output.push_back(input[i]);
}
for (int i = 0; i < output.size(); ++i)
{
cout<<output[i]<<endl;
}
return output;
}
struct moves struct moves
{ {
int row; int row;
@ -49,7 +78,6 @@ class Board
{ {
char boardArray [8][8]; char boardArray [8][8];
char turn = 'O'; char turn = 'O';
//bool winOrLose;
public: public:
@ -81,13 +109,17 @@ class Board
} }
} }
// winOrLose = false;
} }
moves parse(string input) //needs to be idiot proof moves parse(string input)
{ {
input = myToUpper(input);
cout<<input<<endl;
int temp1; int temp1;
char temp2; char temp2;
string temp3; string temp3;
@ -323,7 +355,6 @@ class Board
cout<<"Invalid piece!"<<endl; cout<<"Invalid piece!"<<endl;
} }
// isGameOver();
} }
@ -435,7 +466,6 @@ class Board
cout<<"Invalid piece!"<<endl; cout<<"Invalid piece!"<<endl;
} }
// isGameOver();
} }
@ -521,7 +551,7 @@ class Board
} }
void dumbassAI() void easyAI()
{ {
//1) see all possible movements //1) see all possible movements
@ -539,7 +569,7 @@ class Board
move(listOfMoves[randomChoice]); move(listOfMoves[randomChoice]);
cout<<"\n\nMove executed by AI: "<<listOfMoves[temp].column<<" "<<listOfMoves[temp].row<<" "<<listOfMoves[temp].moveType<<endl; //cout<<"\n\nMove executed by AI: "<<listOfMoves[temp].column<<" "<<listOfMoves[temp].row<<" "<<listOfMoves[temp].moveType<<endl; uncomment for debugging purposes
} }
@ -564,7 +594,6 @@ int main()
cout<<"playing with AI..."<<endl; cout<<"playing with AI..."<<endl;
Board b; Board b;
//b.displayBoard();
string move; string move;
@ -584,10 +613,10 @@ int main()
vector<moves> possibleMoves = b.viewPossibleMoves(); vector<moves> possibleMoves = b.viewPossibleMoves();
//displayPossibleMoves(possibleMoves); //displayPossibleMoves(possibleMoves); for debugging purposes - AI
b.dumbassAI(); b.easyAI();
gameOver = b.isGameOver(); gameOver = b.isGameOver();
} }