alexobviously / alexobviously/bishop

parsePgn cannot handle moves of type 1.d4 without space between move number and move

Offen
#76 0 Kommentare 1 Reaktion 1 zugewiesene Person Beansprucht von @alexobviously Auf GitHub ansehen
Vorherrschende Sprache
Dart
Sterne
23
Forks
12
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

In pgn files, the moves might be included in a way, that the move number and the move are not separated by a space:

```
1.d4 Nf6 2.Nf3 d5 3.e3 Bf5 4.c4 c6 5.Nc3 e6 6.Bd3 Bxd3 7.Qxd3 Nbd7 8.b3 Bd6
9.O-O O-O 10.Bb2 Qe7 11.Rad1 Rad8 12.Rfe1 dxc4 13.bxc4 e5 14.dxe5 Nxe5 15.Nxe5 Bxe5
16.Qe2 Rxd1 17.Rxd1 Rd8 18.Rxd8+ Qxd8 19.Qd1 Qxd1+ 20.Nxd1 Bxb2 21.Nxb2 b5
22.f3 Kf8 23.Kf2 Ke7 1/2-1/2
```

as seen here: https://www.pgnmentor.com/files.html

In these cases, the parser incorrectly returns "1.d4" as a move instead of "d4". This seems to result from the approach of how move numbers are identified, beginning with final numRegex = RegExp(r'([0-9]+\.+ )');

It seems that adding the following check can fix this:
```
String move = substr.substring(0, end);
if (move.contains(".")) {
move = move.substring(move.indexOf('.') + 1); //Cut off move numbers from move in case move numbers are directly followed by move without space such as "1.d4" (and not "1. d4")
}
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.