Hi,
does exist a python script/program to let 2 engines play against each other and which creates the annotated pgn?
Something like cutechess-cli, but written in python.
Thanks
Engine match with python script
Moderators: hgm, Rebel, chrisw
-
- Posts: 1871
- Joined: Sat Nov 25, 2017 2:28 pm
- Location: France
Re: Engine match with python script
Can't you just call cutechess inside a python script ?
-
- Posts: 389
- Joined: Wed Sep 26, 2012 1:29 pm
- Location: Hungary
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Engine match with python script
Thanks!gbtami wrote: ↑Wed Feb 19, 2020 12:46 am See zinc http://talkchess.com/forum3/viewtopic.p ... hilit=zinc
It doesn't work, but I suppose it is because it needs an older version of python-chess
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Engine match with python script
Just uploaded a basic script at https://github.com/fsmosca/combat
There are some limitations such as no support for pgn file as start position, only epd file is supported so far. See limitations section in the readme. It uses the python-chess modules.
Sample game output.
[pgn]
[Event "?"]
[Site "?"]
[Date "????.??.??"]
[Round "3.2"]
[White "Deuterium 2019.2"]
[Black "Deuterium 2019.2 mob150 ks200"]
[Result "1/2-1/2"]
[BlackTimeControl "5s+0.05s"]
[FEN "rnbqkb1r/pp1p1ppp/4pn2/2p5/3P4/6P1/PPP1PPBP/RNBQK1NR w KQkq - 0 1"]
[Termination "threefold repetition"]
[WhiteTimeControl "5s+0.05s"]
1. Nf3 { +0.51/9 94ms } 1... Be7 { -0.17/9 141ms } 2. dxc5 { +0.44/10 94ms } 2... O-O { -0.23/11 94ms } 3. Be3 { +0.38/10 109ms } 3... Nc6 { -0.15/10 93ms } 4. O-O { +0.47/11 94ms } 4... b6 { -0.18/11 94ms } 5. cxb6 { +0.53/11 157ms } 5... axb6 { -0.17/11 156ms } 6. c4 { +0.18/9 94ms } 6... Bc5 { -0.17/11 234ms } 7. Nd4 { +0.53/10 94ms } 7... Bb7 { -0.57/12 125ms } 8. Nc3 { +0.71/10 94ms } 8... Qb8 { -0.40/11 109ms } 9. Ndb5 { +0.61/10 78ms } 9... Ne5 { -0.69/12 172ms } 10. Bxc5 { +0.41/12 78ms } 10... bxc5 { -0.46/12 141ms } 11. e4 { +0.82/11 93ms } 11... Nxc4 { -0.90/12 157ms } 12. Qe2 { +0.92/12 250ms } 12... Nb6 { -0.21/10 93ms } 13. a4 { +0.82/9 79ms } 13... d5 { -0.41/10 109ms } 14. e5 { +0.32/9 78ms } 14... Nfd7 { -0.57/10 78ms } 15. f4 { +0.53/10 125ms } 15... d4 { +0.05/12 110ms } 16. Bxb7 { +0.05/12 78ms } 16... Qxb7 { +0.18/12 109ms } 17. Nd6 { +0.39/13 94ms } 17... Qb8 { +0.04/13 141ms } 18. a5 { +0.00/11 172ms } 18... dxc3 { -0.01/14 94ms } 19. axb6 { -0.05/13 78ms } 19... Rxa1 { +0.07/15 109ms } 20. Rxa1 { +0.06/15 78ms } 20... cxb2 { +0.07/14 63ms } 21. Qxb2 { +0.01/14 109ms } 21... Qxb6 { -0.01/13 63ms } 22. Qxb6 { +0.08/13 93ms } 22... Nxb6 { +0.00/13 172ms } 23. Rb1 { +0.12/12 94ms } 23... Nd5 { -0.02/12 297ms } 24. Rc1 { +0.07/12 62ms } 24... f6 { +0.00/13 157ms } 25. Rxc5 { +0.05/12 62ms } 25... fxe5 { +0.00/15 109ms } 26. f5 { +0.00/14 157ms } 26... Ne3 { +0.00/15 62ms } 27. Rxe5 { +0.00/14 63ms } 27... Nxf5 { +0.00/14 62ms } 28. Rxe6 { +0.00/14 94ms } 28... Nxd6 { +0.00/13 94ms } 29. Rxd6 { +0.00/12 62ms } 29... Rc8 { +0.00/14 63ms } 30. h3 { -0.04/10 62ms } 30... Rc2 { +0.00/12 63ms } 31. Rd7 { -0.01/12 78ms } 31... h6 { +0.09/15 125ms } 32. h4 { +0.00/13 94ms } 32... Kh7 { +0.00/15 63ms } 33. Rd6 { -0.02/13 78ms } 33... h5 { +0.00/16 62ms } 34. Kf1 { +0.00/17 110ms } 34... Ra2 { +0.00/17 62ms } 35. Rb6 { +0.00/17 63ms } 35... Rd2 { +0.00/19 93ms } 36. Re6 { +0.00/18 63ms } 36... Rc2 { +0.00/18 62ms } 37. Rb6 { +0.00/21 63ms } 37... Ra2 { +0.00/20 62ms } 38. Rc6 { +0.00/21 79ms } 38... Rb2 { +0.00/20 62ms } 39. Ra6 { +0.00/20 94ms } 39... Rc2 { +0.00/21 125ms } 40. Rb6 { +0.00/26 62ms } 40... g6 { +0.00/18 63ms } 41. Rb7+ { +0.00/15 94ms } 41... Kh6 { +0.00/23 62ms } 42. Rd7 { +0.00/19 63ms } 42... Ra2 { +0.00/22 47ms } 43. Rb7 { +0.00/19 62ms } 43... Rc2 { +0.00/22 47ms } 44. Rd7 { +0.00/34 63ms } 44... Ra2 { +0.00/25 93ms } 45. Rb7 { +0.00/31 78ms } 45... Rc2 { +0.00/25 79ms } 46. Rd7 { +0.00/38 62ms } 46... Ra2 { +0.00/26 78ms } 47. Rb7 { +0.00/36 78ms } 47... Rc2 { +0.00/26 47ms } 48. Rd7 { +0.00/42 63ms } 48... Ra2 { +0.00/26 47ms } 49. Rb7 { +0.00/39 125ms } 49... Rc2 { +0.00/26 63ms } 1/2-1/2
[/pgn]
-
- Posts: 395
- Joined: Fri Aug 12, 2016 8:43 pm
Re: Engine match with python script
Thank you!Ferdy wrote: ↑Wed Feb 26, 2020 2:01 am Just uploaded a basic script at https://github.com/fsmosca/combat
There are some limitations such as no support for pgn file as start position, only epd file is supported so far. See limitations section in the readme.
I think you should add a requirements.txt file with the python-chess version.
Another suggestion may be to add a match.json file instead of all the command line options.
Anyway: thanks again!
-
- Posts: 4833
- Joined: Sun Aug 10, 2008 3:15 pm
- Location: Philippines
Re: Engine match with python script
Added requirements.txt, and also match.ini.Fulvio wrote: ↑Tue Mar 03, 2020 10:19 amThank you!Ferdy wrote: ↑Wed Feb 26, 2020 2:01 am Just uploaded a basic script at https://github.com/fsmosca/combat
There are some limitations such as no support for pgn file as start position, only epd file is supported so far. See limitations section in the readme.I think you should add a requirements.txt file with the python-chess version.
Another suggestion may be to add a match.json file instead of all the command line options.
Anyway: thanks again!
match.ini
Code: Select all
[COMBAT]
# Engine settings file
engine config file = combat.json
# Games = rounds x 2 if reverse is true
round = 8
reverse = true
# Opening file and random
opening file = grand_swiss_2019_6plies.pgn
randomize position = true
# Adjudication
win adjudication enable = true
win adjudication score = 700
win adjudication count = 4
# Run game matches in parallel
parallel = 4
[ENGINE1]
# name is from engine config file or combat.json or engines.json
name = Deuterium v2019.2
# tc or time control as base_time+inc_time, all in ms
tc = 10000+100
[ENGINE2]
name = Deuterium v2019.2 mobility130
tc = 10000+100
python combat.py