Example #1
0
    public function testinThreefoldRepetition()
    {
        $chess = new ChessPublicator();
        /*
         * [Event "Fischer - Petrosian Candidates Final"]
         * [Site "Buenos Aires ARG"]
         * [Date "1971.10.07"]
         * [EventDate "1971.09.30"]
         * [Round "3"]
         * [Result "1/2-1/2"]
         * [White "Robert James Fischer"]
         * [Black "Tigran Vartanovich Petrosian"]
         * [ECO "C11"]
         * [WhiteElo "?"]
         * [BlackElo "?"]
         * [PlyCount "67"]
         */
        $match = '1. e4 e6 2. d4 d5 3. Nc3 Nf6 4. Bg5 dxe4 5. Nxe4 Be7 6. Bxf6
		gxf6 7. g3 f5 8. Nc3 Bf6 9. Nge2 Nc6 10. d5 exd5 11. Nxd5 Bxb2
		12. Bg2 O-O 13. O-O Bh8 14. Nef4 Ne5 15. Qh5 Ng6 16. Rad1 c6
		17. Ne3 Qf6 18. Kh1 Bg7 19. Bh3 Ne7 20. Rd3 Be6 21. Rfd1 Bh6
		22. Rd4 Bxf4 23. Rxf4 Rad8 24. Rxd8 Rxd8 25. Bxf5 Nxf5
		26. Nxf5 Rd5 27. g4 Bxf5 28. gxf5 h6 29. h3 Kh7 30. Qe2 Qe5
		31. Qh5 Qf6 32. Qe2 Re5 33.Qd3 Rd5 34.Qe2';
        $moves = preg_replace("/([0-9]{0,})\\./", "", $match);
        $moves = str_replace('  ', ' ', str_replace("\r", ' ', str_replace("\n", ' ', str_replace("\t", '', $moves))));
        $moves = explode(' ', trim($moves));
        foreach ($moves as $move) {
            $this->assertNotNull($chess->move($move), $move);
        }
        $this->assertSame($chess->inThreefoldRepetition(), true);
    }