Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.1

Bug #2018 promoted pawns moved on/to the back rank disappear
Submitted: 2004-07-29 23:08 UTC
From: cellog Assigned: cellog
Status: Closed Package: Games_Chess
PHP Version: n/a OS: n/a
Roadmaps: (Not assigned)    

 [2004-07-29 23:08 UTC] cellog
Description: ------------ This move list causes it with the demo: Moves # White Black 1 e4 c5 2 d4 cxd4 3 Qxd4 Nc6 4 Qd1 Nf6 5 Bd3 d5 6 Nc3 d4 7 e5 Nxe5 8 Bf4 Nxd3+ 9 Qxd3 dxc3 10 Qxd8+ Kxd8 11 Rd1+ Ke8 12 bxc3 Bf5 13 Rc1 Nd5 14 Ne2 Nxf4 15 Nxf4 Rc8 16 O-O Rxc3 17 Ne2 Rxc2 18 Rxc2 Bxc2 19 Rc1 Bf5 20 Nd4 e6 21 Nxf5 exf5 22 Re1+ Be7 23 Re5 g6 24 Kf1 f6 25 Re2 Kf7 26 Rb2 b6 27 a4 Rc8 28 a5 Bc5 29 a6 Rc6 30 Rd2 h5 31 h4 g5 32 g3 Kg6 33 Kg2 Re6 34 Rd7 b5 35 hxg5 fxg5 36 f3 Rxa6 37 Kh3 g4+ 38 fxg4 hxg4+ 39 Kh4 Bf2 40 Rb7 f4 41 Kxg4 Bxg3 42 Rxb5 Rf6 43 Rb7 a6 44 Ra7 Be1 45 Kf3 a5 46 Ke2 Bb4 47 Kf3 Kg5 48 Rg7+ Rg6 49 Rf7 Rf6 50 Rg7+ Kf5 51 Rh7 a4 52 Rh5+ Ke6 53 Rb5 Bd2 54 Rb4 a3 55 Ra4 Bc1 56 Re4+ Kd5 57 Ra4 Re6 58 Ra5+ Kc4 59 Ra4+ Kb5 60 Ra7 Ra6 61 Rb7+ Rb6 62 Ra7 Kb4 63 Ra8 Rb5 64 Ra6 Kb3 65 Rc6 Be3 66 Ra6 a2 67 Ra8 Kb2 68 Rh8 a1=Q 69 Rh2+ Kc3 70 Rc2+ Kxc2 71 Ke4 Qh1 Expected result: ---------------- Checkmate Actual result: -------------- A whole slew of errors on line 410 of Standard.php in Games_Chess_Standard::inCheck(), and the Queen disappears from the board


 [2004-09-23 15:23 UTC] bastiaan at ricardis dot tudelft dot nl
I have the same but than with the following move list: Moves # White Black 1 e4 b6 2 Qg4 h6 3 Bb5 Ba6 4 Bxd7+ Qxd7 5 Qxd7+ Kxd7 6 e5 Kc8 7 b4 h5 8 b5 h4 9 Ba3 h3 10 Bxe7 Rh4 11 Bxf8 Rg4 12 e6 Rh4 13 e7 Rg4 14 e8=Q+ Kb7 15 bxa6+ Kxa6 16 Bb4 Rg5 17 a4 Rg6 18 a5 Rg5 19 Qc8 The error I get is: Warning: in_array(): Wrong datatype for second argument in /var/www/Games/Chess/Standard.php on line 410 Please fix it. Bastiaan
 [2004-09-23 16:19 UTC] cellog
bastiaan: this is not the same bug if you don't get the same error message, please open a new bug. I will fix it when I have time.
 [2004-09-23 18:23 UTC] bastiaan at ricardis dot tudelft dot nl
sorry but it IS the same bug, it happens on the same line in the execution, in the same function. I think it has something to do with the promotion piece. I have seen this error three times now and it involves a promotion piece everytime. I will see if I can make a faster reproducable case.
 [2004-09-23 18:33 UTC] bastiaan at ricardis dot tudelft dot nl
Ok I know for sure that it has to do with the promotion! Just try this FEN: rnk2Bn1/p1p1Ppp1/bp6/1P6/6r1/7p/P1PP1PPP/RN2K1NR w KQ - 0 0 And do the following moves: e8=Q+ Kb7 bxa6+ Kxa6 Bb4 Rg5 a4 Rg6 a5 Rg5 Qc8 This produces the error on line 410. However, if you take a FEN that has been created after the promotion than you will not have any problems with that last move. I see in cellog's report that there is a promotion too and the error is caused when moving the promoted piece into checkmate. I hope this is enough information to fix it. I would love to have this bug removed.
 [2004-09-24 09:42 UTC] bastiaan at ricardis dot tudelft dot nl
I think I have fixed the bug, I have tested with 5 cases and all behave normal. My fix is to change line 451 of Standard.php from: if ($to{1} == '8' || $to{1} == '1') { to: if (!empty($promote) and ($to{1} == '8' || $to{1} == '1')) { This way not every pawn that is promoted and then moved to row 1 or 8 is taken from the board. I will try to help fix bugs in the future. Cheers, Bastiaan
 [2004-09-24 16:48 UTC] cellog
great detective work. If you don't mind, would you be willing to guinea pig your work for a little while before I do a new release? I would like to write a unit test that verifies the bug with the existing code, and then apply the fix. If you're feeling extra-motivated, then go ahead and write the test yourself. I'm very close to having my system enough in order to be able to do this work. Incidentally, some code that is sitting on my hard drive untested is the ability to calculate ratings, ICC-style. I don't know how to test this properly without starting a fake ICC account, playing a few games, and logging how the rating changes, but if you would like to see that code, I can get it in order over the next week also. Greg
 [2004-10-01 17:40 UTC] cellog
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on In case this was a website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better.