key-lock key-lock loading

birdracerthree wrote:

key-lock wrote:

birdracerthree wrote:

HasiLover_Test wrote:

key-lock wrote:

is there any definite way to tell when endgame starts? (i can tell when I play, but I want it for my engine)
i'm using the StockFish piece values, which change depending on endgame or middlegame/opening:

midgame values:
pawn=126
knight=781
bishop=825
rook=1276
queen=2538

endgame value:
pawn=208
knight=854
bishop=915
rook=1380
queen=2682

also, how do you decide on these values? I know centipawns is a common unit.
another method I tried was calculating the mobility of each piece (how many squares it can move to from the middle of the board):
queen=27
rook=14
bishop=13
knight=8
pawn=3
using this method, the king would be 8, but since you have to cancel out moves that get you checked, king=16(3)+4(8)+4(13)+4(14)+18(27)=674
Id say once the players both only have 2 minor pieces or 1 major piece left. (Pawn amount doesnt matter)
This doesn't include BNNvBNN, RRvRR, BBNNvBBNN, and more. This is how Element does it :
if 3N+3B+5R+9Q<27 or Q=2 and Q+R+2 = PieceCount-P then
Endgame =1

N is number of knights, B is number of bishops, etc. The second part of the boolean is used to detect if there are no minor pieces left (although allowing QRRvQRR to count as an endgame removes Element's pawn sheild. This has caused issues here - https://lichess.org/study/PgtRI4b6/BCzCiPI4#76).

Alternatively, you can use the material value and interpolate between early middlegame and late endgame. For example, the pawn value would be *(-41/31)*x+208, where x is the total material (x starts at 62 in the beginning of the game ignoring pawns).

How are these calculated? Well, the standard beginners are taught is {1,3,3,5,9}. However, this can causing BNvRP exchanges, which is bad (BN>RP). In chess engines, the standard is {1,3.2,3.3,5,9}, with the knight sometimes being 3.1 instead. Element is switching to {1,3.9,4.1,6,12} soon (variant of {1,4,4,6,12} to help stop BNvRP exchanges).
I noticed that in the 1st part of the boolean, it essentially was if the standard piece value of the board (except for pawns)<27
for my values, that would be 6961.02188 on average (not taking pawns into account). I already have a board evaluation function, so I'll change it to
(board value)<7,000
Max value this has is 62 at the start of the game. The function is not dependent on the piece values of the engine.
ok, but do I need variables for it? I meant that since I already had a board eval. function, I wanted to modify the boolean to be easier. my board starts at 18620 (not including my engine's values for kings/negative values for opposite colors). also, isn't the starting piece value 78, 79.2, or 96 (depending on which definition you used).