Comments (14)
This doesn't seem to be the case for the library version 3.0.0. In that version, sf.info
returns ''
.
from stockfish.
Sorry, never mind - bug is still present in 3.0.0. I must have never implemented the functionality correctly...
from stockfish.
Hi, @charlesoblack
I wrote test:
def test_set_fen_position_mate(self, stockfish):
stockfish.set_fen_position('8/8/8/6pp/8/4k1PP/8/r3K3 w - - 12 53')
assert stockfish.get_best_move() is None
assert stockfish.info == ''
I think it's correct behaviour. Do you agree?
from stockfish.
Yes, I think that test displays the intended behavior.
from stockfish.
So ... no bug? Can I close this issue?
from stockfish.
While the test itself passes for me, the current behavior still shows up when running through a game with a python.chess
Visitor:
class TestVisitor(chess.pgn.BaseVisitor):
def __init__(self, gm):
self.gm = gm
self.gm.evals = []
self.move_count = 1
def visit_board(self, board):
self.move_count += 1
sf.set_fen_position(board.fen())
best_move = sf.get_best_move()
print(best_move, sf.info)
info_string = sf.info
rating_match = re.search(r'score (cp|mate) (.+?)(?: |$)', info_string)
if rating_match.group(1) == 'mate':
original_rating = int(rating_match.group(2))
if original_rating:
rating = 9999 * original_rating / abs(original_rating)
elif self.gm.headers['Result'] == '1-0':
rating = 9999
else:
rating = -9999
else:
rating = int(rating_match.group(2))
if board.turn == chess.BLACK:
rating *= -1
self.gm.evals.append(rating)
output ends with:
a2a1 info depth 10 seldepth 2 multipv 1 score mate 1 nodes 204 nps 204000 tbhits 0 time 1 pv a2a1
None info depth 10 seldepth 2 multipv 1 score mate 1 nodes 204 nps 204000 tbhits 0 time 1 pv a2a1
Here is the PGN I am using for the above:
[Event "Rated Blitz game"]
[Site "https://lichess.org/3N2cqCjY"]
[Date "2020.02.14"]
[Round "-"]
[White "Grahtbo"]
[Black "Gorbunok"]
[Result "0-1"]
[BlackElo "1734"]
[BlackRatingDiff "+6"]
[ECO "A13"]
[Opening "English Opening: Agincourt Defense"]
[Termination "Normal"]
[TimeControl "180+0"]
[UTCDate "2020.02.14"]
[UTCTime "22:08:23"]
[Variant "Standard"]
[WhiteElo "1748"]
[WhiteRatingDiff "-6"]
1. c4 { [%clk 0:03:00] } 1... e6 { [%clk 0:03:00] } 2. b3 { [%clk 0:02:59] } 2... c6 { [%clk 0:02:59] } 3. a3 { [%clk 0:02:58] } 3... a5 { [%clk 0:02:58] } 4. Bb2 { [%clk 0:02:57] } 4... Nf6 { [%clk 0:02:55] } 5. e3 { [%clk 0:02:56] } 5... Be7 { [%clk 0:02:54] } 6. d3 { [%clk 0:02:55] } 6... O-O { [%clk 0:02:53] } 7. Nf3 { [%clk 0:02:54] } 7... h6 { [%clk 0:02:51] } 8. Be2 { [%clk 0:02:54] } 8... b6 { [%clk 0:02:50] } 9. O-O { [%clk 0:02:53] } 9... Ba6 { [%clk 0:02:48] } 10. Nbd2 { [%clk 0:02:52] } 10... d5 { [%clk 0:02:46] } 11. cxd5 { [%clk 0:02:51] } 11... cxd5 { [%clk 0:02:45] } 12. Qc2 { [%clk 0:02:50] } 12... Nbd7 { [%clk 0:02:43] } 13. Rac1 { [%clk 0:02:49] } 13... Rc8 { [%clk 0:02:41] } 14. Qb1 { [%clk 0:02:48] } 14... Rxc1 { [%clk 0:02:39] } 15. Qxc1 { [%clk 0:02:45] } 15... e5 { [%clk 0:02:26] } 16. Nxe5 { [%clk 0:02:41] } 16... Nxe5 { [%clk 0:02:25] } 17. Bxe5 { [%clk 0:02:40] } 17... Bd6 { [%clk 0:02:21] } 18. Bb2 { [%clk 0:02:38] } 18... Re8 { [%clk 0:02:18] } 19. Qa1 { [%clk 0:02:34] } 19... Bb7 { [%clk 0:02:07] } 20. Nf3 { [%clk 0:02:31] } 20... d4 { [%clk 0:02:00] } 21. Bxd4 { [%clk 0:02:25] } 21... Bxf3 { [%clk 0:01:57] } 22. Bxf3 { [%clk 0:02:24] } 22... Qe7 { [%clk 0:01:40] } 23. e4 { [%clk 0:02:22] } 23... Rc8 { [%clk 0:01:33] } 24. Bxb6 { [%clk 0:02:21] } 24... Be5 { [%clk 0:01:29] } 25. Bd4 { [%clk 0:02:17] } 25... Bxd4 { [%clk 0:01:28] } 26. Qxd4 { [%clk 0:02:15] } 26... Rc2 { [%clk 0:01:23] } 27. b4 { [%clk 0:02:07] } 27... axb4 { [%clk 0:01:19] } 28. Qxb4 { [%clk 0:02:06] } 28... Qxb4 { [%clk 0:01:15] } 29. axb4 { [%clk 0:02:05] } 29... Rb2 { [%clk 0:01:14] } 30. e5 { [%clk 0:02:03] } 30... Nd7 { [%clk 0:01:12] } 31. Bc6 { [%clk 0:02:01] } 31... Nxe5 { [%clk 0:01:10] } 32. Be4 { [%clk 0:01:58] } 32... Rxb4 { [%clk 0:01:07] } 33. f3 { [%clk 0:01:58] } 33... Rb2 { [%clk 0:01:04] } 34. d4 { [%clk 0:01:55] } 34... Nc4 { [%clk 0:00:59] } 35. d5 { [%clk 0:01:53] } 35... Nd6 { [%clk 0:00:57] } 36. Rc1 { [%clk 0:01:49] } 36... g5 { [%clk 0:00:48] } 37. Rc6 { [%clk 0:01:48] } 37... Nxe4 { [%clk 0:00:42] } 38. fxe4 { [%clk 0:01:47] } 38... Kg7 { [%clk 0:00:40] } 39. d6 { [%clk 0:01:46] } 39... Rd2 { [%clk 0:00:39] } 40. e5 { [%clk 0:01:45] } 40... Kf8 { [%clk 0:00:26] } 41. Rc7 { [%clk 0:01:43] } 41... Ke8 { [%clk 0:00:24] } 42. Kf1 { [%clk 0:01:38] } 42... h5 { [%clk 0:00:13] } 43. Rxf7 { [%clk 0:01:37] } 43... Kxf7 { [%clk 0:00:09] } 44. g3 { [%clk 0:01:36] } 44... Ke6 { [%clk 0:00:08] } 45. d7 { [%clk 0:01:35] } 45... Rxd7 { [%clk 0:00:06] } 46. h3 { [%clk 0:01:34] } 46... Kxe5 { [%clk 0:00:05] } 47. Kf2 { [%clk 0:01:34] } 47... Rd3 { [%clk 0:00:04] } 48. Kg2 { [%clk 0:01:31] } 48... Ra3 { [%clk 0:00:03] } 49. Kf2 { [%clk 0:01:30] } 49... Ke4 { [%clk 0:00:03] } 50. Kg2 { [%clk 0:01:30] } 50... Ra2+ { [%clk 0:00:02] } 51. Kf1 { [%clk 0:01:28] } 51... Ke3 { [%clk 0:00:01] } 52. Ke1 { [%clk 0:01:27] } 52... Ra1# { [%clk 0:00:00] } 0-1
and to run the visitor:
vis = TestVisitor(game)
game.accept(vis)
from stockfish.
Additionally, running the test after allowing the visitor to run over the chess game yields the incorrect behavior.
from stockfish.
Can you write test (pull request) to reproduce this bug?
from stockfish.
Created the test in #22 . Now to find out how to fix this bug...
from stockfish.
Thank you
I'll try to help you =)
from stockfish.
What about #23?
from stockfish.
from stockfish.
Ok, I'll merge this pr. If you have a idea to improve this, I will always be glad your PR =)
from stockfish.
Sorry, I've been busy with school :P will let you know when I've thought about this more. Thanks for merging the test :)
from stockfish.
Related Issues (20)
- Option to get board visual from either side HOT 2
- FR - Include chess notation entry HOT 2
- FR - Translate move string to human readable description of the move HOT 1
- top_moves returning empty list stockfish 15 HOT 2
- Improving some small things about self.depth HOT 1
- Stockfish 15 Errors on Linux HOT 4
- could use help implementing this HOT 2
- Jupyter Notebook HOT 2
- Improve the is_fen_valid function HOT 1
- Get best move from current position HOT 1
- Compatibility with chess library HOT 2
- [Meta] The future of this project (Please read this before opening new issues or PRs)
- can't use stockfish_mv in google colab HOT 1
- get_evaluation() implemented wrong HOT 2
- Error in stockfish\models.py in __del__, _put HOT 2
- does_current_engine_version_have_wdl_option() not work on stockfish variant
- stockfish derivatives not work when analyze pgn HOT 16
- take longer time compare with chess module HOT 5
- Stockfish crashes on invalid position instead of error mesasge HOT 5
- will_move_be_a_capture throws exeption when converting pawn
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stockfish.