Torom / BotLi

Lichess Bot
GNU Affero General Public License v3.0
46 stars 82 forks source link

books section #7

Closed botss23 closed 2 years ago

botss23 commented 2 years ago

Hi, can you solve the books section error? raise Exception(f'The book "{book}" is not defined in the books section.') Exception: The book "./Perfect2022.bin" is not defined in the books section.

Torom commented 2 years ago

Please try to follow the Readme. If you still have trouble to set it up correctly it would be helpful if you post your config. Please remove the token before you post it here.

botss23 commented 2 years ago

I have followed the readme , i have even set the book path , the problem vanished but has returned after 2 games.

botss23 commented 2 years ago

should i copy my config and paste it here?

Torom commented 2 years ago

Yes this would be helpful.

botss23 commented 2 years ago
engine:                                   # Engine settings.
  dir: "./engines"                        # Directory containing the engine.
  name: "stockfish_14.1_avx2.exe"                      # Binary name of the engine to use.
  ponder: true                            # Think on opponent's time.
  opening_books:
    enabled: true                       # Activate opening books.
    books:
#     white:                              # List of names of books to use as white.
#       - "WhiteBook"
#     black:                              # List of names of books to use as black.
#       - "BlackBook"
      standard:                           # List of names of books to use if there is no specific book for white, black or chess960.
        - "./engines/Pro.bin" 
#     chess960:                           # List of names of books to use for Chess960.
#       - "Chess960Book"
    selection: "best_move"          # Move selection is one of "weighted_random", "uniform_random" or "best_move".
  online_moves:
    chessdb:
      enabled: false                      # Activate online moves from https://chessdb.cn/queryc_en/
      min_depth: 10                       # Minimum evaluation depth.
      min_time: 40                        # Time the bot must have at least to use the online move.
      timeout: 5                          # Time the server has to respond.
    lichess_cloud:
      enabled: false                      # Activate online moves from Lichess cloud eval.
      min_depth: 10                       # Minimum evaluation depth.
      min_time: 40                        # Time the bot must have at least to use the online move.
      timeout: 5                          # Time the server has to respond.
    online_egtb:
      enabled: true                      # Activate online endgame tablebases from Lichess.
      min_time: 10                        # Time the bot must have at least to use the online move.
      timeout: 3                          # Time the server has to respond.
  offer_draw:
    enabled: true                         # Activate whether the bot should offer draw.
    score: 10                             # If the absolute value of the score is less than or equal to this value, the bot offers/accepts draw (in cp)
    consecutive_moves: 10                 # How many moves in a row the absolute value of the score has to be below the draw value
    min_game_length: 35                   # Earliest move in which draw is offered.
  resign:
    enabled: false                        # Activate whether the bot should resign games.
    score: -1000                          # If the score is less than or equal to this value, the bot resigns (in cp).
    consecutive_moves: 5                  # How many moves in a row the score has to be below the resign value.
  uci_options:                            # Arbitrary UCI options passed to the engine. (Commenting allowed)
    Move Overhead: 100                    # Increase if your bot flags games too often.
    Threads: 4                            # Max CPU threads the engine can use.
    Hash: 2048                             # Max memory (in megabytes) the engine can allocate.
#   SyzygyPath: "/path/to/syzygy"         # Path to your local syzygy endgame tablebases

move_overhead_multiplier: 1.0             # Increase if your bot flags games too often. Default move overhead is 1 second per 1 minute initital time.

challenge:                                # Incoming challenges. (Commenting allowed)
  concurrency: 1                          # Number of games to play simultaneously.
  bullet_with_increment_only: false       # Whether bullet games should be accepted with increment only.
# min_increment: 0                        # Minimum amount of increment to accept a challenge.
# max_increment: 180                      # Maximum amount of increment to accept a challenge.
# min_initial: 0                          # Minimum amount of initial time to accept a challenge.
# max_initial: 315360000                  # Maximum amount of initial time to accept a challenge.
  variants:                               # Chess variants to accept (https://lichess.org/variant).
    - standard
    - chess960
#   - fromPosition
#   - antichess
#   - atomic
#   - crazyhouse
#   - horde
#   - kingOfTheHill
#   - racingKings
#   - threeCheck
  time_controls:                          # Time controls to accept.
    - bullet
    - blitz
    - rapid
#   - classical
  bot_modes:                              # Game modes to accept against BOTs.
#   - casual                              # Unrated games.
    - rated                               # Rated games
  human_modes:                            # Game modes to accept against humans.
    - casual                              # Unrated games.
    - rated                               # Rated games

matchmaking:
  initial_time: 60                        # Initial time for matchmaking mode.
  increment: 1                            # Increment time for matchmaking mode.
  rated: true                             # Activate rated games in matchmaking mode.
  timeout: 20                             # Time until a challenge is canceled.
  variant: standard                       # Chess variant (https://lichess.org/variant) to challenge when starting with --matchmaking flag.
# min_rating_diff: 0                      # Minimum rating distance to opponent. (Commenting allowed)
# max_rating_diff: 300                    # Maximum rating distance to opponent. (Commenting allowed)

books:                                    # Names of the opening books (to be used above in the polyglot section) and paths to the 
 Pro.bin: "./engines/Pro.bin"
botss23 commented 2 years ago

ah sorry for this , not to good with edit

Torom commented 2 years ago

Change the entry under standard to "ProDeo.bin"

botss23 commented 2 years ago

yes i have

Torom commented 2 years ago

Not in the config you posted. Change - "./engines/Pro.bin" to - "ProDeo.bin"

botss23 commented 2 years ago

yes i did

botss23 commented 2 years ago

raise Exception(f'The book "{book}" is not defined in the books section.') Exception: The book "Prodeo.bin" is not defined in the books section.

still getting it

botss23 commented 2 years ago

tried again , still gettin it

Torom commented 2 years ago

You wrote Prodeo.bin but you name the book ProDeo.bin. This is case sensitive.

botss23 commented 2 years ago

ah , thats resolved but here comes new one if not os.path.isfile(CONFIG['books'][book]): TypeError: string indices must be integers

botss23 commented 2 years ago

im sorry because i have not much python knowledge

Torom commented 2 years ago

No it's fine. Can you post the complete error message you get?

botss23 commented 2 years ago

C:\Users\Vi\Documents\BotLi-main>python user_interface.py Traceback (most recent call last): File "C:\Users\Vi\Documents\BotLi-main\user_interface.py", line 214, in ui = UserInterface() File "C:\Users\Vi\Documents\BotLi-main\user_interface.py", line 21, in init self.config = load_config() File "C:\Users\Vi\Documents\BotLi-main\config.py", line 60, in load_config if not os.path.isfile(CONFIG['books'][book]): TypeError: string indices must be integers

Torom commented 2 years ago

Ah I have a idea what happened. Can you again post your config please. You can format it with a code block for better readability.

botss23 commented 2 years ago
engine:                                   # Engine settings.
  dir: "./engines"                        # Directory containing the engine.
  name: "stockfish_14.1_avx2.exe"                      # Binary name of the engine to use.
  ponder: true                            # Think on opponent's time.
  opening_books:
    enabled: true                       # Activate opening books.
    books:
#     white:                              # List of names of books to use as white.
#       - "WhiteBook"
#     black:                              # List of names of books to use as black.
#       - "BlackBook"
      standard:                           # List of names of books to use if there is no specific book for white, black or chess960.
        - "ProDeo.bin" 
#     chess960:                           # List of names of books to use for Chess960.
#       - "Chess960Book"
    selection: "best_move"          # Move selection is one of "weighted_random", "uniform_random" or "best_move".
  online_moves:
    chessdb:
      enabled: false                      # Activate online moves from https://chessdb.cn/queryc_en/
      min_depth: 10                       # Minimum evaluation depth.
      min_time: 40                        # Time the bot must have at least to use the online move.
      timeout: 5                          # Time the server has to respond.
    lichess_cloud:
      enabled: false                      # Activate online moves from Lichess cloud eval.
      min_depth: 10                       # Minimum evaluation depth.
      min_time: 40                        # Time the bot must have at least to use the online move.
      timeout: 5                          # Time the server has to respond.
    online_egtb:
      enabled: true                      # Activate online endgame tablebases from Lichess.
      min_time: 10                        # Time the bot must have at least to use the online move.
      timeout: 3                          # Time the server has to respond.
  offer_draw:
    enabled: true                         # Activate whether the bot should offer draw.
    score: 10                             # If the absolute value of the score is less than or equal to this value, the bot offers/accepts draw (in cp)
    consecutive_moves: 10                 # How many moves in a row the absolute value of the score has to be below the draw value
    min_game_length: 35                   # Earliest move in which draw is offered.
  resign:
    enabled: false                        # Activate whether the bot should resign games.
    score: -1000                          # If the score is less than or equal to this value, the bot resigns (in cp).
    consecutive_moves: 5                  # How many moves in a row the score has to be below the resign value.
  uci_options:                            # Arbitrary UCI options passed to the engine. (Commenting allowed)
    Move Overhead: 100                    # Increase if your bot flags games too often.
    Threads: 4                            # Max CPU threads the engine can use.
    Hash: 2048                             # Max memory (in megabytes) the engine can allocate.
#   SyzygyPath: "/path/to/syzygy"         # Path to your local syzygy endgame tablebases

move_overhead_multiplier: 1.0             # Increase if your bot flags games too often. Default move overhead is 1 second per 1 minute initital time.

challenge:                                # Incoming challenges. (Commenting allowed)
  concurrency: 1                          # Number of games to play simultaneously.
  bullet_with_increment_only: false       # Whether bullet games should be accepted with increment only.
# min_increment: 0                        # Minimum amount of increment to accept a challenge.
# max_increment: 180                      # Maximum amount of increment to accept a challenge.
# min_initial: 0                          # Minimum amount of initial time to accept a challenge.
# max_initial: 315360000                  # Maximum amount of initial time to accept a challenge.
  variants:                               # Chess variants to accept (https://lichess.org/variant).
    - standard
    - chess960
#   - fromPosition
#   - antichess
#   - atomic
#   - crazyhouse
#   - horde
#   - kingOfTheHill
#   - racingKings
#   - threeCheck
  time_controls:                          # Time controls to accept.
    - bullet
    - blitz
    - rapid
#   - classical
  bot_modes:                              # Game modes to accept against BOTs.
#   - casual                              # Unrated games.
    - rated                               # Rated games
  human_modes:                            # Game modes to accept against humans.
    - casual                              # Unrated games.
    - rated                               # Rated games

matchmaking:
  initial_time: 60                        # Initial time for matchmaking mode.
  increment: 1                            # Increment time for matchmaking mode.
  rated: true                             # Activate rated games in matchmaking mode.
  timeout: 20                             # Time until a challenge is canceled.
  variant: standard                       # Chess variant (https://lichess.org/variant) to challenge when starting with --matchmaking flag.
# min_rating_diff: 0                      # Minimum rating distance to opponent. (Commenting allowed)
# max_rating_diff: 300                    # Maximum rating distance to opponent. (Commenting allowed)

books:                                    # Names of the opening books (to be used above in the polyglot section) and paths to the polyglot opening books.
 ProDeo.bin:-"ProDeo.bin"
Torom commented 2 years ago

The - betweenProDeo.bin: and "ProDeo.bin" in the books section is the problem. Replace it with a whitespace.

botss23 commented 2 years ago

jajaja yeah thanks for your help