Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move parsed with "x" notation? #13

Open
miklgene1986 opened this issue Mar 9, 2021 · 6 comments
Open

Move parsed with "x" notation? #13

miklgene1986 opened this issue Mar 9, 2021 · 6 comments

Comments

@miklgene1986
Copy link

miklgene1986 commented Mar 9, 2021

Hello, thanks for your library, I'm testing it in my chrome and in one "pgn" file it works little strange. Move "Rcf8" from pgn become "Rcxf8".

The whole PGN file:

[FEN "3qr1k1/pbr2pp1/1p2pn1p/8/3PP3/1B2RN1P/P3QPP1/3R2K1 w - - 0 19"]

Moves:
...
19. d5 {A positional pawn sacrifice that gives white the initiative} exd5
20. e5 {The point. In return, black's light squared bishop will become
passive and her knight will lack stability, while white will get to use the d4
square for her pieces.} Nh5 21. Rd4 g6 22. Qd2
{Threatening Red3} Qe7 23. Nh2 {Improving the knight} (23. Red3 {can now be met with} Ba6) 23... Qc5 24.
Re1 {Avoiding the trade of queens} Qc3 25. Qd1 Rec8 26. e6 $1 {Opening up
black's position} Nf6 27. Ng4 Nxg4 28. Rxg4 Kg7 29. exf7 Rxf7 30. Re6 g5 31.
Kh2 {Once again, white takes the time to prevent black's idea of Qc1,
trading the queens} Qc7+ 32. Rg3 Rcf8 33. Qd4+ Rf6 34. h4 Qc5 $2 {Black was
already under a lot of pressure, but this move allows white to cash in} (34...
Qf4 {was a better try, giving back the g5 pawn} 35. Qxf4 Rxf4 36. hxg5 hxg5 37.
Rxg5+ Kf7 38. Rge5) 35. Qe5 d4 36. hxg5 hxg5 37. Rxg5+ Kh8 38. Rh5+ Kg7 39.
Qg3+ 1-0
...

  1. Look at the pgn move "32. Rg3 Rcf8".

  2. In JS Object it shows like:
    26: {m: "Rg3", from: "g4", to: "g3", fen: "2r5/pbq2rk1/1p2R2p/3p2p1/8/1B4RP/P4PPK/3Q4 b - - 3 32"}
    27: {m: "Rcxf8", from: "c8", to: "f8", fen: "5r2/pbq2rk1/1p2R2p/3p2p1/8/1B4RP/P4PPK/3Q4 w - - 4 33"}

So Rook moves at empty cell, but you lib think it's was after some figure. Why?

So "Rcf8" now "Rcxf8", but should be "Rcf8".

Please help.

P.s:

Whole js object after lib:

0: {m: "d5", comment: "A positional pawn sacrifice that gives white the initiative", from: "d4", to: "d5", fen: "3qr1k1/pbr2pp1/1p2pn1p/3P4/4P3/1B2RN1P/P3QPP1/3R2K1 b - - 0 19"}
1: {m: "exd5", from: "e6", to: "d5", fen: "3qr1k1/pbr2pp1/1p3n1p/3p4/4P3/1B2RN1P/P3QPP1/3R2K1 w - - 0 20"}
2: {m: "e5", comment: "The point. In return, blacks light squared bishop …ite will get to use the d4 square for her pieces.", from: "e4", to: "e5", fen: "3qr1k1/pbr2pp1/1p3n1p/3pP3/8/1B2RN1P/P3QPP1/3R2K1 b - - 0 20"}
3: {m: "Nh5", from: "f6", to: "h5", fen: "3qr1k1/pbr2pp1/1p5p/3pP2n/8/1B2RN1P/P3QPP1/3R2K1 w - - 1 21"}
4: {m: "Rd4", from: "d1", to: "d4", fen: "3qr1k1/pbr2pp1/1p5p/3pP2n/3R4/1B2RN1P/P3QPP1/6K1 b - - 2 21"}
5: {m: "g6", from: "g7", to: "g6", fen: "3qr1k1/pbr2p2/1p4pp/3pP2n/3R4/1B2RN1P/P3QPP1/6K1 w - - 0 22"}
6: {m: "Qd2", comment: "Threatening Red3", from: "e2", to: "d2", fen: "3qr1k1/pbr2p2/1p4pp/3pP2n/3R4/1B2RN1P/P2Q1PP1/6K1 b - - 1 22"}
7: {m: "Qe7", from: "d8", to: "e7", fen: "4r1k1/pbr1qp2/1p4pp/3pP2n/3R4/1B2RN1P/P2Q1PP1/6K1 w - - 2 23"}
8: {m: "Nh2", comment: "Improving the knight", variations: Array(1), from: "f3", to: "h2", …}
9: {m: "Qc5", from: "e7", to: "c5", fen: "4r1k1/pbr2p2/1p4pp/2qpP2n/3R4/1B2R2P/P2Q1PPN/6K1 w - - 4 24"}
10: {m: "Re1", comment: "Avoiding the trade of queens", from: "e3", to: "e1", fen: "4r1k1/pbr2p2/1p4pp/2qpP2n/3R4/1B5P/P2Q1PPN/4R1K1 b - - 5 24"}
11: {m: "Qc3", from: "c5", to: "c3", fen: "4r1k1/pbr2p2/1p4pp/3pP2n/3R4/1Bq4P/P2Q1PPN/4R1K1 w - - 6 25"}
12: {m: "Qd1", from: "d2", to: "d1", fen: "4r1k1/pbr2p2/1p4pp/3pP2n/3R4/1Bq4P/P4PPN/3QR1K1 b - - 7 25"}
13: {m: "Rexc8", from: "e8", to: "c8", fen: "2r3k1/pbr2p2/1p4pp/3pP2n/3R4/1Bq4P/P4PPN/3QR1K1 w - - 8 26"}
14: {m: "e6", comment: "Opening up blacks position", from: "e5", to: "e6", fen: "2r3k1/pbr2p2/1p2P1pp/3p3n/3R4/1Bq4P/P4PPN/3QR1K1 b - - 0 26"}
15: {m: "Nf6", from: "h5", to: "f6", fen: "2r3k1/pbr2p2/1p2Pnpp/3p4/3R4/1Bq4P/P4PPN/3QR1K1 w - - 1 27"}
16: {m: "Ng4", from: "h2", to: "g4", fen: "2r3k1/pbr2p2/1p2Pnpp/3p4/3R2N1/1Bq4P/P4PP1/3QR1K1 b - - 2 27"}
17: {m: "Nxg4", from: "f6", to: "g4", fen: "2r3k1/pbr2p2/1p2P1pp/3p4/3R2n1/1Bq4P/P4PP1/3QR1K1 w - - 0 28"}
18: {m: "Rxg4", from: "d4", to: "g4", fen: "2r3k1/pbr2p2/1p2P1pp/3p4/6R1/1Bq4P/P4PP1/3QR1K1 b - - 0 28"}
19: {m: "Kg7", from: "g8", to: "g7", fen: "2r5/pbr2pk1/1p2P1pp/3p4/6R1/1Bq4P/P4PP1/3QR1K1 w - - 1 29"}
20: {m: "exf7", from: "e6", to: "f7", fen: "2r5/pbr2Pk1/1p4pp/3p4/6R1/1Bq4P/P4PP1/3QR1K1 b - - 0 29"}
21: {m: "Rxf7", from: "c7", to: "f7", fen: "2r5/pb3rk1/1p4pp/3p4/6R1/1Bq4P/P4PP1/3QR1K1 w - - 0 30"}
22: {m: "Re6", from: "e1", to: "e6", fen: "2r5/pb3rk1/1p2R1pp/3p4/6R1/1Bq4P/P4PP1/3Q2K1 b - - 1 30"}
23: {m: "g5", from: "g6", to: "g5", fen: "2r5/pb3rk1/1p2R2p/3p2p1/6R1/1Bq4P/P4PP1/3Q2K1 w - - 0 31"}
24: {m: "Kh2", comment: "Once again, white takes the time to prevent blacks idea of Qc1, trading the queens", from: "g1", to: "h2", fen: "2r5/pb3rk1/1p2R2p/3p2p1/6R1/1Bq4P/P4PPK/3Q4 b - - 1 31"}
25: {m: "Qc7+", from: "c3", to: "c7", fen: "2r5/pbq2rk1/1p2R2p/3p2p1/6R1/1B5P/P4PPK/3Q4 w - - 2 32"}
26: {m: "Rg3", from: "g4", to: "g3", fen: "2r5/pbq2rk1/1p2R2p/3p2p1/8/1B4RP/P4PPK/3Q4 b - - 3 32"}
27: {m: "Rcxf8", from: "c8", to: "f8", fen: "5r2/pbq2rk1/1p2R2p/3p2p1/8/1B4RP/P4PPK/3Q4 w - - 4 33"}
28: {m: "Qd4+", from: "d1", to: "d4", fen: "5r2/pbq2rk1/1p2R2p/3p2p1/3Q4/1B4RP/P4PPK/8 b - - 5 33"}
29: {m: "Rf6", from: "f7", to: "f6", fen: "5r2/pbq3k1/1p2Rr1p/3p2p1/3Q4/1B4RP/P4PPK/8 w - - 6 34"}
30: {m: "h4", from: "h3", to: "h4", fen: "5r2/pbq3k1/1p2Rr1p/3p2p1/3Q3P/1B4R1/P4PPK/8 b - - 0 34"}
31: {m: "Qc5", comment: "Black was already under a lot of pressure, but this move allows white to cash in", variations: Array(1), from: "c7", to: "c5", …}
32: {m: "Qe5", from: "d4", to: "e5", fen: "5r2/pb4k1/1p2Rr1p/2qpQ1p1/7P/1B4R1/P4PPK/8 b - - 2 35"}
33: {m: "d4", from: "d5", to: "d4", fen: "5r2/pb4k1/1p2Rr1p/2q1Q1p1/3p3P/1B4R1/P4PPK/8 w - - 0 36"}
34: {m: "hxg5", from: "h4", to: "g5", fen: "5r2/pb4k1/1p2Rr1p/2q1Q1P1/3p4/1B4R1/P4PPK/8 b - - 0 36"}
35: {m: "hxg5", from: "h6", to: "g5", fen: "5r2/pb4k1/1p2Rr2/2q1Q1p1/3p4/1B4R1/P4PPK/8 w - - 0 37"}
36: {m: "Rxg5+", from: "g3", to: "g5", fen: "5r2/pb4k1/1p2Rr2/2q1Q1R1/3p4/1B6/P4PPK/8 b - - 0 37"}
37: {m: "Kh8", from: "g7", to: "h8", fen: "5r1k/pb6/1p2Rr2/2q1Q1R1/3p4/1B6/P4PPK/8 w - - 1 38"}
38: {m: "Rh5+", from: "g5", to: "h5", fen: "5r1k/pb6/1p2Rr2/2q1Q2R/3p4/1B6/P4PPK/8 b - - 2 38"}
39: {m: "Kg7", from: "h8", to: "g7", fen: "5r2/pb4k1/1p2Rr2/2q1Q2R/3p4/1B6/P4PPK/8 w - - 3 39"}
40: {m: "Qg3+", from: "e5", to: "g3", fen: "5r2/pb4k1/1p2Rr2/2q4R/3p4/1B4Q1/P4PPK/8 b - - 4 39"}

@miklgene1986
Copy link
Author

Hello, any news? Are you here?
Anyway, sorry if I bother you.

@alsator
Copy link

alsator commented Feb 21, 2023 via email

@miklgene1986
Copy link
Author

А не подскажите почему такое может происходить? В кратце парсер иногда не верно определяет ходы и добавляет в них "x", что означает взятие фигуры. Но на самом деле фигура противника там нету, поле пустое. Это может происходить даже на 5-10`ом ходу, особенно в начальных позициях. Казалось бы первый ход коня на d7, а он его распозняет как взятие и добвляет xd7. Может как-то выкрутиться? В принципе ходу работают если добавлять условие, но отображение в истории ходов не красивое.

Спасибо.

@alsator
Copy link

alsator commented Feb 21, 2023 via email

@miklgene1986
Copy link
Author

Ясно, тогда извините пожалуйста.

@jeroenpost86
Copy link

This fixed it for me:

In FenParser0x88.php, remove the line 1172

$move["m"] = preg_replace("/([a-h])([a-h])([0-8])/s", "$1x$2$3", $move["m"]);

For some reason this messes up some moves.

For instance, this pgn got messed up for me:
1. e4 e5 2. Nc3 Bc5 3. f4 d6 4. Nf3 Nc6 5. Na4 Bb6 6. Nxb6 axb6 7. Bb5 Bd7 8. d3 Nge7 9. f5

Nge7 turned into Ngxe7.

I didn't do any other testing, and I am not sure what this regex does, so I won't add a pull request for this, but this worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants