Hey all,
I'm (still) working on my console-based chess program. I have most of it worked out, but I've run across a problem:
after a few turns, it just exits. (says "Press enter to continue...")
This is weird because the program is just an infinite loop (for(;) with no way for the program to actually exit (I'm lazy and havn't put in a "Quit?" thing yet).
Here is the main cpp file:
Code:
// chess, main program
// last updated 10-24-02
// Will Herrick
#include <iostream>
#include "board.h"
using namespace std;
int main()
{
int a;
int b;
int c;
int d;
int turn;
bool valid;
bool check;
BOARD board;
board.showBoard();
board.setTurn(1); // set white first
for(;;)
{
turn = board.getTurn();
if(turn == 1) cout << "Whites turn, ";
else if(turn == 2) cout << "Blacks turn, ";
cout << "Make your move:" << endl;
cin >> a >> b >> c >> d;
valid = board.Move(a,b,c,d);
if(valid == false)
cout << "Invalid move" << endl;
if(valid == true)
{
board.showBoard();
if(turn == 1) board.setTurn(2);
if(turn == 2) board.setTurn(1);
check = board.isCheck();
if(check == true)
{
cout << "Check!";
}
}
}
return 0;
}
I'm not posting the other bits (board .cpp) because they are long, but I can do so if necessary.
What might be a reason for this oddity?
Thanks!