Nyeh
This commit is contained in:
parent
d874a13d99
commit
6a867cd780
2 changed files with 10 additions and 8 deletions
12
Board.cpp
12
Board.cpp
|
@ -242,23 +242,23 @@ bool Board::isThisMovePossible(int r, int c, string moveType){
|
||||||
|
|
||||||
if (moveType == "FWD"){
|
if (moveType == "FWD"){
|
||||||
if (isPiece(r+reflector, c))
|
if (isPiece(r+reflector, c))
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (moveType == "RIGHT"){
|
else if (moveType == "RIGHT"){
|
||||||
if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 <= 7))
|
if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 <= 7))
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (moveType == "LEFT"){
|
else if (moveType == "LEFT"){
|
||||||
if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 >= 0))
|
if (isPiece(r+reflector, c+1) && (r+reflector >= 0) && (r+reflector <= 7) && (c+1 >= 0))
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else return false;
|
else return false;
|
||||||
|
|
|
@ -104,7 +104,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
b.displayBoard();//Display the board on the server
|
b.displayBoard();//Display the board on the server
|
||||||
string boardState = b.boardToString();
|
string boardState = b.boardToString();
|
||||||
final_move = b.boardToString();
|
//final_move = b.boardToString();
|
||||||
write(newsockfd, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
|
write(newsockfd, boardState.c_str(), boardState.length());//Display the board to the client (line by line)
|
||||||
cout<<"\nWaiting for client: ";
|
cout<<"\nWaiting for client: ";
|
||||||
n = read(newsockfd,buffer,255);
|
n = read(newsockfd,buffer,255);
|
||||||
|
@ -126,14 +126,16 @@ int main(int argc, char *argv[])
|
||||||
b.easyAI();
|
b.easyAI();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
string final_move = b.boardToString();
|
string final_move = b.boardToString();
|
||||||
write(newsockfd, final_move.c_str(), final_move.length());//Display the board to the client (line by line)
|
write(newsockfd, final_move.c_str(), final_move.length());//Display the board to the client (line by line)
|
||||||
write(newsockfd, final_move.c_str(), final_move.length());
|
write(newsockfd, final_move.c_str(), final_move.length());
|
||||||
cout << "\n\nGAME OVER!!!";
|
cout << "\n\nGAME OVER!!!";
|
||||||
usleep(1);
|
usleep(1);
|
||||||
|
*/
|
||||||
close(newsockfd);
|
close(newsockfd);
|
||||||
close(sockfd);
|
close(sockfd);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Reference in a new issue