nmrugg / stockfish.js

The Stockfish chess engine in Javascript
GNU General Public License v3.0
933 stars 134 forks source link

Evaluation #77

Open A-Beille opened 1 year ago

A-Beille commented 1 year ago

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 !

Jochengehtab commented 1 year ago

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

samuraitruong commented 1 year ago

@A-Beille

My implementation as below

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

A-Beille commented 1 year ago

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)

samuraitruong commented 1 year ago

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: @.***>