stockfish.js icon indicating copy to clipboard operation
stockfish.js copied to clipboard

Evaluation

Open A-Beille opened this issue 2 years ago • 5 comments

Hi, I recently started using this package, and I want to create an evaluation bar of the position using it. How can I manage to do what I want to? Thanks you !

A-Beille avatar Jul 10 '23 19:07 A-Beille

Stockfish is a UCI chess engine, so you can send the eval command to get the Evaluation.

Jochengehtab avatar Jul 25 '23 19:07 Jochengehtab

@A-Beille

My implementation as below

  • Assume that you have current position FEN
  • search for bestmove with current position (using depth, go time or.....) -after you get the CP score -> you can calculate the wining chance
Win% = 50 + 50 * (2 / (1 + exp(-0.00368208 * CP)) - 1)

This is the percentage of your ELO bar. if current move is black then white Elo = 100-blackElo. with this you can render the elobar.

Read more here - https://lichess.org/page/accuracy

samuraitruong avatar Sep 11 '23 04:09 samuraitruong

the thing is that here, you get a percentage. If you put 0 centipawns, then the winning rate in percentage is 50%. But that's not what I want: I want to calculate the evaluation from the centipawns given by the engine (like an eval bar)

A-Beille avatar Sep 16 '23 19:09 A-Beille

Thats is correct. You need to apply the calculation on the UI after winning chance, of course when CP =0 win chance=50% because this is also 50% for opposite color.

assume that move is black, and black winning is 50% -> white winning = 100-black winning change

if you get CP = -300 for example. winning chance calculate about 27%. then black = 27%, white = 73%. with this you can easy implement the UI.

Hope that make sense

Get Outlook for Androidhttps://aka.ms/AAb9ysg


From: A_Beille @.> Sent: Sunday, 17 September 2023, 5:54 am To: nmrugg/stockfish.js @.> Cc: Truong Nguyen @.>; Comment @.> Subject: Re: [nmrugg/stockfish.js] Evaluation (Issue #77)

the thing is that here, you get a percentage. If you put 0 centipawns, then the winning rate in percentage is 50%. But that's not what I want: I want to calculate the evaluation from the centipawns given by the engine (like an eval bar)

— Reply to this email directly, view it on GitHubhttps://github.com/nmrugg/stockfish.js/issues/77#issuecomment-1722303875, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAJA3ITSYLDTWIJ27NSW5Z3X2X7XLANCNFSM6AAAAAA2FAFWKM. You are receiving this because you commented.Message ID: @.***>

samuraitruong avatar Sep 16 '23 22:09 samuraitruong