Does anyone know where in the code of stockfish you can change the piece values. I believe the values are not correct and want to tweak them and compile with new binary?
Thanks
Stockfish Code ( Piece Value's)
Moderator: Ras
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Stockfish Code ( Piece Value's)
types.h (prior to SF2.1 in piece.h)NJDenson wrote:Does anyone know where in the code of stockfish you can change the piece values. I believe the values are not correct and want to tweak them and compile with new binary?
Code: Select all
/*
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
Copyright (C) 2004-2008 Tord Romstad (Glaurung author)
Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad
Stockfish is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Stockfish is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ...
const Value PawnValueMidgame = Value(0x0C6);
const Value PawnValueEndgame = Value(0x102);
const Value KnightValueMidgame = Value(0x331);
const Value KnightValueEndgame = Value(0x34E);
const Value BishopValueMidgame = Value(0x344);
const Value BishopValueEndgame = Value(0x359);
const Value RookValueMidgame = Value(0x4F6);
const Value RookValueEndgame = Value(0x4FE);
const Value QueenValueMidgame = Value(0x9D9);
const Value QueenValueEndgame = Value(0x9FE);
-
- Posts: 2088
- Joined: Wed Jul 13, 2011 9:04 pm
- Location: Madrid, Spain.
Re: StockFish code (piece values) in centipawns?
Hello:
Regards from Spain.
Ajedrecista.
It is very interesting... what are these values in centipawns? Sorry for my lack of knowledge, but I do not know what they mean and even what they are (maybe magic numbers?). Please answer and thanks in advance.Sven Schüle wrote:types.h (prior to SF2.1 in piece.h)NJDenson wrote:Does anyone know where in the code of stockfish you can change the piece values. I believe the values are not correct and want to tweak them and compile with new binary?SvenCode: Select all
/* Stockfish, a UCI chess playing engine derived from Glaurung 2.1 Copyright (C) 2004-2008 Tord Romstad (Glaurung author) Copyright (C) 2008-2012 Marco Costalba, Joona Kiiski, Tord Romstad Stockfish is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Stockfish is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ // ... const Value PawnValueMidgame = Value(0x0C6); const Value PawnValueEndgame = Value(0x102); const Value KnightValueMidgame = Value(0x331); const Value KnightValueEndgame = Value(0x34E); const Value BishopValueMidgame = Value(0x344); const Value BishopValueEndgame = Value(0x359); const Value RookValueMidgame = Value(0x4F6); const Value RookValueEndgame = Value(0x4FE); const Value QueenValueMidgame = Value(0x9D9); const Value QueenValueEndgame = Value(0x9FE);
Regards from Spain.
Ajedrecista.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: StockFish code (piece values) in centipawns?
The values are based on a "pawn unit" being 0x100 (decimal 256), see below.Ajedrecista wrote:It is very interesting... what are these values in centipawns?
Code: Select all
mg
piece hex dec cp
P 0x0c6 198 0,773
N 0x331 817 3,191
B 0x344 836 3,266
R 0x4f6 1270 4,961
Q 0x9d9 2521 9,848
eg
piece hex dec cp
P 0x102 258 1,008
N 0x34e 846 3,305
B 0x359 857 3,348
R 0x4fe 1278 4,992
Q 0x9fe 2558 9,992
-
- Posts: 2088
- Joined: Wed Jul 13, 2011 9:04 pm
- Location: Madrid, Spain.
Thank you very much.
Hello Sven:
Regards from Spain.
Ajedrecista.
Thanks for your fast answer. I tried hexadecimal (the appearance of the values claims for that) and I got these values (198, 817, ...) but I did not know about the standard 0x100 (256) pawn unit. I can understand it now!Sven Schüle wrote:The values are based on a "pawn unit" being 0x100 (decimal 256), see below.Ajedrecista wrote:It is very interesting... what are these values in centipawns?
SvenCode: Select all
mg piece hex dec cp P 0x0c6 198 0,773 N 0x331 817 3,191 B 0x344 836 3,266 R 0x4f6 1270 4,961 Q 0x9d9 2521 9,848 eg piece hex dec cp P 0x102 258 1,008 N 0x34e 846 3,305 B 0x359 857 3,348 R 0x4fe 1278 4,992 Q 0x9fe 2558 9,992
Regards from Spain.
Ajedrecista.
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: Thank you very much.
My tables wrongly use "cp" as column heading although the values are in pawns, not centipawns.Ajedrecista wrote:I tried hexadecimal (the appearance of the values claims for that) and I got these values (198, 817, ...) but I did not know about the standard 0x100 (256) pawn unit.Sven Schüle wrote:The values are based on a "pawn unit" being 0x100 (decimal 256)Ajedrecista wrote:It is very interesting... what are these values in centipawns?
My claim 'are based on a "pawn unit" being 0x100' is of course debatable since only the endgame value of a pawn is close to 0x100. But at least it is clear that the original values have to be divided by 2.56 (or 256 as I did) to get those centipawn values the eyes of most of us are used to see.
Sven
-
- Posts: 75
- Joined: Tue May 23, 2006 7:01 pm
Re: Thank you very much.
Wow, I am still some what lost but here is won I found in code of SF 2.2.1
const Value PawnValueMidgame = Value(0x0C6);
const Value PawnValueEndgame = Value(0x102);
const Value KnightValueMidgame = Value(0x331);
const Value KnightValueEndgame = Value(0x34E);
const Value BishopValueMidgame = Value(0x344);
const Value BishopValueEndgame = Value(0x359);
const Value RookValueMidgame = Value(0x4F6);
const Value RookValueEndgame = Value(0x4FE);
const Value QueenValueMidgame = Value(0x9D9);
const Value QueenValueEndgame = Value(0x9FE);
I believe the values for mid game rook is too low and mid game queen:
Thanks all for info provide thus far.
const Value PawnValueMidgame = Value(0x0C6);
const Value PawnValueEndgame = Value(0x102);
const Value KnightValueMidgame = Value(0x331);
const Value KnightValueEndgame = Value(0x34E);
const Value BishopValueMidgame = Value(0x344);
const Value BishopValueEndgame = Value(0x359);
const Value RookValueMidgame = Value(0x4F6);
const Value RookValueEndgame = Value(0x4FE);
const Value QueenValueMidgame = Value(0x9D9);
const Value QueenValueEndgame = Value(0x9FE);
I believe the values for mid game rook is too low and mid game queen:
Thanks all for info provide thus far.
-
- Posts: 75
- Joined: Tue May 23, 2006 7:01 pm
Re: Thank you very much. ( I got It)
New testing Values:
const Value PawnValueMidgame = Value(0x0C6);
const Value PawnValueEndgame = Value(0x102);
const Value KnightValueMidgame = Value(0x331);
const Value KnightValueEndgame = Value(0x34E);
const Value BishopValueMidgame = Value(0x344);
const Value BishopValueEndgame = Value(0x359);
const Value RookValueMidgame = Value(0x4FB);
const Value RookValueEndgame = Value(0x4FE);
const Value QueenValueMidgame = Value(0x9E7);
const Value QueenValueEndgame = Value(0x9FE);
Thanks Again All
const Value PawnValueMidgame = Value(0x0C6);
const Value PawnValueEndgame = Value(0x102);
const Value KnightValueMidgame = Value(0x331);
const Value KnightValueEndgame = Value(0x34E);
const Value BishopValueMidgame = Value(0x344);
const Value BishopValueEndgame = Value(0x359);
const Value RookValueMidgame = Value(0x4FB);
const Value RookValueEndgame = Value(0x4FE);
const Value QueenValueMidgame = Value(0x9E7);
const Value QueenValueEndgame = Value(0x9FE);
Thanks Again All
-
- Posts: 319
- Joined: Fri Dec 18, 2009 11:40 am
- Location: Naperville, IL
Re: StockFish code (piece values) in centipawns?
If you wish to compare them to displayed scores, PawnValueMidgame = 100 cp. Also, if you run SF directly you can use the "eval" command to see a breakdown of eval factors. (The example below uses it on a real position; in practice, I think eval is more often used on silly positions that arise during search.)Sven Schüle wrote:The values are based on a "pawn unit" being 0x100 (decimal 256), see below.Ajedrecista wrote:It is very interesting... what are these values in centipawns?
Stockfish 120107 64bit SSE4.2 by Tord Romstad, Marco Costalba and Joona Kiiski
position fen r1bq1b1r/ppp3pp/4k3/3np3/1nB5/2N2Q2/PPPP1PPP/R1B1K2R w KQ - 4 9
eval
Code: Select all
Eval term | White | Black | Total
| MG EG | MG EG | MG EG
---------------------+-------------+-------------+---------------
Material, PST, Tempo | --- --- | --- --- | -2.91 -3.15
Material imbalance | --- --- | --- --- | -0.33 -0.33
Pawns | --- --- | --- --- | 0.40 0.20
Knights | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Bishops | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Rooks | -0.37 0.00 | 0.00 0.00 | -0.37 +0.00
Queens | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Mobility | 0.32 0.42 | 0.03 -0.06 | +0.29 +0.48
King safety | 0.65 0.00 | -4.92 0.00 | +5.57 +0.00
Threats | 0.27 0.64 | 0.04 0.20 | +0.24 +0.44
Passed pawns | 0.00 0.00 | 0.00 0.00 | +0.00 +0.00
Unstoppable pawns | --- --- | --- --- | +0.00 +0.00
Space | 0.31 0.00 | 0.53 0.00 | -0.22 +0.00
---------------------+-------------+-------------+---------------
Total | --- --- | --- --- | +2.65 -2.36
Uncertainty margin: White: +0.00, Black: +5.25
Scaling: 100.00% MG, 0.00% * 100.00% EG.
Total evaluation: 2.67
-
- Posts: 3241
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: Stockfish Code ( Piece Value's)
... and what's your supporting evidence ?NJDenson wrote:I believe the values are not correct
believe me marco and joona aren't amateurs, and didn't choose them randomly. they did some very expensive CLOP optimization of piece values and PST.
if you can get a significant elo gain by making your random modifications, i can't wait to see it. but i seriously doubt it...