diff --git a/chess/pgn.py b/chess/pgn.py index 7ede45bb2..6f060a1d0 100644 --- a/chess/pgn.py +++ b/chess/pgn.py @@ -398,7 +398,10 @@ def board(self, _cache=False): Unless the `SetUp` and `FEN` header tags are set this is the default starting position. """ - chess960 = self.headers.get("Variant", "").lower() == "chess960" + chess960 = self.headers.get("Variant", "").lower() in [ + "chess960", + "fischerandom", # Cutechess + "fischerrandom"] if chess960 or "Variant" not in self.headers: VariantBoard = chess.Board diff --git a/data/pgn/cutechess-fischerrandom.pgn b/data/pgn/cutechess-fischerrandom.pgn new file mode 100644 index 000000000..2fdbd09fe --- /dev/null +++ b/data/pgn/cutechess-fischerrandom.pgn @@ -0,0 +1,190 @@ +[Event "?"] +[Site "?"] +[Date "2016.07.28"] +[Round "1"] +[White "Maverick 1.5"] +[Black "Stockfish 7"] +[Result "0-1"] +[FEN "nbbrknrq/pppppppp/8/8/8/8/PPPPPPPP/NBBRKNRQ w KQkq - 0 1"] +[PlyCount "120"] +[SetUp "1"] +[TimeControl "10+0.05"] +[Variant "fischerandom"] + +1. d4 {+0.13/12 0.29s} d5 {-0.17/15 0.30s} 2. c3 {+0.22/13 0.28s} +Nb6 {-0.17/14 0.14s} 3. e4 {+0.21/13 0.95s} dxe4 {+0.14/13 0.29s} +4. Bxe4 {+0.25/12 0.22s} g6 {-0.03/15 0.69s} 5. g4 {+0.31/11 0.30s} +c6 {+0.26/13 0.19s} 6. Qf3 {+0.29/11 0.30s} Ne6 {+0.25/15 0.67s} +7. Nb3 {+0.22/10 0.35s} Qf6 {+0.23/15 0.14s} 8. Qxf6 {+0.34/12 0.27s} +exf6 {+0.25/15 0.13s} 9. h4 {+0.32/12 0.39s} O-O {+0.20/15 0.073s} +10. Be3 {+0.15/11 0.33s} Nf4 {+0.68/14 0.60s} 11. Nc5 {+0.21/10 0.17s} +Rfe8 {+0.77/15 0.34s} 12. Nd2 {0.00/10 0.25s} Nbd5 {+1.24/14 0.27s} +13. c4 {0.00/10 0.16s} b6 {+1.51/14 0.19s} 14. cxd5 {-0.26/10 0.15s} +cxd5 {+1.69/12 0.030s} 15. Bc2 {-1.01/10 0.23s} bxc5 {+2.00/14 0.29s} +16. Nb3 {-1.29/11 0.17s} c4 {+1.82/15 0.50s} 17. Nc5 {-1.25/13 0.22s} +Bd6 {+2.05/15 0.19s} 18. Ba4 {-1.31/10 0.20s} Re7 {+1.91/15 0.27s} +19. Bc2 {-1.46/10 0.15s} h5 {+2.11/16 0.82s} 20. gxh5 {-1.62/12 0.20s} +Nxh5 {+1.89/16 0.43s} 21. O-O-O {-1.50/11 0.22s} Nf4 {+2.04/15 0.36s} +22. Rde1 {-1.74/10 0.13s} Kg7 {+2.14/15 0.20s} 23. h5 {-1.65/11 0.15s} +Nxh5 {+2.23/12 0.030s} 24. Kd2 {-1.92/10 0.19s} f5 {+2.43/14 0.36s} +25. Bg5 {-1.74/10 0.15s} Rxe1 {+2.37/15 0.22s} 26. Rxe1 {-2.13/11 0.17s} +f6 {+3.39/15 0.20s} 27. Bh4 {-2.74/13 0.14s} g5 {+3.22/13 0.13s} +28. Rg1 {-2.88/13 0.15s} Rh8 {+4.22/15 0.44s} 29. Bd1 {-2.88/10 0.15s} +Kf8 {+4.10/16 0.24s} 30. Bg3 {-3.61/12 0.14s} f4 {+4.29/16 0.25s} +31. Bh2 {-3.70/13 0.15s} Ng7 {+4.40/14 0.038s} 32. Rh1 {-4.06/14 0.23s} +Nf5 {+4.48/16 0.17s} 33. Bg4 {-4.56/13 0.11s} Ke7 {+4.60/14 0.021s} +34. Bxf5 {-4.14/11 0.13s} Bxf5 {+4.70/16 0.16s} 35. f3 {-4.34/12 0.25s} +Rh3 {+4.84/15 0.092s} 36. Ke2 {-5.89/12 0.32s} g4 {+4.83/13 0.025s} +37. fxg4 {-4.74/11 0.13s} Bg6 {+4.91/15 0.079s} 38. Ke1 {-4.95/10 0.12s} +Bxc5 {+5.01/13 0.038s} 39. dxc5 {-5.95/12 0.14s} Be4 {+5.22/14 0.11s} +40. a4 {-6.42/12 0.38s} Bxh1 {+5.82/13 0.079s} 41. Bxf4 {-7.92/12 0.12s} +d4 {+5.91/13 0.033s} 42. Kd2 {-6.92/10 0.083s} Kd7 {+6.10/14 0.082s} +43. g5 {-7.26/10 0.11s} fxg5 {+6.57/15 0.11s} 44. Bxg5 {-8.34/10 0.091s} +Kc6 {+6.81/13 0.026s} 45. Bf4 {-8.56/11 0.20s} Kxc5 {+7.90/15 0.14s} +46. a5 {-8.94/11 0.17s} Be4 {+11.14/16 0.22s} 47. a6 {-9.64/10 0.10s} +Rb3 {+15.84/15 0.094s} 48. Kc1 {-11.49/13 0.12s} c3 {+48.50/24 0.078s} +49. bxc3 {-10.88/13 0.088s} dxc3 {+48.54/23 0.018s} 50. Kd1 {-11.10/13 0.17s} +c2+ {+M35/23 0.14s} 51. Ke2 {-10.72/12 0.16s} Rb1 {+M31/23 0.024s} +52. Bd2 {-11.36/12 0.080s} c1=Q {+M21/24 0.076s} 53. Bxc1 {-12.14/14 0.11s} +Rxc1 {+M19/23 0.025s} 54. Ke3 {-12.35/13 0.072s} Kd5 {+M15/23 0.10s} +55. Kf2 {-M18/13 0.14s} Kd4 {+M11/24 0.070s} 56. Kg3 {-M10/12 0.026s} +Ke3 {+M9/24 0.016s} 57. Kg4 {-M8/8 0.001s} Rg1+ {+M7/40 0.063s} +58. Kh5 {-M6/6 0.001s} Kf4 {+M5/91 0.015s} 59. Kh6 {-M4/4 0.002s} +Rg2 {+M3/127 0.004s} 60. Kh5 {-M2/2 0.001s} Rh2# {+M1/127 0.003s, Black mates} +0-1 + +[Event "?"] +[Site "?"] +[Date "2016.07.28"] +[Round "1"] +[White "Stockfish 7"] +[Black "Maverick 1.5"] +[Result "1-0"] +[FEN "rqkrbnnb/pppppppp/8/8/8/8/PPPPPPPP/RQKRBNNB w KQkq - 0 1"] +[PlyCount "99"] +[SetUp "1"] +[TimeControl "10+0.05"] +[Variant "fischerandom"] + +1. g3 {+0.14/14 0.54s} g6 {-0.11/13 0.39s} 2. e4 {+0.12/14 0.31s} +Ne6 {+0.01/12 0.22s} 3. c3 {+0.32/15 0.54s} d6 {+0.31/12 0.25s} +4. d4 {+0.64/15 0.64s} Nf6 {+0.15/12 0.27s} 5. Ne3 {+0.55/14 0.29s} +Bg7 {+0.02/12 0.39s} 6. f4 {+0.72/15 1.1s} h5 {-0.25/11 0.32s} +7. Bf3 {+0.87/14 0.27s} Ba4 {-0.57/11 0.38s} 8. b3 {+0.94/13 0.18s} +Bd7 {-0.67/13 0.25s} 9. Kb2 {+0.91/14 0.65s} Nf8 {-0.44/11 0.31s} +10. h3 {+1.22/12 0.10s} e5 {-0.29/12 0.46s} 11. dxe5 {+1.53/13 0.27s} +dxe5 {-0.44/13 0.19s} 12. fxe5 {+1.49/14 0.51s} Ng8 {-0.40/12 0.30s} +13. g4 {+1.65/13 0.16s} hxg4 {-0.58/11 0.27s} 14. Bxg4 {+1.86/14 0.33s} +Bxe5 {-0.50/12 0.19s} 15. Nf3 {+2.20/14 0.23s} Bf4 {-0.79/12 0.19s} +16. Bh4 {+2.73/14 0.17s} Re8 {-0.87/12 0.16s} 17. Qd3 {+4.34/14 0.17s} +f5 {-2.56/13 0.17s} 18. Nxf5 {+4.28/15 0.30s} gxf5 {-2.69/14 0.17s} +19. Bxf5 {+4.68/15 0.061s} Bd6 {-3.08/14 0.22s} 20. e5 {+5.62/14 0.23s} +Nh6 {-3.56/13 0.37s} 21. Bxd7+ {+6.66/14 0.15s} Nxd7 {-3.81/12 0.13s} +22. Qg6 {+7.05/14 0.060s} Rf8 {-4.75/11 0.17s} 23. e6 {+8.47/15 0.36s} +b5 {-5.56/12 0.46s} 24. exd7+ {+9.50/15 0.28s} Kxd7 {-6.15/12 0.24s} +25. Ne5+ {+10.51/18 0.10s} Kc8 {-6.52/11 0.036s} 26. Qe6+ {+10.58/15 0.021s} +Kb7 {-5.07/8 0.021s} 27. Rxd6 {+11.11/19 0.24s} cxd6 {-10.56/11 0.22s} +28. Qd5+ {+11.15/16 0.062s} Kc8 {-11.09/15 0.24s} 29. Qc6+ {+11.23/17 0.13s} +Qc7 {-11.23/15 0.034s} 30. Qxa8+ {+11.31/15 0.066s} Qb8 {-11.23/15 0.038s} +31. Qxb8+ {+11.41/16 0.14s} Kxb8 {-11.23/13 0.030s} 32. Nd7+ {+11.39/15 0.034s} +Kb7 {-11.74/14 0.51s} 33. Nxf8 {+11.46/16 0.12s} Nf5 {-11.71/13 0.25s} +34. Bg5 {+11.51/15 0.032s} Kc6 {-11.69/11 0.26s} 35. h4 {+11.75/15 0.095s} +Ng3 {-12.05/11 0.12s} 36. Ne6 {+12.06/14 0.31s} Ne4 {-12.04/10 0.17s} +37. Nd4+ {+12.31/13 0.090s} Kb6 {-12.39/11 0.14s} 38. Bf4 {+12.75/15 0.22s} +a6 {-11.93/9 0.13s} 39. h5 {+15.20/16 0.20s} Kc5 {-13.49/11 0.26s} +40. h6 {+21.53/15 0.24s} Nf6 {-14.72/12 0.12s} 41. Re1 {+22.26/13 0.053s} +b4 {-14.64/11 0.13s} 42. Bxd6+ {+M21/19 0.20s} Kxd6 {-17.58/12 0.10s} +43. Re6+ {+M17/21 0.095s} Kd7 {-17.90/12 0.12s} 44. Rxf6 {+M15/21 0.047s} +Ke7 {-M18/11 0.25s} 45. Rf5 {+M13/19 0.069s} Kd6 {-M12/12 0.12s} +46. h7 {+M11/20 0.085s} a5 {-M10/10 0.010s} 47. h8=Q {+M9/20 0.076s} +Kc7 {-M8/8 0.007s} 48. Qg7+ {+M5/127 0.031s} Kd6 {-M4/4 0.001s} +49. Nb5+ {+M3/127 0.003s} Kc6 {-M2/2 0s} 50. Qc7# {+M1/127 0.003s, White mates} +1-0 + +[Event "?"] +[Site "?"] +[Date "2016.07.28"] +[Round "1"] +[White "Maverick 1.5"] +[Black "Stockfish 7"] +[Result "0-1"] +[FEN "rnkqnbbr/pppppppp/8/8/8/8/PPPPPPPP/RNKQNBBR w KQkq - 0 1"] +[PlyCount "70"] +[SetUp "1"] +[TimeControl "10+0.05"] +[Variant "fischerandom"] + +1. f4 {+0.30/11 0.23s} d5 {-0.09/13 0.15s} 2. Nc3 {+0.50/11 0.35s} +Nf6 {+0.03/14 0.27s} 3. Nf3 {+0.41/13 0.40s} e6 {+0.08/13 0.18s} +4. Bd4 {+0.33/12 0.42s} h6 {+0.32/13 0.29s} 5. e3 {+0.30/11 0.23s} +Ng4 {+0.24/13 0.16s} 6. Qe1 {+0.26/12 0.35s} c5 {+0.61/14 0.11s} +7. Be5 {+0.37/13 0.23s} Nc6 {+0.60/14 0.30s} 8. Bb5 {+0.23/13 0.54s} +Ngxe5 {+0.66/14 0.30s} 9. fxe5 {+0.10/13 0.23s} Bh7 {+0.55/13 0.069s} +10. Bxc6 {+0.28/11 0.20s} bxc6 {+0.76/14 0.35s} 11. Rf1 {+0.08/11 0.58s} +Rb8 {+1.28/13 0.22s} 12. b3 {0.00/10 0.32s} Rb7 {+1.54/13 0.20s} +13. e4 {-0.03/9 0.17s} c4 {+1.73/15 0.53s} 14. Qe3 {-0.31/9 0.19s} +Qa5 {+1.85/14 0.76s} 15. Nd4 {-0.57/8 0.19s} c5 {+3.82/13 0.34s} +16. Nxe6 {-1.50/10 0.18s} cxb3 {+3.82/15 0.45s} 17. cxb3 {-1.25/10 0.23s} +fxe6 {+4.14/13 0.15s} 18. exd5 {-1.72/10 0.17s} exd5 {+4.05/13 0.23s} +19. Qh3+ {-1.57/10 0.39s} Kb8 {+4.59/14 0.20s} 20. Nxd5 {-1.62/10 0.14s} +c4 {+8.22/14 0.32s} 21. Qe6 {-4.82/10 0.34s} Bc5 {+11.06/14 0.26s} +22. Kd1 {-6.91/10 0.48s} cxb3 {+12.77/14 0.20s} 23. d4 {-8.16/10 0.24s} +b2 {+21.67/14 0.23s} 24. Rb1 {-14.22/11 0.36s} Qa4+ {+23.31/14 0.24s} +25. Ke1 {-14.18/11 0.14s} Qxd4 {+30.39/15 0.80s} 26. Rf3 {-18.19/9 0.11s} +Qe4+ {+30.58/13 0.026s} 27. Ne3 {-21.85/11 0.16s} Qxb1+ {+40.76/14 0.84s} +28. Kf2 {-24.98/12 0.26s} Qe4 {+41.45/13 0.047s} 29. Kg3 {-24.92/12 0.56s} +b1=Q {+M21/13 0.18s} 30. Qg4 {-42.56/12 0.49s} Bxe3 {+M11/17 0.16s} +31. Qxe4 {-M18/10 0.11s} Qxe4 {+M9/20 0.022s} 32. a3 {-M8/11 0.32s} +g5 {+M7/30 0.094s} 33. h3 {-M6/6 0.005s} Qxe5+ {+M5/46 0.021s} +34. Kg4 {-M8/8 0.003s} h5+ {+M3/127 0.004s} 35. Kxh5 {-M2/2 0s} +Bf5# {+M1/127 0.003s, Black mates} 0-1 + +[Event "?"] +[Site "?"] +[Date "2016.07.28"] +[Round "1"] +[White "Stockfish 7"] +[Black "Maverick 1.5"] +[Result "1-0"] +[FEN "nbrnbkqr/pppppppp/8/8/8/8/PPPPPPPP/NBRNBKQR w KQkq - 0 1"] +[PlyCount "107"] +[SetUp "1"] +[TimeControl "10+0.05"] +[Variant "fischerandom"] + +1. c4 {+0.13/15 0.38s} c5 {-0.41/13 0.34s} 2. f3 {+0.17/14 0.36s} +Be5 {-0.27/13 0.29s} 3. Nb3 {+0.26/14 0.20s} d6 {-0.30/14 0.34s} +4. e3 {+0.11/15 0.67s} Nb6 {+0.08/12 0.32s} 5. d4 {0.00/14 0.60s} +cxd4 {+0.02/13 0.22s} 6. exd4 {+0.05/15 0.22s} Bf4 {-0.07/13 0.25s} +7. Bd2 {-0.05/12 0.029s} Bxd2 {-0.08/13 0.25s} 8. Nxd2 {+0.50/13 0.16s} +Bd7 {-0.12/12 0.23s} 9. b3 {+0.69/13 0.15s} Nc6 {-0.23/11 0.37s} +10. Nc3 {+0.85/14 0.35s} f6 {-0.33/11 0.23s} 11. d5 {+1.24/14 0.39s} +Ne5 {-0.83/11 0.19s} 12. f4 {+1.51/15 0.57s} Ng6 {-0.85/11 0.28s} +13. Qf2 {+1.67/16 0.36s} Qf7 {-0.67/11 0.17s} 14. a4 {+1.74/15 0.36s} +Rc7 {-0.99/11 0.29s} 15. Bd3 {+1.89/16 0.43s} O-O {-1.09/11 0.39s} +16. O-O {+1.80/15 0.077s} f5 {-1.07/11 0.19s} 17. g3 {+1.96/15 0.25s} +Nc8 {-1.09/10 0.18s} 18. Nf3 {+1.87/14 0.33s} a5 {-1.18/11 0.60s} +19. Ng5 {+2.46/14 0.24s} Qf6 {-1.35/14 0.19s} 20. Nb5 {+2.37/13 0.040s} +Bxb5 {-2.07/14 0.16s} 21. axb5 {+3.17/15 0.41s} Rd7 {-2.19/13 0.16s} +22. Ne6 {+3.39/14 0.11s} Re8 {-2.69/13 0.34s} 23. Qc2 {+3.75/15 0.34s} +Nb6 {-2.58/12 0.17s} 24. Bxf5 {+4.00/14 0.26s} Rc8 {-3.29/11 0.21s} +25. Ng5 {+4.98/13 0.099s} Kh8 {-4.05/11 0.20s} 26. Be6 {+4.99/12 0.024s} +Qd4+ {-4.27/11 0.12s} 27. Kh1 {+5.51/15 0.19s} Nf8 {-4.33/11 0.15s} +28. Rfe1 {+5.56/14 0.031s} a4 {-5.63/11 0.37s} 29. bxa4 {+5.70/15 0.16s} +g6 {-4.90/10 0.11s} 30. Re4 {+6.24/14 0.13s} Qf6 {-5.64/13 0.17s} +31. a5 {+6.28/13 0.031s} Nxd5 {-5.63/12 0.38s} 32. Bxd5 {+6.81/14 0.37s} +h6 {-6.27/12 0.60s} 33. Ne6 {+7.60/15 0.15s} Nh7 {-6.31/11 0.10s} +34. a6 {+8.36/16 0.23s} b6 {-6.96/12 0.20s} 35. Qa2 {+9.66/16 0.24s} +Ra7 {-7.23/12 0.13s} 36. Qf2 {+9.66/16 0.18s} Rb8 {-8.02/12 0.17s} +37. Nd4 {+9.86/15 0.029s} Ng5 {-9.02/12 0.19s} 38. Nc6 {+10.75/15 0.12s} +Nxe4 {-8.81/12 0.15s} 39. Bxe4 {+10.89/13 0.029s} d5 {-9.34/13 0.16s} +40. Bxd5 {+11.75/15 0.15s} Rba8 {-10.57/13 0.21s} 41. Nxa7 {+13.36/17 0.31s} +Rxa7 {-10.97/12 0.13s} 42. c5 {+13.46/14 0.023s} Rc7 {-10.67/11 0.13s} +43. Bc6 {+16.80/14 0.17s} Rxc6 {-11.13/9 0.094s} 44. bxc6 {+18.21/13 0.11s} +Qxc6+ {-14.47/9 0.17s} 45. Qg2 {+21.11/14 0.31s} Qa4 {-17.24/10 0.17s} +46. cxb6 {+27.63/15 0.41s} Qxa6 {-17.80/9 0.10s} 47. Qb2+ {+56.80/14 0.085s} +Kh7 {-19.85/10 0.19s} 48. b7 {+M19/15 0.045s} Qd6 {-17.43/11 0.31s} +49. b8=Q {+M13/17 0.060s} Qxb8 {-M12/13 0.25s} 50. Qxb8 {+M9/28 0.063s} +g5 {-M8/8 0.001s} 51. Qe8 {+M7/31 0.058s} Kg7 {-M6/6 0.001s} +52. Rc6 {+M5/77 0.014s} g4 {-M4/4 0.001s} 53. Qxe7+ {+M3/127 0.002s} +Kg8 {-M2/2 0.001s} 54. Rc8# {+M1/127 0.002s, White mates} 1-0 diff --git a/test.py b/test.py index 282586885..d2cd29744 100755 --- a/test.py +++ b/test.py @@ -2088,6 +2088,13 @@ def test_variants(self): game.setup(chess.Board()) self.assertNotIn("Variant", game.headers) + def test_cutechess_fischerrandom(self): + with open("data/pgn/cutechess-fischerrandom.pgn") as pgn: + game = chess.pgn.read_game(pgn) + board = game.board() + self.assertTrue(board.chess960) + self.assertEqual(board.fen(), "nbbrknrq/pppppppp/8/8/8/8/PPPPPPPP/NBBRKNRQ w KQkq - 0 1") + class StockfishTestCase(unittest.TestCase):