I posted earlier and i dint get a reply, i think because of the amount of code i put up, im getting a seg error after the first loop runs for the fifth time, if anyone could help it would be great. Also im trying to find borland turbo debugger (td32.exe) and i cant find nowhere to download it from, if anyone knows that would help too. Thanks
Code:
for(int i=0; i<player1->getNDraughts(); i++){
std::cout << "loop"<<endl;
Draught * d1 = player1->getDraught(i);
Square * d1s = d1->getSquare();
for(int j=0; j<player2->getNDraughts(); j++){
Draught * d2 = player2->getDraught(j);
if(d1s->getY() == 0 || d1s->getY() == 1){
Square * s = board->getSquare(d1s->getX()+1, d1s->getY() +1); // getting squares for top right
Square * o = board->getSquare(d1s->getX()+2, d1s->getY() +2);
Square * s1 = board->getSquare(d1s->getX()-1, d1s->getY() +1); // getting squares for bottom right
Square * o1 = board->getSquare(d1s->getX()-2, d1s->getY() +2);
if ((d2->getSquare() == s) && !o->isOccupied()){ // checking if top right square is occupied
fm = true;
}
if ((d2->getSquare() == s1) && !o1->isOccupied()){ // checking if bottom right square is occupied
fm = true;
}
}
else if (sq1->getY() == 6 || sq1->getY() == 7){
Square * s = board->getSquare(d1s->getX()+1, d1s->getY()-1); // getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()+2, d1s->getY()-2);
Square * s1 = board->getSquare(d1s->getX()-1, d1s->getY() -1); // getting squares for bottom left
Square * o1 = board->getSquare(d1s->getX()-2, d1s->getY() -2);
if ((d2->getSquare() == s) && !o->isOccupied()){ // checking if top right square is occupied
fm = true;
}
if ((d2->getSquare() == s1) && !o1->isOccupied()){ // checking if bottom right square is occupied
fm = true;
}
}
else { //rest of squares on the row
Square * s = board->getSquare(d1s->getX()+1, d1s->getY()-1); // getting squares for top left focred move
Square * o = board->getSquare(d1s->getX()+2, d1s->getY()-2);
Square * s1 = board->getSquare(d1s->getX()+1, d1s->getY() +1); // getting squares for top right
Square * o1 = board->getSquare(d1s->getX()+2, d1s->getY() +2);
Square * s2 = board->getSquare(d1s->getX()-1, d1s->getY() -1); // getting squares for bottom left
Square * o2 = board->getSquare(d1s->getX()-2, d1s->getY() -2);
Square * s3 = board->getSquare(d1s->getX()-1, d1s->getY() +1); // getting squares for bottom right
Square * o3 = board->getSquare(d1s->getX()-2, d1s->getY() +2);
if ((d2->getSquare() == s) && !o->isOccupied()){ // checking if top left square is occupied
fm = true;
}
if ((d2->getSquare() == s1) && !o1->isOccupied()){ // checking if top right square is occupied
fm = true;
}
if (current->isKing()){
if ((d2->getSquare() == s2) && !o2->isOccupied()){ // checking if bottom left square is occupied
fm = true;
}
}
if (current->isKing()){
if ((d2->getSquare() == s3) && !o3->isOccupied()){ // checking if bottom right square is occupied
fm = true;
}
}
}
}
if (fm) {
forcedMovesp1.push_back(i);
}
}