Skip to content

Commit

Permalink
Heavily improving evaluation function
Browse files Browse the repository at this point in the history
The evaluation is heavily improved in this commit. Ideas come from the internal Scid engine.

With opening book : +70 Elo
Without opening book : +120 Elo
  • Loading branch information
PaulJeFi committed Jun 1, 2024
1 parent 98811a3 commit c30cdf2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ It currently has the following features :
- [material balance](https://www.chessprogramming.org/Material)
- [tapered eval](https://www.chessprogramming.org/Tapered_Eval)
- [Mop-up evaluation](https://www.chessprogramming.org/Mop-up_Evaluation)
- [Trapped bisops](https://www.chessprogramming.org/Trapped_Pieces)
- [Minor pieces development](https://www.chessprogramming.org/Development)
- [Center control](https://www.chessprogramming.org/Center_Control) : [Pawn center](https://www.chessprogramming.org/Pawn_Center)
- [Unadvanced central pawns](https://www.chessprogramming.org/Development#Eval_Considerations)
- [space control eval](https://www.chessprogramming.org/Space) _to be readded_
- [bishop pair](https://www.chessprogramming.org/Bishop_Pair) _to be readded_
- [Search](https://www.chessprogramming.org/Search)
Expand Down
34 changes: 34 additions & 0 deletions src/JavaScript/reglisse.js
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,7 @@ function evaluate(board) {
gamePhase = 0,
piece = 0;

// PSQT + material
for (var sq=0; sq<64; sq++) {
piece = board.board[mailbox64[sq]];
if (piece != EMPTY) {
Expand All @@ -1725,6 +1726,39 @@ function evaluate(board) {
};
};

// Minor pieces developed
if (board.board[92] != (WHITE | KNIGHT)) { mg[0] += 8; };
if (board.board[93] != (WHITE | BISHOP)) { mg[0] += 8; };
if (board.board[96] != (WHITE | BISHOP)) { mg[0] += 8; };
if (board.board[97] != (WHITE | KNIGHT)) { mg[0] += 8; };
if (board.board[22] != (BLACK | KNIGHT)) { mg[1] += 8; };
if (board.board[23] != (BLACK | BISHOP)) { mg[1] += 8; };
if (board.board[26] != (BLACK | BISHOP)) { mg[1] += 8; };
if (board.board[27] != (BLACK | KNIGHT)) { mg[1] += 8; };

// Trapped bishop
if (board.board[31] == (WHITE | BISHOP) && board.board[42] == (BLACK | PAWN)) { mg[0] -= 120; };
if (board.board[38] == (WHITE | BISHOP) && board.board[47] == (BLACK | PAWN)) { mg[0] -= 120; };
if (board.board[81] == (BLACK | BISHOP) && board.board[72] == (WHITE | PAWN)) { eg[1] -= 120; };
if (board.board[88] == (BLACK | BISHOP) && board.board[77] == (WHITE | PAWN)) { eg[1] -= 120; };

// Central pawn control
if ((board.board[64] == (WHITE | PAWN) || board.board[54] == (WHITE | PAWN)) &&
(board.board[65] == (WHITE | PAWN) || board.board[55] == (WHITE | PAWN))) {
mg[0] += 15;
};
if ((board.board[64] == (BLACK | PAWN) || board.board[54] == (BLACK | PAWN)) &&
(board.board[65] == (BLACK | PAWN) || board.board[55] == (BLACK | PAWN))) {
mg[1] += 15;
};

// Undevelopped central pawn
if (board.board[84] == (WHITE | PAWN) && board.board[74] != EMPTY) { mg[0] -= 15; };
if (board.board[85] == (WHITE | PAWN) && board.board[75] != EMPTY) { mg[0] -= 15; };
if (board.board[34] == (BLACK | PAWN) && board.board[44] != EMPTY) { mg[1] -= 15; };
if (board.board[35] == (BLACK | PAWN) && board.board[45] != EMPTY) { mg[1] -= 15; };


var side2move = board.turn ? 0 : 1;

var mgScore = mg[side2move] - mg[side2move ^ 1],
Expand Down

0 comments on commit c30cdf2

Please sign in to comment.