raccrompton / BookBuilder

An automatic Chess opening repertoire Builder
GNU General Public License v3.0
125 stars 18 forks source link

Exception: Cannot find move c6d5 in opening explorer API response #18

Open scchess opened 1 year ago

scchess commented 1 year ago
#BOOK SETTINGS
OPENINGBOOK: [{"Name": "Book A", "pgn": "1. e4 e5 2. Nc3 Nc6 3. Nf3 Bc5 4. Bc4 Nf6 5. d3 d6 6. h3 a6 7. O-O b5 8. Bb3 Na5 9. Nd5 Nxb3 10. axb3 Nxd5 11. exd5 Bb7 12. c4 bxc4 13. bxc4 c6 14. Bd2 cxd5 15. b4 Ba7 16. Bc3 dxc4 17. dxc4 O-O 18. Qd2 Qb6 19. Rab1 Rfd8 20. Qe2 Qc7 21. Bd2 f6 22. Be3 Kf7 23. Bxa7 Rxa7 24. Rfc1 Bxf3 25. Qxf3 Qd7 26. Qd5+ Qe6 27. Qe4 Qc8 28. Qxh7 Rc7 29. Qh5+ Kf8 30. Qh8+ Kf7 31. Qh5+ Ke6 32. Qh4 Rxc4 33. Rxc4 Qxc4 34. Qxc4+ Ke7 35. Qc7+ Rd7 36. Qc6 a5 37. b5 Ra7 38. b6 Ra8 39. b7 Rb8 40. Qc8 Rxc8 41. bxc8=Q a4 42. Qc7+ Ke6 43. Ra1 a3 44. Rxa3 Kd5 45. Ra6 Ke6 46. Qxd6+ Kf5 47. Ra3 Kg6 48. Rf3 Kf7 49. Qd7+ Kg6 50. Rg3+ Kh5 51. Qxg7 e4 52. Qg4+ Kh6 53. Qg6#"},{"Name": "Book B", "pgn": "1. d3 g6 2. d4 Bg7 3. h4 Nf6 4. h5 d5 5. hxg6 fxg6 6. c3 Nc6 7. Nf3 Bf5 8. Bg5 e6 9. e3 Qe7 10. Bd3 O-O-O 11. O-O h6 12. Bxf6 Qxf6 13. Na3 Bxd3 14. Qxd3 g5 15. c4 g4 16. cxd5 exd5 17. Nd2 h5 18. Qb5 h4 19. Nb3 h3 20. Nc5 b6 21. Qa6+"}] 
#add the starting point PGNs you want to create repertoires for, with starting point pgns.
#The format for multiple PGNs and chapters looks like this: [{"Name": "Book A", "pgn": "1. e4 e5"},{"Name": "Book B", "pgn": "1. e4 e5 2. f4"}]
LONGTOSHORT: 0
#if you want the chapter ordered from long lines to short lines, instead of short to long, change to "1". Else 0.

#DATABASE SETTINGS
VARIANT: 'standard' 
#Variants to include in the analysis
SPEEDS: ['blitz,rapid,classical,correspondence'] 
#comma separated Formats to include in the analysis
RATINGS: ['1600,1800,2000,2200,2500'] 
#Ratings of the players to include in the analysis
MOVES: 10
#The number of most played moves to search over for the best move (minimum 5)

#MOVE SELECTION SETTINGS
DEPTHLIKELIHOOD: 0.01
#this controls how deep moves and lines are generated. The smaller the number the deeper the lines. Once cumulative line likelihood reaches this probability threshold, no futher continuations will be added (in percentage so 0.0025 = 0.25%)
ALPHA: 0.001
#The larger this number the more likely we are to select moves with less data. This is the confidence interval alpha (EG 0.05 = 95% CI), for deciding the lower bounds of how good a move's winrate is.
MINPLAYRATE: 0.001
#minimum frequency for a move to be played in a position to be considered as a 'best move' candidate, as a percentage (0.05= 5%)
MINGAMES: 19 
#games where moves played this or less than this will be discarded (unless top engine move) (25 = 25 games).
CONTINUATIONGAMES: 10 
# games where moves played this or less than this will not be considered a valid continuation (ie we don't want to be inferring cumulative probability or likely lines from tiny amounts of games/1 game)
DRAWSAREWINS: 0
#if you want to count draws as wins, for the win rate calculation, select 1. Else 0.

#ENGINE SETTINGS
ENGINEPATH: '/usr/local/bin/stockfish_11'
#the filepath where the engine is stored on your computer, so it can be accessed. It should end in the actual engine file, not the folder, so /engine.exe or similar.
#Some users reported errors if the engine has _ in the file name.
CAREABOUTENGINE: 0
#care about engine eval of position or engine finishing = 1, dont care = 0. If this is 0 then no engine functionality will work.
ENGINEDEPTH: 10
#what depth the engine should evaluate best moves. the higher the depth the longer the evaluation will take.
ENGINEFINISH: 1
#if we want the engine to complete lines to cumulative likelihood where data is insufficient, 1. Otherwise 0, and lines will end where there's no good human data
SOUNDNESSLIMIT: -99
#maximum centipawns we are willing to be down in engine eval, provided the winrate is better (-300 = losing by 3 pawns in eval). We never give up a forced mate, however.
MOVELOSSLIMIT: -99
#maximum centipawns we are willing to lose vs engine analysis pre move to play a higher winrate move. We never give up a forced mate, however.
IGNORELOSSLIMIT: 300
#centipawns advantage above which we won't care if we play a move that hits our loss limit, if it has a higher win rate (is easier to win)
ENGINETHREADS: 1
#how many threads you want the engine to use (check your comp and set 1 if unsure)
#for reference my safemax is 20
ENGINEHASH: 320 
#how much hash (RAM) you want the engine to use (check your comp and set to 16 if unsure)
#for reference my safe max is 10240

# Change this to true/false depending if you want to see detailed output in your terminal when running the program
PRINT_INFO_TO_CONSOLE: true
rmccarth commented 1 year ago

I'm also seeing this but its giving c7c6:

What is the full path to your config.yaml file? (ie. /Users/youruser/BookBuilder/config.yaml): /home/slixperi/BookBuilder/config.yaml
Loading config file...
File loaded!
INFO:root:Starting BookBuilder. Your current dir is /home/slixperi/BookBuilder. Files will be saved to this location.
DEBUG:root:[Move.from_uci('e2e4'), Move.from_uci('e7e5'), Move.from_uci('f2f3'), Move.from_uci('c7c6'), Move.from_uci('d2d4')]
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): explorer.lichess.ovh:443
DEBUG:urllib3.connectionpool:https://explorer.lichess.ovh:443 "GET /lichess?variant=standard&speeds=rapid,classical,correspondence&ratings=2200,2500&recentGames=0&topGames=0&moves=6&play=&fen=rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR%20b%20KQkq%20-%200%201 HTTP/1.1" 200 None
DEBUG:root:likelihoods to get here: [('e5', 0.254397567523063)]
DEBUG:root:cumulative likelihood +25.44%
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): explorer.lichess.ovh:443
DEBUG:urllib3.connectionpool:https://explorer.lichess.ovh:443 "GET /lichess?variant=standard&speeds=rapid,classical,correspondence&ratings=2200,2500&recentGames=0&topGames=0&moves=6&play=&fen=rnbqkbnr/pppp1ppp/8/4p3/4P3/5P2/PPPP2PP/RNBQKBNR%20b%20KQkq%20-%200%202 HTTP/1.1" 200 None
Traceback (most recent call last):
  File "/home/slixperi/BookBuilder/workerEngineReduce.py", line 369, in find_opponent_move
    move_stats = next(item for item in self.stats['moves'] if item["uci"] == move_uci) #move stats is the next move in self stats moves which matches the move fed into function
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "BookBuilder.py", line 397, in <module>
    main()
  File "BookBuilder.py", line 393, in main
    grower.run()
  File "BookBuilder.py", line 305, in run
    self.iterator(chapter, opening['Name'])
  File "BookBuilder.py", line 313, in iterator
    Rooter(self.pgn)
  File "BookBuilder.py", line 40, in __init__
    pgnList = self._calculate_pgns()
  File "BookBuilder.py", line 71, in _calculate_pgns
    move_stats, chance = workerPlay.find_opponent_move(move) #we look for the PGN move in the API response, and return the odds of it being played
  File "/home/slixperi/BookBuilder/workerEngineReduce.py", line 371, in find_opponent_move
    raise Exception(f'Cannot find move {move_uci} in opening explorer API response')
Exception: Cannot find move c7c6 in opening explorer API response
raccrompton commented 1 year ago

Basically, this means a move in your PGN has never been played on Lichess (or if it has, has been played later than I believe move 25, which is the limit of Lichess's opening explorer).

So, the PGN would likely need to be much shorter in order to use it as the base of the tree from which to generate moves.

On Tue, 11 Oct 2022 at 15:08, Rob @.***> wrote:

I'm also seeing this but its giving c7c6:

What is the full path to your config.yaml file? (ie. /Users/youruser/BookBuilder/config.yaml): /home/slixperi/BookBuilder/config.yaml Loading config file... File loaded! INFO:root:Starting BookBuilder. Your current dir is /home/slixperi/BookBuilder. Files will be saved to this location. DEBUG:root:[Move.from_uci('e2e4'), Move.from_uci('e7e5'), Move.from_uci('f2f3'), Move.from_uci('c7c6'), Move.from_uci('d2d4')] DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): explorer.lichess.ovh:443 DEBUG:urllib3.connectionpool:https://explorer.lichess.ovh:443 "GET /lichess?variant=standard&speeds=rapid,classical,correspondence&ratings=2200,2500&recentGames=0&topGames=0&moves=6&play=&fen=rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR%20b%20KQkq%20-%200%201 HTTP/1.1" 200 None DEBUG:root:likelihoods to get here: [('e5', 0.254397567523063)] DEBUG:root:cumulative likelihood +25.44% DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): explorer.lichess.ovh:443 DEBUG:urllib3.connectionpool:https://explorer.lichess.ovh:443 "GET /lichess?variant=standard&speeds=rapid,classical,correspondence&ratings=2200,2500&recentGames=0&topGames=0&moves=6&play=&fen=rnbqkbnr/pppp1ppp/8/4p3/4P3/5P2/PPPP2PP/RNBQKBNR%20b%20KQkq%20-%200%202 HTTP/1.1" 200 None Traceback (most recent call last): File "/home/slixperi/BookBuilder/workerEngineReduce.py", line 369, in find_opponent_move move_stats = next(item for item in self.stats['moves'] if item["uci"] == move_uci) #move stats is the next move in self stats moves which matches the move fed into function StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "BookBuilder.py", line 397, in main() File "BookBuilder.py", line 393, in main grower.run() File "BookBuilder.py", line 305, in run self.iterator(chapter, opening['Name']) File "BookBuilder.py", line 313, in iterator Rooter(self.pgn) File "BookBuilder.py", line 40, in init pgnList = self._calculate_pgns() File "BookBuilder.py", line 71, in _calculate_pgns move_stats, chance = workerPlay.find_opponent_move(move) #we look for the PGN move in the API response, and return the odds of it being played File "/home/slixperi/BookBuilder/workerEngineReduce.py", line 371, in find_opponent_move raise Exception(f'Cannot find move {move_uci} in opening explorer API response') Exception: Cannot find move c7c6 in opening explorer API response

— Reply to this email directly, view it on GitHub https://github.com/raccrompton/BookBuilder/issues/18#issuecomment-1274750316, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABWBKZWH4GQPGMOLWJXSNRTWCVYFTANCNFSM6AAAAAAQ3J7WBQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>