Mind-Sports-Games / Fairy-Stockfish-Rust

Rust wrapper for Fairy-Stockfish-Lib
GNU General Public License v3.0
3 stars 0 forks source link

Game result returning the range of u32 datatype #2

Closed silicon-ninja closed 1 year ago

silicon-ninja commented 2 years ago

Versions


But i am not loading it through variants.ini file. Just calling the function using gameResult() and the return type is u32. it gives the max value of u32.

...
rsffish::init();
let pos = rsffish::positionFromFen(
            &"chess".to_string(),
            &"8/1Q2b1k1/2p3p1/p2p2P1/8/5PB1/PP3RK1/3r3q w - - 2 37".to_string(),
            false,
        );
println!("game result: {}", pos.gameResult());

you can actually try running the same exact code and let me know if face the same issue

Output

game result: 4294935296

Thank you.

silicon-ninja commented 2 years ago

also tried out with

https://github.com/ianfab/Fairy-Stockfish/blob/fde5583abb90e6514529ed87cafea8398bd5a9e7/src/variants.ini

this ini file still the same issue game result: 4294935296

lakinwecker commented 2 years ago

v0.0.10 should have a fix for this. Thanks again for reporting it.

silicon-ninja commented 2 years ago

It still is being a problem while testing out regardless of who wins with this fens.

Black Winning : 8/1Q2b1k1/2p3p1/p2p2P1/8/5PB1/PP3RK1/3r3q w - - 2 37 White Winning :2r3kr/p5Rp/1p3Qn1/4q3/8/2P5/P1P3PP/5R1K b - - 6 27

the game result is-32000 how do i figure it out who won.

same thing goes for draw and on going game.

Draw by stalemate: rn2k1nr/pp4pp/3p4/q1pP4/P1P2p1b/1b2pPRP/1P1NP1PQ/2B1KBNR w Kkq - 0 13 Game still going on: 2r3kr/p4R1p/1p3Qn1/4q3/8/2P5/P1P3PP/5R1K w - - 5 27

the game result is0

thank you.

lakinwecker commented 2 years ago

I will look into it.

lakinwecker commented 2 years ago

This method alone is not enough to distinguish if a game is over or not. So it will return 0 for both an ongoing game and for a drawn game. You'll need to use other methods (like is is_optional_game_end and the number of legal moves) to determine the real result. You can get an idea for how to do it via the javascript api: https://github.com/ianfab/Fairy-Stockfish/blob/master/src/ffishjs.cpp#L294-L325

The longer term plan is to provide an API that is more analagous to the above javascript API, which should help this.

I'm looking into why the method returns -32000 for when white wins. It is my understanding that this should return 32000 (positive)

lakinwecker commented 2 years ago

For the difference between the white wins and black wins, this issue is not caused by my wrapper. I will see if ianfab can help us here.

For example, here is the python that reproduces it:

>>> print(pyffish.version())
(0, 0, 72)
>>> pyffish.game_result("chess", "8/1Q2b1k1/2p3p1/p2p2P1/8/5PB1/PP3RK1/3r3q w - - 2 37", [], False)
-32000
>>> pyffish.game_result("chess", "2r3kr/p5Rp/1p3Qn1/4q3/8/2P5/P1P3PP/5R1K b - - 6 27", [], False)
lakinwecker commented 2 years ago

Ok, I got an answer from ianfab:

All scores are pov scores. So in both cases the person who's turn it is, has lost.