Пример #1
0
void ROOK::legalMoves
  (
    POSITION start,
    const BOARD &board,
    POSITIONLIST &moves
  ) const
  {
    moves.nMoves = 0;
    rookMoves(start.row, start.col, board, moves);

    return;
  }
Пример #2
0
//moves should be 290 slots, this function collects all possible moves for a color
int states::moveGen(char color, move *moves){
    int movesIndex = 0;
    //move moves[290];
    square pieces[10];
    //k = number of slots filled in pieces array
    int k = findPieces(color,pieces);
    for(int i = 0; i < k; ++i){
    switch(board[pieces[i].x][pieces[i].y]){
	case 'k':
	case 'K':
	    kingMoves(pieces[i].x, pieces[i].y, moves, movesIndex, color );
	    break;
	case 'q':
	case 'Q':
	    queenMoves(pieces[i].x, pieces[i].y, moves, movesIndex, color);
	    break;
	case 'r':
	case 'R':
	    rookMoves(pieces[i].x, pieces[i].y, moves, movesIndex, color);
	    break;
	case 'b':
	case 'B':
	    bishopMoves(pieces[i].x, pieces[i].y, moves, movesIndex, color);
	    break;
	case 'n':
	case 'N':
	    knightMoves(pieces[i].x, pieces[i].y, moves, movesIndex, color);
	    break;
	case 'P':
	    wPawnMoves(pieces[i].x, pieces[i].y, moves, movesIndex);
	    break;
	case 'p':
	    bPawnMoves(pieces[i].x, pieces[i].y, moves, movesIndex);
	    break;
        default:
	    cout<< "259 non-valid piece in pieces[i], states.cpp";
    }

    }
    return movesIndex;
}