Jakob256 / PurplePanda

Chess Engine
2 stars 0 forks source link

better time management #3

Open tissatussa opened 9 months ago

tissatussa commented 9 months ago

hi, i just discovered your chess engine .. i managed to compile the source code into a valid binary, using your g++ command (i'm on Xubuntu 22.04 64-bit) .. it plays without errors in CuteChess, but it seems to lack proper time management : while using 13 minutes per player per game, plus 10 seconds bonus, Purple Panda plays each (!?) move almost instantly (takes about 0.03 sec) and reaching only Depth 5 ..

are you aware of this "behaviour" ? should / can it be changed ?

Jakob256 commented 6 months ago

Hi,

I have finally looked into this issue. It seems the thinking time was 1000x lower than it should. This was probably caused by your system having more "clock ticks" per second than my pc. (I have 1000 ticks per second and you seem to have 1000000.)

The problem starting with todays new version of PurplePanda (version 14) should be fixed. (In engine.h I add the line time=time*CLOCKS_PER_SEC/1000; which should do the trick.)

Thanks for raising the issue and sorry for the late response.

Jakob

tissatussa commented 6 months ago

i was able to compile v14 on Linux and the binary runs fine in CuteChess .. it also has a good time management : i let it play against another engine in a 15 min. game and Purple Panda spent its time very regular and realistic :

Purple Panda v14 -vs- Pigeon v1 5 1 - ApronusDiagram1718917521

(animated diagram created with apronus.com 250 ms per move)


[Event "engine vs engine"] [Site "?"] [Date "2024.01.20"] [Round "?"] [White "Purple Panda v14"] [Black "Pigeon v1.5.1"] [Result "1/2-1/2"] [ECO "A00"] [GameDuration "00:42:02"] [Opening "Dunst (Sleipner, Heinrichsen) Opening"] [PlyCount "119"] [TimeControl "900+10"]

  1. Nc3 {0.00/8 30s} Nf6 {0.00/9 17s} 2. e4 {+0.02/8 31s} Nc6 {-0.30/8 17s} 3. d4 {+0.05/8 30s} d5 {-0.19/8 34s} 4. e5 {+0.08/8 38s} Ne4 {-0.16/8 38s} 5. Bf4 {+0.86/7 30s} Bf5 {-0.11/8 46s} 6. Bb5 {+0.07/8 30s} a6 {+0.17/8 8.5s} 7. Bxc6+ {+0.08/8 30s} bxc6 {+0.14/9 27s} 8. Nf3 {+0.07/8 29s} Qb8 {+0.58/8 20s} 9. Qc1 {-0.76/8 29s} h6 {+0.48/7 7.1s} 10. Nh4 {+0.17/7 28s} Be6 {+0.81/8 10s} 11. Be3 {+0.04/8 28s} Qb4 {+0.73/8 17s} 12. a3 {+0.03/8 28s} Qc4 {+0.66/8 8.9s} 13. Ne2 {+0.05/8 27s} g5 {+0.68/8 21s} 14. Nf3 {+0.03/8 26s} Kd8 {+0.43/8 34s} 15. Ng3 {+0.09/8 26s} f5 {+0.49/8 47s} 16. Nxe4 {+0.13/8 25s} dxe4 {+0.59/9 18s} 17. Nd2 {+0.17/9 25s} Qa4 {+0.40/8 16s} 18. Nb1 {+0.18/7 25s} f4 {+1.05/9 40s} 19. Nc3 {+0.14/9 25s} Qc4 {+0.42/9 26s} 20. Bxf4 {+0.20/9 24s} gxf4 {+0.35/8 15s} 21. Qxf4 {-0.73/8 24s} h5 {+0.35/8 21s} 22. Qxe4 {-0.72/8 24s} Rb8 {+0.39/7 7.4s} 23. O-O-O {+0.22/7 23s} Bh6+ {+0.30/8 18s} 24. f4 {+0.19/7 23s} h4 {+0.16/7 12s} 25. Rd2 {+0.25/7 22s} Bd5 {+0.25/8 33s} 26. Qe3 {+0.19/9 22s} Rg8 {+0.58/8 25s} 27. Rg1 {+0.23/7 22s} Rxg2 {+1.00/8 19s} 28. Re1 {-0.81/8 21s} Rxd2 {+1.06/8 16s} 29. Qxd2 {-0.70/9 21s} Bg8 {+0.72/8 18s} 30. Qf2 {-0.84/8 21s} Qf7 {+1.48/9 28s} 31. Rf1 {-0.76/8 21s} h3 {+1.31/8 13s} 32. Qf3 {-0.73/7 20s} Bh7 {+1.30/7 9.5s} 33. Qxc6 {-0.81/8 20s} Bxf4+ {+1.33/8 37s} 34. Kb1 {+0.15/9 20s} Qb3 {-0.09/9 19s} 35. Qd5+ {+0.17/9 20s} Qxd5 {-0.37/11 16s} 36. Nxd5 {+0.16/10 19s} Bh6 {-0.35/9 9.7s} 37. Rf3 {+0.16/9 19s} Be4 {-0.32/9 15s} 38. Rxh3 {+0.09/10 19s} Bxd5 {-0.17/10 27s} 39. Rxh6 {+0.06/10 19s} Kd7 {+0.03/9 8.6s} 40. b3 {+0.06/8 19s} Rb6 {+0.03/10 22s} 41. Rxb6 {+0.08/10 18s} cxb6 {-0.07/14 27s} 42. Kc1 {+0.10/11 19s} Bg8 {+0.05/12 29s} 43. Kd2 {+0.11/11 18s} Ke6 {+0.16/13 30s} 44. Ke3 {+0.10/11 18s} Kf5 {+0.27/13 22s} 45. Kf3 {+0.08/11 17s} b5 {+0.91/12 12s} 46. b4 {0.00/11 17s} Bd5+ {+1.00/12 7.8s} 47. Ke3 {-0.80/11 18s} Be4 {+1.05/12 30s} 48. c3 {-0.80/11 17s} Bd5 {+1.14/13 23s} 49. Kd3 {-0.84/10 17s} Kf4 {+1.14/13 17s} 50. Ke2 {-0.82/11 17s} Ke4 {+1.14/11 12s} 51. Kd2 {-0.80/11 16s} Kf3 {+1.14/13 21s} 52. Kd3 {-0.82/11 16s} Kf4 {+1.07/12 27s} 53. Kd2 {-0.82/11 16s} Kg5 {+1.15/11 7.9s} 54. Kd3 {-0.84/10 16s} Kg4 {+1.06/12 14s} 55. Ke3 {-0.84/11 16s} Bg2 {+1.08/11 7.6s} 56. Kd3 {-0.82/11 16s} Kf4 {+1.06/12 18s} 57. Kc2 {-0.80/11 16s} Bd5 {+1.06/12 20s} 58. Kd2 {-0.82/11 15s} Kg5 {+1.06/12 26s} 59. Ke2 {-0.84/10 15s} Kf4 {+1.06/12 14s} 60. Kd2 {0.00/13 15s, Draw by 3-fold repetition} 1/2-1/2
Jakob256 commented 6 months ago

I'm happy to hear that.

I think this game perfectly demonstrates its complete lack of positional play and understanding of King safety.

My goal is to eventually reach 2000 ELO in the CCRL Blitz rating list, even if it's quite an ambitious goal for me.

tissatussa commented 6 months ago

@Jakob256 according to the CCRL Blitz list Purple Panda v12 has rating 1401 and Pigeon v1.5.1 has 1738, so this draw is a good result! My Issue is about its time management, and this seems to be fixed now!

your concern about its playing style / strength and lack of positional play and understanding of King safety is another matter .. i hope you can improve that .. proper time management can help a lot anyhow.

i'm looking forward to any improvements !

tissatussa commented 1 month ago

i just updated the above game by adding a little animated GIF to display it.

i'm just testing your newest v17 (compiling on Linux went well) in CuteChess GUI and it seems to run fine .. i set a 15m10s game, a Rapid tc, and PP uses about 30 seconds each move, consistently - this 30 goes down slowly to 29-28-27 etc while the game develops .. i see no output during the evaluation process, only after bestmove is output we see the info lines of all reached depths .. can you output each line after each depth is finished, so the development / accuracy of 'bestmove' is visible ? that would be nice, and probably easy to code, but i don't know (are all depths intertwined ?)

Jakob256 commented 1 month ago

Hi! I love the gif 😀

Yeah, this is actually a bug of the engine. In fact, it does output every line after each finished depth. But for some reason the GUI (I noticed it with Arena) does not show the search statistics until the search is finished. I will look into why this happens and inform you when it is fixed

tissatussa commented 1 month ago

nice .. i noticed other chess engine programmers having the same issue, it seems complicated to output info during search .. many authors use a second thread to access the search process at any time - also to get the latest bestmove (when time's up), stop the engine, etc. But implementing multi thread can also be hard, but worth to build i think.

Jakob256 commented 1 month ago

i pushed a fix for the bug. It was as simple as changing a \n to std::endl, so the output is immediately flushed. Now the best move after each finished depth is displayed in Arena. Please let me know if the problem persists for you