Ejemplo n.º 1
0
/*pass this the color of the piece on-move
  returns score for that color*/
int states::eval(char color){
    square piecesB[10];
    square piecesW[10];
    int countB = findPieces('B',piecesB);
    int countW = findPieces('W',piecesW);
    int totalB, totalW;

    #ifdef LEARN
    if(color == 'B'){
       totalB = addPieces(countB,piecesB);
       totalW = addPieces(countW,piecesW);
    }
    else{
       totalB = addLearnPieces(countB,piecesB);
       totalW = addLearnPieces(countW,piecesW);
    }
    #endif

    #ifndef LEARN
       totalB = addPieces(countB,piecesB);
       totalW = addPieces(countW,piecesW);
    #endif

    int score;
    if(color == 'W')
	 score = totalW - totalB;
    else
	 score = totalB - totalW;
//	cout<< "score " << score << '\n';
    return score; 
}
Ejemplo n.º 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;
}
Ejemplo n.º 3
0
QImage ImageProcessor::proceed(int Debug) {

  DebugMode=Debug;

  std::vector<std::vector<PieceSquare> >
      ChessDesk(8,std::vector<PieceSquare>(8));

  for(int i=0;i<8;i++) {
    for(int j=0;j<8;j++) {
      ChessDesk[i][j].Type=0;
      ChessDesk[i][j].Color=0;
      ChessDesk[i][j].IsAttacked=0;
    }
  }

  ChessArea=findDesk();
  drawRect(ChessArea);

  findPieces(ChessDesk);

  return *image;
}