Crafty 23.1 JE (Joshua Edition v1.11) changes

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by jhaglund »

Here are some changes I made to Crafty.

Code: Select all

//Crafty 23.1 JE (v 1.11)

// changes to chess.h

#  define BISHOP_VALUE                           340

#  define QUEEN_VALUE                            985

#  define LEARN_INTERVAL                          1

// changes to data.c

int lazy_eval_cutoff = 165;

int razor_margin = 165;

int bishop_pair[2] = {50, 50};

int bishop_trapped = 100;

// changes to evaluate.c



/*
 ************************************************************
 * 
 *
 *   removed knight_outpost code                            *
 *  
 *
 ************************************************************
 */
 

//   if (!(mask_no_pattacks[enemy][square] & Pawns(enemy))) {
 
//     if (knight_outpost[side][square]) {
 
//       score_eg += knight_outpost[side][square];
 
//       score_mg += knight_outpost[side][square];
 
//       if (knight_outpost[side][square] &&
 
//           pawn_attacks[enemy][square] & Pawns(side)) {
 
//         score_eg += knight_outpost[side][square] / 2;
 
//         score_mg += knight_outpost[side][square] / 2;
 
//         if (!Knights(enemy) && !(Color(square) & Bishops(enemy))) {
 
//           score_eg += knight_outpost[side][square];

//           score_mg += knight_outpost[side][square];
 
//         }

//       }
 
//     }
 
//   }



/*
 ************************************************************
 * 
 *
 *   Check for trapped bishops                           *
 *  
 *
 ************************************************************
 */
 

   else { 
        if (square == sqflip[side][A7]) { 
          if (SetMask(sqflip[side][B6]) & Pawns(enemy)) { 
            score_eg -= bishop_trapped; 
            score_mg -= bishop_trapped; 
          } 
          if (square == sqflip[side][H7]) { 
        } else if (SetMask(sqflip[side][G6]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][B8]) { 
        }else if (SetMask(sqflip[side][C7]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][G8]) { 
        }else if (SetMask(sqflip[side][F7]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][A2]) { 
        }else if (SetMask(sqflip[side][B3]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][H2]) { 
        }else if (SetMask(sqflip[side][G3]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
               if (square == sqflip[side][B1]) { 
        }else if (SetMask(sqflip[side][C2]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
                if (square == sqflip[side][G1]) { 
        }else if (SetMask(sqflip[side][F2]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
            if (square == sqflip[side][A6]) { 
        }else if (SetMask(sqflip[side][B5]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
           if (square == sqflip[side][H6]) { 
        }else if (SetMask(sqflip[side][G5]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
                if (square == sqflip[side][A3]) { 
        }else if (SetMask(sqflip[side][B4]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
                if (square == sqflip[side][H3]) { 
        }else if (SetMask(sqflip[side][G4]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
        } 
      } 
    }


/*
 ************************************************************
 * 
 *
 *   Check for an undeveloped knight or bishop / rook combo *
 *  
 *
 ************************************************************
 */
 
  if (PcOnSq(sqflip[side][B1]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][A1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][G1]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][H1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 

  if (PcOnSq(sqflip[side][B8]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][A8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][G8]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece;    
  
   if (PcOnSq(sqflip[side][C1]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][A1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][C8]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
    
  if (PcOnSq(sqflip[side][F1]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][F8]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece;
  tree->score_mg += sign[side] * score_mg;

}


/*
 ************************************************************
 *
*
 *   Don't add in the piece/square table value for the queen *
 * 
************************************************************
*/

//    score_mg += qval[mg][side][square];

//    score_eg += qval[eg][side][square];
Joshua D. Haglund

P.S... add position(.lrn) learning back ^.^
User avatar
beachknight
Posts: 3533
Joined: Tue Jan 09, 2007 8:33 pm
Location: Antalya, Turkey

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by beachknight »

Interesting changes.

Could it be compiled as soon as your changes are completed?

Best,
hi, merhaba, hallo HT
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by jhaglund »

Interesting changes.

Could it be compiled as soon as your changes are completed?

Best,
You'd have to find someone to apply the changes for a fast compile.
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by bob »

jhaglund wrote:Here are some changes I made to Crafty.

Code: Select all

//Crafty 23.1 JE (v 1.11)

// changes to chess.h

#  define BISHOP_VALUE                           340

#  define QUEEN_VALUE                            985

#  define LEARN_INTERVAL                          1

// changes to data.c

int lazy_eval_cutoff = 165;

int razor_margin = 165;

int bishop_pair[2] = {50, 50};

int bishop_trapped = 100;

// changes to evaluate.c



/*
 ************************************************************
 * 
 *
 *   removed knight_outpost code                            *
 *  
 *
 ************************************************************
 */
 

//   if (!(mask_no_pattacks[enemy][square] & Pawns(enemy))) {
 
//     if (knight_outpost[side][square]) {
 
//       score_eg += knight_outpost[side][square];
 
//       score_mg += knight_outpost[side][square];
 
//       if (knight_outpost[side][square] &&
 
//           pawn_attacks[enemy][square] & Pawns(side)) {
 
//         score_eg += knight_outpost[side][square] / 2;
 
//         score_mg += knight_outpost[side][square] / 2;
 
//         if (!Knights(enemy) && !(Color(square) & Bishops(enemy))) {
 
//           score_eg += knight_outpost[side][square];

//           score_mg += knight_outpost[side][square];
 
//         }

//       }
 
//     }
 
//   }



/*
 ************************************************************
 * 
 *
 *   Check for trapped bishops                           *
 *  
 *
 ************************************************************
 */
 

   else { 
        if (square == sqflip[side][A7]) { 
          if (SetMask(sqflip[side][B6]) & Pawns(enemy)) { 
            score_eg -= bishop_trapped; 
            score_mg -= bishop_trapped; 
          } 
          if (square == sqflip[side][H7]) { 
        } else if (SetMask(sqflip[side][G6]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][B8]) { 
        }else if (SetMask(sqflip[side][C7]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][G8]) { 
        }else if (SetMask(sqflip[side][F7]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][A2]) { 
        }else if (SetMask(sqflip[side][B3]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
        if (square == sqflip[side][H2]) { 
        }else if (SetMask(sqflip[side][G3]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
               if (square == sqflip[side][B1]) { 
        }else if (SetMask(sqflip[side][C2]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
                if (square == sqflip[side][G1]) { 
        }else if (SetMask(sqflip[side][F2]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped; 
          score_mg -= bishop_trapped; 
        } 
            if (square == sqflip[side][A6]) { 
        }else if (SetMask(sqflip[side][B5]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
           if (square == sqflip[side][H6]) { 
        }else if (SetMask(sqflip[side][G5]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
                if (square == sqflip[side][A3]) { 
        }else if (SetMask(sqflip[side][B4]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
                if (square == sqflip[side][H3]) { 
        }else if (SetMask(sqflip[side][G4]) & Pawns(enemy)) { 
          score_eg -= bishop_trapped / 2; 
          score_mg -= bishop_trapped / 2; 
        } 
        } 
      } 
    }


/*
 ************************************************************
 * 
 *
 *   Check for an undeveloped knight or bishop / rook combo *
 *  
 *
 ************************************************************
 */
 
  if (PcOnSq(sqflip[side][B1]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][A1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][G1]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][H1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 

  if (PcOnSq(sqflip[side][B8]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][A8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][G8]) == pieces[side][knight] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece;    
  
   if (PcOnSq(sqflip[side][C1]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][A1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][C8]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
    
  if (PcOnSq(sqflip[side][F1]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H1]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece; 
  if (PcOnSq(sqflip[side][F8]) == pieces[side][bishop] && 
      PcOnSq(sqflip[side][H8]) == pieces[side][rook]) 
    score_mg -= undeveloped_piece;
  tree->score_mg += sign[side] * score_mg;

}


/*
 ************************************************************
 *
*
 *   Don't add in the piece/square table value for the queen *
 * 
************************************************************
*/

//    score_mg += qval[mg][side][square];

//    score_eg += qval[eg][side][square];
Joshua D. Haglund

P.S... add position(.lrn) learning back ^.^
Just for the record, all the eval/piece value changes are _guaranteed_ to hurt Crafty's play. Those values have been fine-tuned on the cluster playing tens of millions of games. I can certainly make a cluster run if you want to see the effect...
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by jhaglund »

Hello Bob,

I wouldn't mind a test at all, but you'd have to include all the other changes listed. If you'd do a combination of the changes also, if you have extra free time. :)

The test position file (.epd) I was working on was lost. I'd have to start over completely. It's on the back burner, since I had 12+ hours invested, in hand-creating the positions.
Just for the record, all the eval/piece value changes are _guaranteed_ to hurt Crafty's play. Those values have been fine-tuned on the cluster playing tens of millions of games. I can certainly make a cluster run if you want to see the effect...
User avatar
Zach Wegner
Posts: 1922
Joined: Thu Mar 09, 2006 12:51 am
Location: Earth

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by Zach Wegner »

bob wrote:Just for the record, all the eval/piece value changes are _guaranteed_ to hurt Crafty's play. Those values have been fine-tuned on the cluster playing tens of millions of games. I can certainly make a cluster run if you want to see the effect...
Are you saying that your evaluation is perfectly tuned?
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by bob »

Zach Wegner wrote:
bob wrote:Just for the record, all the eval/piece value changes are _guaranteed_ to hurt Crafty's play. Those values have been fine-tuned on the cluster playing tens of millions of games. I can certainly make a cluster run if you want to see the effect...
Are you saying that your evaluation is perfectly tuned?
No. I am saying the terms he was modifying (except for the new things he added) are perfectly tuned. We ran millions of games to choose optimal material values. Ditto for the outpost knight scoring, etc...
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by bob »

jhaglund wrote:Hello Bob,

I wouldn't mind a test at all, but you'd have to include all the other changes listed. If you'd do a combination of the changes also, if you have extra free time. :)

The test position file (.epd) I was working on was lost. I'd have to start over completely. It's on the back burner, since I had 12+ hours invested, in hand-creating the positions.
Just for the record, all the eval/piece value changes are _guaranteed_ to hurt Crafty's play. Those values have been fine-tuned on the cluster playing tens of millions of games. I can certainly make a cluster run if you want to see the effect...
Can you email me a .zip or .tar or whatever (not .rar) of the modified source? I'll run it tomorrow...
jhaglund
Posts: 173
Joined: Sun May 11, 2008 7:43 am

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by jhaglund »

Can you email me a .zip or .tar or whatever (not .rar) of the modified source? I'll run it tomorrow...
Sent-> craftyje.zip

I'll look for the results here...

Thanks
bob
Posts: 20943
Joined: Mon Feb 27, 2006 7:30 pm
Location: Birmingham, AL

Re: Crafty 23.1 JE (Joshua Edition v1.11) changes

Post by bob »

jhaglund wrote:
Can you email me a .zip or .tar or whatever (not .rar) of the modified source? I'll run it tomorrow...
Sent-> craftyje.zip

I'll look for the results here...

Thanks
It will likely be a couple of days. Our computer room A/C has once again died, and all three clusters are down, as well as many server machines. We apparently peaked at over 140F in the machine room early this morning, which is scorching hot.

No ETA yet on repairs, we are waiting on them to tell us what has failed.