Exemplo n.º 1
0
bool		Arbitrator::blockOk(pawn p, t_position pos){
  pawn		*left = _field->getInter(pos.x - 50, pos.y);
  pawn		*right = _field->getInter(pos.x + 50, pos.y);
  pawn		*up = _field->getInter(pos.x, pos.y - 50);
  pawn		*down = _field->getInter(pos.x, pos.y + 50);

  return (!(left && PAWN((*left), p) &&
	    right && PAWN((*right), p) &&
	    up && PAWN((*up), p) &&
	    down && PAWN((*down), p)));
}
Exemplo n.º 2
0
// put all the pieces for one color at their starting positions on
// the board
LOCAL void setupPieces
  (
    PIECE *board[][NUMCOLS],
    PIECECOLOR color,
    // column in which the non-pawn pieces go
    int backCol,
    // column in which the pawns go
    int pawnCol
  )
  {
    BOOL f = TRUE;
    int row;

    #define NEWPIECE(P, ROWOFFSET, COLOFFSET) \
      f = f && \
          ((board[ROWOFFSET][COLOFFSET] = new P) != (PIECE *) 0);

    NEWPIECE(ROOK(color), 0, backCol);
    NEWPIECE(KNIGHT(color), 1, backCol);
    NEWPIECE(BISHOP(color), 2, backCol);
    NEWPIECE(QUEEN(color), 3, backCol);
    NEWPIECE(KING(color), 4, backCol);
    NEWPIECE(BISHOP(color), 5, backCol);
    NEWPIECE(KNIGHT(color), 6, backCol);
    NEWPIECE(ROOK(color), 7, backCol);

    for (row = 0; row < NUMROWS; row++)
      NEWPIECE(PAWN(color), row, pawnCol);

    if (!f)
      OutOfMemory();

    return;

    #undef NEWPIECE
  }