hello to all --- and question to php code

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

difroso

hello to all --- and question to php code

Post by difroso »

Hello board, i found this board just now and i am happy that there is a programming-chess-forum is somewhere in the web ;)

well i hope i can help sometimes in discussions and i want to place a first question which is necessary for one of my chessly projects.

i am planning a site where you can upload pgn files. before work on them i want to check them online to prevent manipulating and illegal moves.

but before i start to code i thought to myself "well .. there must be a solution about this in the world" and indeed ... i found some programs who check this on windows platforms.

for my online project i need a php solution but i found only a pgn parser - really good to get a move list cleaned up and taken away comments variations and so on... but they did no move validation so you can submit a move like Qxt9 or castleing with king in check and so on.

please let me ask: did someone do already a php pgn checker ? is there someone who maybe knows a file/class which do this ?

i would be very happy for an answer !
thanks in advance --
dirk
User avatar
OliverUwira
Posts: 170
Joined: Mon Sep 13, 2010 9:57 am
Location: Frankfurt am Main

Re: hello to all --- and question to php code

Post by OliverUwira »

Hello Dirk,

if you like, you could have a look a this:

http://home.arcor.de/steve-o13/kurt/pgnviewer.zip

This is a crude PHP hack that I produced for the web site of the Deutsche Ländermeisterschaft der Jugendmannschaften 2004.

I haven't really prepared for writing this but basically the app has a backend script parser/create.php that takes an uploaded PGN and produces from/to notation to use in the JavaScript frontend.

The board implementation is in parser/item.php. If I remember correctly, I didn't check for pins back then but rather corrected ambiguous moves à la 1. e4 e6 2. d4 d5 3. Nc3 Bb4 4. Ne2 manually.

The script is probably still PHP 3, if you're lucky PHP 4. Anyway, if you'll find this useful, feel free to use it.

Your name tells me that you also should be able to deal with the occasional source comment in German :D
difroso

Re: hello to all --- and question to php code

Post by difroso »

hello again .. well that was definitive fast !

yes its right i am german too .. but i try to answer here in english that all understand this.

i got your code - taken a look into and it seems to do what i want ?

this "I didn't check for pins back then but rather corrected ambiguous moves " .. what you wanted to tell me --sorry had problems to translate this in the right way i think.

i will have a clother look in the next days and i will let you know how it works!

thanks for this !! dirk
User avatar
OliverUwira
Posts: 170
Joined: Mon Sep 13, 2010 9:57 am
Location: Frankfurt am Main

Re: hello to all --- and question to php code

Post by OliverUwira »

difroso wrote: i got your code - taken a look into and it seems to do what i want ?
Always nice to be able to help somebody out.
difroso wrote: this "I didn't check for pins back then but rather corrected ambiguous moves " .. what you wanted to tell me --sorry had problems to translate this in the right way i think.
Das bezieht sich auf gefesselte Figuren. In dem Beispiel mit 1.e4 e6 2. d4 d5 3. Sc3 Lb4 4. Se2 könnte eigentlich auch der Sc3 nach e2, wenn er nicht gefesselt wäre. Der PGN-Standard sieht in diesem Fall nicht vor, dass 4. Sge2 geschrieben werden muss. Daher muss der Parser erkennen können, dass 4. Sc3-e2 nicht legal ist.

This related to pinned pieces. In the example with 1.e4 e6 2. d4 d5 3. Nc3 Bb4 4. Ne2 the Nc3 could also go to e2, were it not pinned. In this case, the PGN standard doesn't prescribe that 4. Nge2 be written. Therefore, the parser must be able to recognize that 4. Nc3-e2 is not a legal move.
difroso wrote: thanks for this !! dirk
You're welcome :D
difroso

Re: hello to all --- and question to php code

Post by difroso »

Hallo noch einmal
habe den Code durchgeschaut - es ist vieles vorbereitet von daher super. Einige Dinge wie unmögliche Züge wegen durch Schach ziehen oder Rochaden die nicht mehr gehen oder auch ep schlagen obwohl es nicht geht muss ich noch implementieren wie ich gesehen habe - aber die Infrastruktur für all diese Prüfungen ist da :) das freut mich sehr - also noch einmal Danke für den Code !


English version:
Hello again
i looked at the code and its well prepared. Some things like illegel moves regarding moving thru check or castle which is not right at this time or beating ep i have to implement as i can see. but code is well prepared for all necessary checks :) glad to got this so again many thanks for this !