ConorGriffin37 / chess

Chess Engine and GUI
MIT License
8 stars 1 forks source link

Time management broken #23

Open tpoppins opened 5 years ago

tpoppins commented 5 years ago

This is related to #22 but is more general.

Saruman never produces a bestmove unless the go command is followed by wtime. However, it appears to ignore the values of wtime, btime and movestogo and whatever time control -- 40/4 or 40/40 -- almost never spends more than a fraction of a second on a move.

An example game, TC=40 moves in 20 minutes repeating (local equivalent of CCRL's 40/40):

[Event "Below Decks 40/40 #5"]
[Site "Dual E5-2690v2"]
[Date "2019.04.09"]
[Round "1"]
[White "Saruman 2017.08.10 64-bit"]
[Black "Apep 1.01"]
[Result "0-1"]
[ECO "A50"]
[GameDuration "00:42:19"]
[GameEndTime "2019-04-09T15:20:04.207 Eastern Daylight Time"]
[GameStartTime "2019-04-09T14:37:44.272 Eastern Daylight Time"]
[Opening "Kevitz-Trajkovich defense"]
[PlyCount "177"]
[Termination "adjudication"]
[TimeControl "40/1200"]

1. d4 {book} Nf6 {book} 2. c4 {book} Nc6 {book} 3. Nf3 {book} e6 {book}
4. Bf4 {book} Bb4+ {book} 5. Nbd2 {-0.10/7 0.34s} O-O {34s} 6. e3 {0.00/7 0.27s}
d6 {35s} 7. a3 {+0.05/7 1.0s} Bxd2+ {34s} 8. Qxd2 {0.00/7 0.13s} Qe7 {34s}
9. Qc3 {0.00/7 0.32s} Ne4 {34s} 10. Qc2 {+0.05/7 0.20s} f5 {34s}
11. d5 {+0.10/7 0.29s} e5 {34s} 12. Bg3 {-0.05/7 0.24s} Nxg3 {34s}
13. hxg3 {0.00/7 0.092s} Nd8 {34s} 14. O-O-O {+0.10/7 0.35s} c5 {34s}
15. e4 {+0.35/7 0.21s} fxe4 {34s} 16. Qxe4 {+0.25/7 0.095s} Bf5 {34s}
17. Qe3 {+0.15/7 0.19s} Nf7 {34s} 18. Bd3 {+0.15/7 0.27s} Bxd3 {34s}
19. Rxd3 {+0.10/7 0.14s} e4 {34s} 20. Rdd1 {+0.10/7 0.17s} Rae8 {33s}
21. Rhe1 {+0.05/7 0.19s} Nh6 {33s} 22. Nd2 {+0.10/7 0.24s} Ng4 {34s}
23. Qxe4 {+0.15/7 0.057s} Qd7 {33s} 24. Qc2 {-0.05/7 0.060s} Nxf2 {33s}
25. Rxe8 {-0.30/7 0.063s} Rxe8 {33s} 26. Rf1 {+0.05/7 0.089s} Re2 {34s}
27. Qc3 {-0.10/7 0.23s} Qf5 {33s} 28. Qf3 {-1.05/7 0.12s} Qd3 {33s}
29. Qxd3 {-1.80/7 0.034s} Nxd3+ {33s} 30. Kc2 {-1.20/9 0.070s} Ne5 {33s}
31. Kc3 {-0.65/9 0.11s} Re3+ {33s} 32. Kc2 {-0.65/9 0.062s} Re2 {33s}
33. Kc3 {-0.65/9 0.032s} a6 {33s} 34. Rg1 {-0.60/9 0.18s} Re3+ {33s}
35. Kc2 {-0.60/9 0.075s} b5 {33s} 36. cxb5 {-0.65/9 0.21s} axb5 {32s}
37. Nf3 {-0.65/9 0.32s} Re2+ {32s} 38. Kc3 {-0.65/9 0.075s} Re3+ {32s}
39. Kc2 {-0.65/9 0.021s} Re2+ {32s} 40. Kc3 {-0.65/9 0.030s} Nc4 {31s}
41. Nh4 {-0.65/9 0.46s} Rxb2 {30s} 42. a4 {-0.75/9 0.17s} Rb4 {30s}
43. axb5 {-1.15/9 0.20s} Ne3 {30s} 44. Kd3 {-1.30/9 0.23s} Nxd5 {30s}
45. Rf1 {-1.50/9 1.2s} Rxb5 {30s} 46. Nf5 {-1.45/9 0.17s} Rb6 {30s}
47. Rd1 {-1.45/9 0.52s} Nc7 {30s} 48. Ke3 {-1.45/9 1.2s} Ne8 {30s}
49. Rf1 {-1.50/9 0.73s} g6 {30s} 50. Ne7+ {-1.65/9 0.41s} Kg7 {30s}
51. Nd5 {-1.80/9 2.0s} Rb3+ {30s} 52. Kf4 {-2.00/9 0.11s} Nf6 {30s}
53. Nxf6 {-2.10/9 0.070s} Kxf6 {29s} 54. Kg4+ {-2.00/9 0.11s} Ke5 {29s}
55. Re1+ {-2.15/9 0.078s} Kd5 {30s} 56. Rd1+ {-2.05/9 0.11s} Kc6 {29s}
57. Rh1 {-2.10/9 0.074s} h5+ {29s} 58. Kf4 {-2.15/9 0.057s} Rb4+ {29s}
59. Kf3 {-2.25/9 0.083s} Rb3+ {29s} 60. Kf4 {-2.15/9 0.023s} Rb4+ {29s}
61. Kf3 {-2.25/9 0.033s} c4 {29s} 62. g4 {-2.10/9 0.11s} hxg4+ {30s}
63. Kxg4 {-2.00/9 0.15s} c3+ {29s} 64. Kg5 {-1.90/9 0.074s} c2 {29s}
65. Rc1 {-2.00/9 0.048s} Rc4 {29s} 66. Kxg6 {-2.35/9 0.080s} Kd5 {29s}
67. Kf5 {-1.70/9 0.041s} Rc7 {29s} 68. Kf4 {-1.70/9 0.030s} Kd4 {29s}
69. Kf5 {-3.60/9 0.093s} Kd3 {29s} 70. Ke6 {-4.40/9 0.038s} Kd2 {29s}
71. Rf1 {-4.90/9 0.034s} c1=Q {29s} 72. Rxc1 {-4.90/9 0.022s} Rxc1 {29s}
73. Kxd6 {-5.00/9 0.015s} Rg1 {29s} 74. Kd5 {-5.00/9 0.013s} Rxg2 {28s}
75. Kd4 {-5.00/9 0.016s} Rg4+ {28s} 76. Ke5 {-5.20/9 0.014s} Rh4 {28s}
77. Kd5 {-5.15/9 0.016s} Ke3 {28s} 78. Ke5 {-5.20/9 0.012s} Re4+ {28s}
79. Kd5 {-5.20/9 0.012s} Kd3 {28s} 80. Kc5 {-5.40/9 0.013s} Re5+ {28s}
81. Kc6 {-5.40/9 0.013s} Kc4 {93s} 82. Kd6 {-5.40/9 0.014s} Re3 {28s}
83. Kc6 {-5.50/9 0.012s} Rd3 {28s} 84. Kc7 {-5.50/9 0.013s} Kb5 {2.9s}
85. Kb7 {-5.70/9 0.011s} Rd7+ {0.75s} 86. Kc8 {-5.70/9 0.010s} Kc6
87. Kb8 {-M8/9 0.012s} Rd8+ 88. Ka7 {-M6/9 0.010s} Rc8
89. Ka6 {-M4/9 0.008s, Black wins by adjudication} 0-1

This bug must cost Saruman several hundred Elo points. The exec used is HK's 2017-08-10 build linked via CCW. Tested under Cute Chess GUI (latest dev build) and Arena 3.5.1.

Tirsa@CCRL

DarraghGriffin commented 5 years ago

Hey @tpoppins

Thanks for filing this, we developed this engine when we were in our first year of university as a side project and didn't really know what we were doing. It's likely got a lot of issues because of this.

I will look into fixing this as it seems like it's just an issue with our UCI implementation.

Darragh