COM OOONNNN

This commit is contained in:
Alexander Huddleston 2015-11-04 00:20:53 -06:00
commit 6cabd5aceb
6 changed files with 39 additions and 22 deletions

View file

@ -243,7 +243,6 @@ Board Board::move(moves m){
}
else if (m.moveType == "LEFT") {
//add error checking
if(piece->getType() == 'O') {
row--;
column--;
@ -490,7 +489,6 @@ int Board::evaluate(char max, char min){
val = val - 10;
}
//cout << "val: " << val << "\n";
return val;
}

View file

@ -13,11 +13,9 @@ Engine::Engine(){
b = brd;
alpha = INT_MIN;
beta = INT_MAX;
undo_cnt = 0;
}
void Engine::startGame(){
undo_cnt = 0;
cout<<"WELCOME\n";
cout<<"1. Play against AI?\n";

View file

@ -8,7 +8,7 @@ using namespace std;
class Engine {
Board* b;
int alpha, beta, undo_cnt;
int alpha, beta;
public:
Engine();

View file

@ -3,8 +3,6 @@
#include "Engine.h"
#include "Board.h"
//using namespace std;
string myToUpper(string input);
void parseAndMove(vector<string> tokens, Board& board);
void parseCmd(vector<string> tokens, Board& board);

View file

@ -7,9 +7,6 @@ Repository for the second CSCE 315 project
***NOTE***
To remove all .class and .o files, just use: make clean.
# To run test:
./test
# To launch the server:
./server [port #]
@ -18,12 +15,19 @@ Java Client is now functional with GUI.
# To launch the client:
java Client [server address] [port #]
Where [server address] is linux.cs.tamu.edu (or whatever server you're on) and [port #] is the same as server's [port #].
# Running the client:
- Once the server is running, join via client.
- Enter the password to access the server
- Select a game type
- Select a difficulty (if it's Client vs. AI)
- Play the game by clicking a piece and then clicking a valid spot to place that piece
- Upon game completion, the board interface will close, inform the client the game is over, and end the program
# Troubleshooting:
- Make sure you enable X11 forwarding in your PuTTY settings before you start your connection to the linux server.
- Make sure you also open XLaunch and just click next until finish so that PuTTY doesn't whine about not having a server to start up the client with.
- You will need to manually enter "1" when you start the client. Haven't gotten around to doing that frame just yet, but mostly because the AI stuff isn't finished yet.
- The GUI takes two moves at a time, to play click the square with the piece you want to move, then the square you want to move it to. Remember there is very minimal error checking on the GUI side, so if you make an incorrect move, the server will just yell at you and the client will continue like nothing happened. I left in some Debugging output on both the Client and Server side so you guys can tell where you messed up. Let me know if you experience any bugs.
- The game will not automatically close on Game Over, you will have to close the window yourself, but that's not exactly a bug, so I'm just going to leave it in.
- The GUI takes two moves at a time, to play click the square with the piece you want to move, then the square you want to move it to.
- Be patient. Swing is very slow and it'll take a second or two for it to initialize the window and a couple seconds to render the icons each time you make a move (depending on if you're using a VPN or not, runs smoothly on campus).

View file

@ -62,7 +62,7 @@ int main(int argc, char *argv[])
if (newsockfd < 0)
error("ERROR on accept");
//After all the server setup crap is done, we start the board
//After all the server setup is done, we start the board
Engine e;
string move;
@ -171,6 +171,7 @@ int main(int argc, char *argv[])
e.getBoard()->displayBoard();//Display the board on the server
string boardState = e.getBoard()->boardToString();
final_move = e.getBoard()->boardToString();
<<<<<<< HEAD
if(choice1 == 1) {
cout<<"\nWaiting for client: ";
n = read(newsockfd,buffer,255);
@ -200,6 +201,21 @@ int main(int argc, char *argv[])
e.AI(77);
//e.getBoard()->changeTurns();
=======
cout<<"\nWaiting for client: ";
n = read(newsockfd,buffer,255);
move = buffer;
bzero(buffer,256);
parse(move,(*e.getBoard()));
if(e.getBoard()->isValid()) {
boardState = e.getBoard()->boardToString();
cout << boardState << "testing\n\n";
write(newsockfd, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
//write(newsockfd2, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
e.getBoard()->changeTurns();
e.getBoard()->setValidFalse();
>>>>>>> master
}
}
@ -221,6 +237,7 @@ int main(int argc, char *argv[])
string boardState = e.getBoard()->boardToString();
final_move = e.getBoard()->boardToString();
write(newsockfd2, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
<<<<<<< HEAD
if(choice2 == 1) {
cout<<"\nWaiting for client: ";
n = read(newsockfd2,buffer,255);
@ -239,6 +256,16 @@ int main(int argc, char *argv[])
}
}
else {
=======
cout<<"\nWaiting for client: ";
n = read(newsockfd2,buffer,255);
move = buffer;
bzero(buffer,256);
parse(move,(*e.getBoard()));
if(e.getBoard()->isValid()) {
boardState = e.getBoard()->boardToString();
>>>>>>> master
write(newsockfd, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
//write(newsockfd2, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
if(choice2_difficulty == "EASY")
@ -280,8 +307,6 @@ int main(int argc, char *argv[])
n = read(newsockfd,buffer,255);
move = buffer;
bzero(buffer,256);
//cout << move << "\n\n";
//move = tempParse(move);
parse(move,(*e.getBoard()));
if(e.getBoard()->isValid()) {
@ -290,12 +315,6 @@ int main(int argc, char *argv[])
}
}
//Debugging
/*
if(e.getBoard()->isValid())
cout << e.getBoard()->getTurn();
*/
while(e.getBoard()->getTurn() == 'X' )
{
if(choice_difficulty == "EASY")