pydraughts, a draughts library in Python

Discussion about development of draughts in the time of computer and Internet.
Post Reply
AttackingOrDefending
Posts: 3
Joined: Sun Apr 17, 2022 08:03
Real name: Ioannis Pantidis

pydraughts, a draughts library in Python

Post by AttackingOrDefending » Sun Dec 03, 2023 21:30

Hello,

I have created a library for draughts in Python called pydraughts (https://github.com/AttackingOrDefending/pydraughts). It was originally created to create bots on lidraughts (https://lidraughts.org/player/bots). In June, I added a tournament manager which would allow for the automation of draughts tournaments. While I don't have that much free time at the moment, I was looking for some feedback on what I need to work on next.

Features:
  • Variants:
    • International
      Russian
      Brazilian
      English/American
      Italian
      Turkish
      Frisian
      frysk!
      Antidraughts
      Breakthrough
    Engine protocols:
    • Hub
      DXP
      CheckerBoard
    PDN Reading and Writing
    Ballots
    Tournaments

BertTuyt
Posts: 1573
Joined: Wed Sep 01, 2004 19:42

Re: pydraughts, a draughts library in Python

Post by BertTuyt » Tue Dec 05, 2023 16:11

Thanks for sharing.

I have basically 2 questions , in your github example you have a tournament with 2 players, are more players also possible (and in that case) are engines switched on and off automatically.

And last but not least what we would like to see; a tournament with multiple engines which run an a local computer, but where the game in progress, games played so far, and tournament scores so far can be live seen on LiDraughts. So really automatically, so that one does not need to manually operate all constantly during the tournament.

Bert

AttackingOrDefending
Posts: 3
Joined: Sun Apr 17, 2022 08:03
Real name: Ioannis Pantidis

Re: pydraughts, a draughts library in Python

Post by AttackingOrDefending » Wed Dec 06, 2023 18:16

You can tournaments with more than 2 engines. I have tested with up to 3 engines (scan dxp, kr hub, mobydam dxp) and it worked correctly. I couldn't find more engines to test it, but there shouldn't be any issue with more engines.

Lidraughts doesn't support user-created broadcasts and doesn't have an API for them, like lichess. I sent a message to RoepStoep requesting the addition of a broadcast API but I haven't gotten a reply yet. Playstrategy (https://playstrategy.org), which is also based on lichess, supports broadcasts and has draughts, so this is probably a better choice even though it's less popular.

gwiesenekker
Posts: 17
Joined: Sun Feb 20, 2011 21:04
Real name: Gijsbert Wiesenekker

Re: pydraughts, a draughts library in Python

Post by gwiesenekker » Thu Feb 08, 2024 15:20

Hi,

Thank you! At least for GWD (but I guess also for other engines) it is required it is launched from the directory they are installed in so they can find configuration files etc. By inspecting the source code this is supported for the HubEngine command through the 'cwd' argument:

from draughts.engine import HubEngine, Limit
engine=HubEngine(["C:/Tmp2/GWD7/x64/Release-AVX2/GWD7.exe", ""],cwd="C:/Tmp2/GWD7/x64/Release-AVX2")

But as far as I can see this is not supported for tournament play. I modified lines 60 of tournament.py as follows to launch the engine from the directory it is installed in:

#print(command, os.path.dirname(command[0]))
engine = HubEngine(command, cwd = os.path.dirname(command[0]))

I can then have play GWD against itself as:

from draughts.tournament import RoundRobin
player1 = (["C:/Tmp2/GWD7/x64/Release-AVX2/GWD7.exe", ""], "hub", {})
player2 = (["C:/Tmp2/GWD7/x64/Opponent/GWD7.exe", ""], "hub", {})
players = [player1, player2]
tournament = RoundRobin("tournament.pdn", players, start_time=20, increment=0.2, games_per_pair=4)
scores = tournament.play()
print(scores)

Could you also add 'cwd' support for tournament play?

Thanks,
GW

AttackingOrDefending
Posts: 3
Joined: Sun Apr 17, 2022 08:03
Real name: Ioannis Pantidis

Re: pydraughts, a draughts library in Python

Post by AttackingOrDefending » Thu Feb 15, 2024 18:35

Hi,

I just released a new version with the change you requested. Let me know if you have any problems with it.

Post Reply