SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Red face is there a way to convert chess moves to PGN??

    i mean converting chess moves like e1-g1 to PGN format of O-O(castling).

    i'd searched many hours but all i got were PGN parser and draw the borad. this is not what i am looking for.

    what i really mean is a PHP function/class to convert for example "white knight move" -- "B1C3" into PGN format "Nc3"

    thank you!!

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Sorry, I cannot help you other than to ask if you looked in google code.

    chess lang:php

  3. #3
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    that isn't a PHP code... 'pgn' =>'application/x-chess-pgn' looks more like a header.

    i am looking for function/script like

    $coordinate = 'A2A3 B1C3';
    function convert_pgn($coordinate){....return $pgn_notation;}

  4. #4
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    actually i am referring to a PHP Chess class at http://www.phpclasses.org/browse/file/8351.html

    at line 2050:--
    $coordinate = $this->valueOfX($x_start) . $y_start . $this->valueOfX($x_end) . $y_end;

    the above will show coordinate notation like "B1C3" rather than PGN format "Nc3"

    i need a way to convert $coordinate into PGN instead

  5. #5
    SitePoint Wizard
    Join Date
    Mar 2008
    Posts
    1,149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you considered writing your own converter? I don't imagine it to be too hard.

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,813
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Probably the biggest problem with the conversion you are trying to do is that you want to convert from a notation that just identifies the start and end positions of a move to a notation that needs to know what piece it is that is being moved.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  7. #7
    SitePoint Addict
    Join Date
    Jul 2008
    Posts
    220
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by felgall View Post
    Probably the biggest problem with the conversion you are trying to do is that you want to convert from a notation that just identifies the start and end positions of a move to a notation that needs to know what piece it is that is being moved.
    that is right!! it is what i have in mind


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •