Chess-PGN-EPD

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension Chess::PGN::EPD.

0.01  Fri Feb 08 11:52:56 2002
        - original version; created by h2xs 1.21 with options
                -A -X Chess::PGN::EPD
0.02  Fri Feb 08 17:06:00 2002
        - documentation patch, correct pod format in SYNOPSIS section
0.03  Fri Feb 08 23:32:17 2002
        - added epdset; allows user to specify the initial position for a game
        - patched bug associated with $debug parameter of epdlist (didn't work
          since @moves eats all of @_, $debug was always undef)
0.04  Sat Feb 09 00:49:55 2002
        - documentation patch, correct reference to Chess::PGN::Parse (was
          Chess::PGN::PGNParser)
      Fri Feb 15 06:00:08 2002
        - added epdstr; converts an epd string into a variety of typeset positions
        - greatly expanded documentation
0.05  Fri Feb 15 15:27:33 2002
        - fixed bug, needed to parse moves of form 6e5 because author of ChessPad thought there
          was a need to dis-ambiguate the move
      Sun Feb 17 13:47:56 2002
        - documentation patch, remove dummy comment from README
0.06  Wed Feb 20 14:23:00 2002
        - jump from 0.04 to 0.06 because I forgot to change the $VERSION in the last upload
        - made necessary changes to Makefile.pl in order to install Berkeley DB files used
          by epdcode()
        - added epdcode; converts epd array to one of ECO code, NIC code or Opening name
      Thu Feb 21 07:24:28 2002
        - documentation patch, CHESS::PGN -> Chess::PGN, PGN::PGNParser -> PGN::Parse
        - patched Makefile.pl, install:: -> install ::, spaces are important!
        - added code to find DB files at BEGIN{}
0.07  Sun Mar 10 08:37:35 2002
        - yet more documentation fixes - remove misleading script names from examples
        - added DB_File to dependancy list in changes
        - removed 'taxonomy' from TODO list
        - add 'palview' to epdstr type
        - add 'text' to epdstr type
0.08  Wed Mar 20 19:55:48 2002
        - add %font2map lookup table
0.09  Sat Mar 30 18:58:00 2002
        - correct make test bug, $db_path needs default value of './db/' since test happens
          before install
0.10  Mon Apr 01 15:03:27 2002
        - correct Makefile.PL to use '/' in list of files, not '\' which fails under Linux
0.11  Tue Apr 02 09:08:21 2002
        - must correct target of modified file list as well, 
          not 'Chess/PGN/db' but 'Chess\PGN\db'
0.12  Tue Apr 02 13:54:01 2002
        - patch for permissions bug, db files are created 0644, so should access in
          read-only mode
        - also remove INIT block as un-necessary
0.13  Mon Jun 24 04:23:01 2002
        - fold in patch for 'Malformed UTF-8 character (byte 0xfe) in ord...' problem found
          by Cyril Malkov - patch is his too!
        - add better test.pl file
0.14  Mon Jun 24 17:00:36 2002
        - re-synchronize Makefile.PL to use the one with all of the corrections in it
0.15  Wed Jun 26 20:25:38 2002
        - figured out that MANIFEST should reflect what you want in the distribution,
          but it should do so in a unix like fashion - similar to problem found in
          version .10
        - corrected other typo in README (version should be current, not 0.12!)
0.16  Thu Jun 27 04:23:10 2002
        - put Makefile.PL back in the MANIFEST and therefore back in the distribution!
0.17  Sun Jul 21 13:55:12 2002
        - stamp out a bug related to knight moves
0.18  Wed Aug 21 12:49:00 2002
        - found a forgotten dependency
0.19  Thu Nov 28 10:56:49 2002
        - another patch to the knight moves problem
        - export psquares sub
        - create and export new sub, epdgetboard
      Sat Nov 30 07:49:37 2002
        - modified epdstr to add 'board' as parameter
0.20  Wed Feb 12 17:20:00 2003
        - small code improvements, maintainence release...
0.21  Mon Mar 03 12:31:00 2003
        - added internal check for legal move to patch pinned piece bug...
0.22  Tue Mar 04 07:51:37 2003
        - small code improvements, maintainence release...
        - added 3 tests to check for pinned piece bug
0.23  Sat Apr 04 14:35:00 2009
        - Patch problem with XP and forward slashes blocking database loading
        - Patch problem with hashes that generates warnings (code will be depricated as well, so fix
          is needed!)
0.24  Sun Apr 05 14:40:00 2009
        - Repatch patch above-- had nothing to do with XP, had to do with reliably finding database files!
        - Found another hashref deprication and fixed.
0.25  Sat Oct 02 04:27:21 2010
        - drop usage of 'use DB_File' moving to 'use Storable' instead
        - clean up code to avoid 'Deprecated' messages
        - clean up code using PerlCritic level 4
        - extend tests
        - add sample code
        - slight improvement to pod
        - add epdfromto for telegraphic style from-to notation
        - remove debug output from epdlist
        - add epdTaxonomy to simplify ECO, NIC and Opening tag generation
0.26  Tue May 03 03:04:40 2011
        - apply patch so that module passes test code in Linux
0.27  Tue May 03 05:14:59 2011
        - add test for epdTaxonomy
        - remove use feature ':5.10';
        - rewrite epdTaxonomy to not use given/when
0.28  Sun May 08 12:35:48 2011
        - continue to stamp out 5.10 features; this time '//'
0.29  Mon May 16 11:35:35 2011
        - fix warnings found in test under 5.8.1 Linux
        - fix errors in t\07_psquares.t under 5.8.1 Linux
        - fix errors in t\08_epdset.t under 5.8.1 Linux
0.30  Thu Jun 30 08:55:22 2011
        - fix two errors spotted by user Klaus Ludens
        - add typing filter for rare move case
        - add new logic for setting $debug in epdlist
        - add new test: 10_ludens.t to insure regression
0.31  Wed Aug 29 06:01:39 2012
        - change method for finding databases to something hopefully cross platform
        - Add code from Klaus Ludens to allow for castling bug---generated wrong fen/EPD
0.32  Tue Jan 02 20:36:18 2017
        - Adopt Dist::Zilla
        - fix install failure associated with not finding databases
0.33  Wed Jan 04 21:38:17 2017
        - Extend supported fonts to match font list at http://www.enpassant.dk/chess/fonteng.htm
        - Didn't get to font item, will wait until stable release without bug list...
0.34  Mon Jan 16 21:06:30 2017 
        - Fix "119759	Undeclared dependency on Chess::PGN::Moves"
        - Add 00_Dependancies.t as stop to test without Chess::PGN::Moves
        - Add =head1 LICENSE and the text of the license to pod
        - Add a META.json to the distribution
        - List all modules used in the test suite in META.yml build_requires
        - Add all modules contained in this distribution to the META.yml field 'provides'
        - Generate README from pod

LICENSE  view on Meta::CPAN

This software is copyright (c) 2017 by Hugh S. Myers.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.

Terms of the Perl programming language system itself

a) the GNU General Public License as published by the Free
   Software Foundation; either version 1, or (at your option) any
   later version, or
b) the "Artistic License"

--- The GNU General Public License, Version 1, February 1989 ---

This software is Copyright (c) 2017 by Hugh S. Myers.

This is free software, licensed under:

  The GNU General Public License, Version 1, February 1989

                    GNU GENERAL PUBLIC LICENSE
                     Version 1, February 1989

 Copyright (C) 1989 Free Software Foundation, Inc.
 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The license agreements of most software companies try to keep users
at the mercy of those companies.  By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must tell them their rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License.  The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications.  Each
licensee is addressed as "you".

  1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program.  You may charge a fee for the physical act of
transferring a copy.

  2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:

    a) cause the modified files to carry prominent notices stating that
    you changed the files and the date of any change; and

    b) cause the whole of any work that you distribute or publish, that
    in whole or in part contains the Program or any part thereof, either
    with or without modifications, to be licensed at no charge to all
    third parties under the terms of this General Public License (except
    that you may choose to grant warranty protection to some or all
    third parties, at your option).

    c) If the modified program normally reads commands interactively when
    run, you must cause it, when started running for such interactive use
    in the simplest and most usual way, to print or display an
    announcement including an appropriate copyright notice and a notice
    that there is no warranty (or else, saying that you provide a
    warranty) and that users may redistribute the program under these
    conditions, and telling the user how to view a copy of this General
    Public License.

    d) You may charge a fee for the physical act of transferring a
    copy, and you may at your option offer warranty protection in
    exchange for a fee.

Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.

  3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:

    a) accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of
    Paragraphs 1 and 2 above; or,

    b) accompany it with a written offer, valid for at least three
    years, to give any third party free (except for a nominal charge
    for the cost of distribution) a complete machine-readable copy of the
    corresponding source code, to be distributed under the terms of
    Paragraphs 1 and 2 above; or,

    c) accompany it with the information you received as to where the
    corresponding source code may be obtained.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form alone.)

Source code for a work means the preferred form of the work for making
modifications to it.  For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.

  4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License.  However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.

  5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions.  You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.

  7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.

  8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) 19yy  <name of author>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 1, or (at your option)
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA  02110-1301 USA


Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) 19xx name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License.  Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  program `Gnomovision' (a program to direct compilers to make passes
  at assemblers) written by James Hacker.

  <signature of Ty Coon>, 1 April 1989
  Ty Coon, President of Vice

That's all there is to it!


--- The Artistic License 1.0 ---

This software is Copyright (c) 2017 by Hugh S. Myers.

This is free software, licensed under:

  The Artistic License 1.0

The Artistic License

Preamble

The intent of this document is to state the conditions under which a Package
may be copied, such that the Copyright Holder maintains some semblance of
artistic control over the development of the package, while giving the users of
the package the right to use and distribute the Package in a more-or-less
customary fashion, plus the right to make reasonable modifications.

Definitions:

  - "Package" refers to the collection of files distributed by the Copyright
    Holder, and derivatives of that collection of files created through
    textual modification. 
  - "Standard Version" refers to such a Package if it has not been modified,
    or has been modified in accordance with the wishes of the Copyright
    Holder. 
  - "Copyright Holder" is whoever is named in the copyright or copyrights for
    the package. 
  - "You" is you, if you're thinking about copying or distributing this Package.
  - "Reasonable copying fee" is whatever you can justify on the basis of media
    cost, duplication charges, time of people involved, and so on. (You will
    not be required to justify it to the Copyright Holder, but only to the
    computing community at large as a market that must bear the fee.) 
  - "Freely Available" means that no fee is charged for the item itself, though
    there may be fees involved in handling the item. It also means that
    recipients of the item may redistribute it under the same conditions they
    received it. 

1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.

2. You may apply bug fixes, portability fixes and other modifications derived
from the Public Domain or from the Copyright Holder. A Package modified in such
a way shall still be considered the Standard Version.

3. You may otherwise modify your copy of this Package in any way, provided that
you insert a prominent notice in each changed file stating how and when you
changed that file, and provided that you do at least ONE of the following:

  a) place your modifications in the Public Domain or otherwise make them
     Freely Available, such as by posting said modifications to Usenet or an
     equivalent medium, or placing the modifications on a major archive site
     such as ftp.uu.net, or by allowing the Copyright Holder to include your
     modifications in the Standard Version of the Package.

  b) use the modified Package only within your corporation or organization.

  c) rename any non-standard executables so the names do not conflict with
     standard executables, which must also be provided, and provide a separate
     manual page for each non-standard executable that clearly documents how it
     differs from the Standard Version.

  d) make other distribution arrangements with the Copyright Holder.

4. You may distribute the programs of this Package in object code or executable
form, provided that you do at least ONE of the following:

  a) distribute a Standard Version of the executables and library files,
     together with instructions (in the manual page or equivalent) on where to
     get the Standard Version.

  b) accompany the distribution with the machine-readable source of the Package
     with your modifications.

  c) accompany any non-standard executables with their corresponding Standard
     Version executables, giving the non-standard executables non-standard
     names, and clearly documenting the differences in manual pages (or
     equivalent), together with instructions on where to get the Standard
     Version.

  d) make other distribution arrangements with the Copyright Holder.

5. You may charge a reasonable copying fee for any distribution of this
Package.  You may charge any fee you choose for support of this Package. You
may not charge a fee for this Package itself. However, you may distribute this
Package in aggregate with other (possibly commercial) programs as part of a
larger (possibly commercial) software distribution provided that you do not
advertise this Package as a product of your own.

6. The scripts and library files supplied as input to or produced as output
from the programs of this Package do not automatically fall under the copyright
of this Package, but belong to whomever generated them, and may be sold
commercially, and may be aggregated with this Package.

7. C or perl subroutines supplied by you and linked into this Package shall not
be considered part of this Package.

8. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.

9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

The End

MANIFEST  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.008.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
dist.ini
examples/readme.txt
examples/sample.pgn
examples/sample1.pl
examples/sample2.pl
examples/sample3.pl
lib/Chess/PGN/EPD.pm
share/ECO.db
share/NIC.db
share/Opening.db
t/00_dependancy.t
t/01_epdcode.t
t/02_Shareable.t
t/03_epdlist.t
t/04_epdstr.t
t/05_list-str.t
t/06_epdgetboard.t
t/07_psquares.t
t/08_epdset.t
t/09_epdTaxonomy.t
t/10_ludens.t
t/11_ludens-2.t
t/author-critic.t
t/author-pod-coverage.t
t/author-pod-syntax.t
t/release-kwalitee.t
t/release-test-legal.t

META.json  view on Meta::CPAN

{
   "abstract" : "Perl extension to produce and manipulate EPD text. ",
   "author" : [
      "Hugh S. Myers <hsmyers@gmail.com>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
      "version" : 2
   },
   "name" : "Chess-PGN-EPD",
   "prereqs" : {
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0",
            "File::ShareDir::Install" : "0.06"
         }
      },
      "develop" : {
         "requires" : {
            "Pod::Coverage::TrustPod" : "0",
            "Test::Kwalitee" : "1.21",
            "Test::Pod" : "1.41",
            "Test::Pod::Coverage" : "1.08"
         }
      },
      "runtime" : {
         "requires" : {
            "Chess::PGN::Moves" : "0.05",
            "Cpanel::JSON::XS" : "0",
            "Exporter" : "0",
            "File::ShareDir" : "0",
            "File::Slurper" : "0",
            "perl" : "v5.24.0",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Chess::PGN::Moves" : "0.05",
            "Chess::PGN::Parse" : "0.20",
            "Test::More" : "0",
            "diagnostics" : "0"
         }
      }
   },
   "provides" : {
      "Chess::PGN::EPD" : {
         "file" : "lib/Chess/PGN/EPD.pm",
         "version" : "0.34"
      }
   },
   "release_status" : "stable",
   "version" : "0.34",
   "x_serialization_backend" : "Cpanel::JSON::XS version 3.0213"
}

META.yml  view on Meta::CPAN

---
abstract: 'Perl extension to produce and manipulate EPD text. '
author:
  - 'Hugh S. Myers <hsmyers@gmail.com>'
build_requires:
  Chess::PGN::Moves: '0.05'
  Chess::PGN::Parse: '0.20'
  Test::More: '0'
  diagnostics: '0'
configure_requires:
  ExtUtils::MakeMaker: '0'
  File::ShareDir::Install: '0.06'
dynamic_config: 0
generated_by: 'Dist::Zilla version 6.008, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: Chess-PGN-EPD
provides:
  Chess::PGN::EPD:
    file: lib/Chess/PGN/EPD.pm
    version: '0.34'
requires:
  Chess::PGN::Moves: '0.05'
  Cpanel::JSON::XS: '0'
  Exporter: '0'
  File::ShareDir: '0'
  File::Slurper: '0'
  perl: v5.24.0
  strict: '0'
  warnings: '0'
version: '0.34'
x_serialization_backend: 'YAML::Tiny version 1.69'

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.008.
use strict;
use warnings;

use 5.024000;

use ExtUtils::MakeMaker;

use File::ShareDir::Install;
$File::ShareDir::Install::INCLUDE_DOTFILES = 1;
$File::ShareDir::Install::INCLUDE_DOTDIRS = 1;
install_share dist => "share";


my %WriteMakefileArgs = (
  "ABSTRACT" => "Perl extension to produce and manipulate EPD text. ",
  "AUTHOR" => "Hugh S. Myers <hsmyers\@gmail.com>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0,
    "File::ShareDir::Install" => "0.06"
  },
  "DISTNAME" => "Chess-PGN-EPD",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.024000",
  "NAME" => "Chess::PGN::EPD",
  "PREREQ_PM" => {
    "Chess::PGN::Moves" => "0.05",
    "Cpanel::JSON::XS" => 0,
    "Exporter" => 0,
    "File::ShareDir" => 0,
    "File::Slurper" => 0,
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Chess::PGN::Moves" => "0.05",
    "Chess::PGN::Parse" => "0.20",
    "Test::More" => 0,
    "diagnostics" => 0
  },
  "VERSION" => "0.34",
  "test" => {
    "TESTS" => "t/*.t"
  }
);


my %FallbackPrereqs = (
  "Chess::PGN::Moves" => "0.05",
  "Chess::PGN::Parse" => "0.20",
  "Cpanel::JSON::XS" => 0,
  "Exporter" => 0,
  "File::ShareDir" => 0,
  "File::Slurper" => 0,
  "Test::More" => 0,
  "diagnostics" => 0,
  "strict" => 0,
  "warnings" => 0
);


unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
  delete $WriteMakefileArgs{TEST_REQUIRES};
  delete $WriteMakefileArgs{BUILD_REQUIRES};
  $WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}

delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
  unless eval { ExtUtils::MakeMaker->VERSION(6.52) };

WriteMakefile(%WriteMakefileArgs);

{
package
MY;
use File::ShareDir::Install qw(postamble);
}

README  view on Meta::CPAN

NAME

    Chess::PGN::EPD - Perl extension to produce and manipulate EPD text.

SYNOPSIS

    From "Working With Epd Files" by Steve Lopez
    <http://www.chessbaseusa.com/portals/6/tn/Issues_Back/1999_autumn/1999_1031.htm>,

    "There's a lot of chess information available on the Internet in a
    variety of formats. One of these is called EPD (Extended Position
    Description) format; it's just a convenient way to provide a board
    position (rather than a full game) in an ASCII text notation. For
    example, here's what the board position after 1.e4 looks like in EPD
    format:

        rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

    This was designed as a way for chess players and chess programs to pass
    board positions back and forth for analysis. You'll frequently see
    posts to Usenet chess newsgroups or other message boards containing
    these EPD positions.

    There's a quick, easy way to copy and paste these board descriptions
    into ChessBase or any of our playing programs (Fritz, Hiarcs, Nimzo,
    Junior). Just highlight the EPD line from a post or web page and hit
    CRTL-C on your keyboard. Then open ChessBase, go to the Game menu,
    select "Setup position", and click the button marked "Paste FEN".
    You'll instantly see the position appear on the board in the "Setup
    position" window. Click "OK" and you'll now have an "Enter new game"
    window with the proper board position on it taken from the EPD file.
    You can then save the position into a database just like any other
    game..."

    Chess::PGN::EPD attempts to bring ease and convenience to its users
    programmatically by providing a set of functions that manipulate EPD
    text.

VERSION

    0.34

RECENT CHANGES

      * Fix "119759 Undeclared dependency on Chess::PGN::Moves"

      * Add 00_Dependancies.t as stop to test without Chess::PGN::Moves

      * Add =head1 LICENSE and the text of the license to pod

      * Add a META.json to the distribution

      * List all modules used in the test suite in META.yml build_requires

      * Add all modules contained in this distribution to the META.yml
      field 'provides'

      * Generate README from pod

    See the Changes file for a longer revision history.

REQUIREMENTS

    This distribution requires Perl v5.24.0.

    This distribution requires the following modules:

      * Chess::PGN::Moves (version 0.05)

      * Chess::PGN::Parse (version 0.20)

      * Cpanel::JSON::XS

      * File::ShareDir

      * File::ShareDir::Install (version 0.06)

      * File::Slurper

      * Pod::Coverage::TrustPod

      * Test::Kwalitee (version 1.21)

      * Test::Pod (version 1.41)

      * Test::Pod::Coverage (version 1.08)

INSTALLATION

    Traditional recipe based on Makefile.PL:

        perl Makefile.PL
        make
        make test
        make install

    Note that some distributions will have a Build.PL file instead of or in
    addition to Makefile.PL. In that case use this recipe:

        perl Build.PL
        ./Build
        ./Build test
        ./Build install

AUTHOR

    Hugh S. Myers <hsmyers@gmail.com>

LICENSE

                 The "Artistic License"
    
                    Preamble

    The intent of this document is to state the conditions under which a
    Package may be copied, such that the Copyright Holder maintains some
    semblance of artistic control over the development of the package,
    while giving the users of the package the right to use and distribute
    the Package in a more-or-less customary fashion, plus the right to make
    reasonable modifications.

    Definitions:

        "Package" refers to the collection of files distributed by the
        Copyright Holder, and derivatives of that collection of files
        created through textual modification.
    
        "Standard Version" refers to such a Package if it has not been
        modified, or has been modified in accordance with the wishes
        of the Copyright Holder as specified below.
    
        "Copyright Holder" is whoever is named in the copyright or
        copyrights for the package.
    
        "You" is you, if you're thinking about copying or distributing
        this Package.
    
        "Reasonable copying fee" is whatever you can justify on the
        basis of media cost, duplication charges, time of people involved,
        and so on.  (You will not be required to justify it to the
        Copyright Holder, but only to the computing community at large
        as a market that must bear the fee.)
    
        "Freely Available" means that no fee is charged for the item
        itself, though there may be fees involved in handling the item.
        It also means that recipients of the item may redistribute it
        under the same conditions they received it.

    1. You may make and give away verbatim copies of the source form of the
    Standard Version of this Package without restriction, provided that you
    duplicate all of the original copyright notices and associated
    disclaimers.

    2. You may apply bug fixes, portability fixes and other modifications
    derived from the Public Domain or from the Copyright Holder. A Package
    modified in such a way shall still be considered the Standard Version.

    3. You may otherwise modify your copy of this Package in any way,
    provided that you insert a prominent notice in each changed file
    stating how and when you changed that file, and provided that you do at
    least ONE of the following:

        a) place your modifications in the Public Domain or otherwise make them
        Freely Available, such as by posting said modifications to Usenet or
        an equivalent medium, or placing the modifications on a major archive
        site such as uunet.uu.net, or by allowing the Copyright Holder to include
        your modifications in the Standard Version of the Package.
    
        b) use the modified Package only within your corporation or organization.
    
        c) rename any non-standard executables so the names do not conflict
        with standard executables, which must also be provided, and provide
        a separate manual page for each non-standard executable that clearly
        documents how it differs from the Standard Version.
    
        d) make other distribution arrangements with the Copyright Holder.

    4. You may distribute the programs of this Package in object code or
    executable form, provided that you do at least ONE of the following:

        a) distribute a Standard Version of the executables and library files,
        together with instructions (in the manual page or equivalent) on where
        to get the Standard Version.
    
        b) accompany the distribution with the machine-readable source of
        the Package with your modifications.
    
        c) give non-standard executables non-standard names, and clearly
        document the differences in manual pages (or equivalent), together
        with instructions on where to get the Standard Version.
    
        d) make other distribution arrangements with the Copyright Holder.

    5. You may charge a reasonable copying fee for any distribution of this
    Package. You may charge any fee you choose for support of this Package.
    You may not charge a fee for this Package itself. However, you may
    distribute this Package in aggregate with other (possibly commercial)
    programs as part of a larger (possibly commercial) software
    distribution provided that you do not advertise this Package as a
    product of your own. You may embed this Package's interpreter within an
    executable of yours (by linking); this shall be construed as a mere
    form of aggregation, provided that the complete Standard Version of the
    interpreter is so embedded.

    6. The scripts and library files supplied as input to or produced as
    output from the programs of this Package do not automatically fall
    under the copyright of this Package, but belong to whoever generated
    them, and may be sold commercially, and may be aggregated with this
    Package. If such scripts or library files are aggregated with this
    Package via the so-called "undump" or "unexec" methods of producing a
    binary executable image, then distribution of such an image shall
    neither be construed as a distribution of this Package nor shall it
    fall under the restrictions of Paragraphs 3 and 4, provided that you do
    not represent such an executable image as a Standard Version of this
    Package.

    7. C subroutines (or comparably compiled subroutines in other
    languages) supplied by you and linked into this Package in order to
    emulate subroutines and variables of the language defined by this
    Package shall not be considered part of this Package, but are the
    equivalent of input as in Paragraph 6, provided these subroutines do
    not change the language in any way that would cause it to fail the
    regression tests for the language.

    8. Aggregation of this Package with a commercial distribution is always
    permitted provided that the use of this Package is embedded; that is,
    when no overt attempt is made to make this Package's interfaces visible
    to the end user of the commercial distribution. Such use shall not be
    construed as a distribution of this Package.

    9. The name of the Copyright Holder may not be used to endorse or
    promote products derived from this software without specific prior
    written permission.

    10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
    WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
    MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

                    The End

COPYRIGHT

    Copyright (C) 2017 Hugh S. Myers

dist.ini  view on Meta::CPAN

name    = Chess-PGN-EPD
author  = Hugh S. Myers <hsmyers@gmail.com>
license = Perl_5
copyright_holder = Hugh S. Myers
copyright_year   = 2017

[VersionFromModule]

[Test::Perl::Critic]
[Test::Kwalitee]
[Test::Legal]

[MetaJSON]
[MetaProvides::Package]
[ReadmeFromPod]

[AutoPrereqs]
[Prereqs  / TestRequires]
Chess::PGN::Moves = 0.05
Chess::PGN::Parse = 0.20

[@Classic]

examples/readme.txt  view on Meta::CPAN

The scripts in this directory are taken directly from the
pod documentation of Chess::PGN::EPD and are here to
save you a bit of cut and paste.

readme.txt
sample.pgn
sample1.pl
sample2.pl
sample3.pl

The .pgn file is useful as input to sample1 and sample3--- sample2 is stand-alone.

examples/sample.pgn  view on Meta::CPAN

[Event "ICC 2 12 u"]
[Site "Internet Chess Club"]
[Date "2003.03.31"]
[Round "-"]
[White "hsmyers"]
[Black "guest2023"]
[Result "1-0"]
[ICCResult "Black resigns"]
[WhiteElo "1492"]
[Opening "KGA: Fischer defense"]
[ECO "C30"]
[NIC "KG.05"]
[Time "14:36:59"]
[TimeControl "120+12"]

1. e4 e5 2. f4 d6 3. Nf3 exf4 4. Be2 g5 5. O-O Bg4 6. d4 Nc6 7. c3 Qf6 8.
Bb5 Ne7 9. d5 a6 10. dxc6 axb5 11. cxb7 Rb8 12. Qb3 Rxb7 13. a4 Bg7 14. axb5
O-O 15. Na3 Rfb8 16. c4 c6 17. Qc2 cxb5 18. cxb5 Rc8 19. Qd2 Bxf3 20. Rxf3
Qd4+ 21. Qxd4 Bxd4+ 22. Kh1 Re8 23. Rd3 Be5 24. Rb1 g4 25. Bd2 g3 26. hxg3
fxg3 27. Bc3 Bf4 28. Rf3 Ng6 29. Re1 Rbe7 30. b6 Rxe4 31. Rxe4 Rxe4 32. b7
d5 33. Rxf4 Nxf4 34. b8=Q+ {Black resigns} 1-0

examples/sample1.pl  view on Meta::CPAN

#!/usr/bin/perl
# sample1.pl - an example of Chess::PGN::EPD usage...
#
use warnings;
use strict;
use Chess::PGN::Parse;
use Chess::PGN::EPD qw( epdlist );

if ( $ARGV[0] ) {
    my $pgn = new Chess::PGN::Parse( $ARGV[0] )
      or die "Can't open $ARGV[0]: $!\n";
    while ( $pgn->read_game() ) {
        $pgn->parse_game();
        print join( "\n", epdlist( @{ $pgn->moves() } ) ), "\n\n";
    }
}

examples/sample2.pl  view on Meta::CPAN

#!/usr/bin/perl
# sample2.pl - an example of Chess::PGN::EPD usage...
#
use warnings;
use strict;
use Chess::PGN::EPD qw( epdstr );

my $position = 'rnbqkb1r/ppp1pppp/5n2/3P4/8/8/PPPP1PPP/RNBQKBNR w KQkq -';
print join( "\n", epdstr( epd => $position, type => 'latex' ) );

examples/sample3.pl  view on Meta::CPAN

#!/usr/bin/perl
# sample3.pl - an example of Chess::PGN::EPD usage...
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::Parse;
use Chess::PGN::EPD qw( epdlist epdcode );

if ( $ARGV[0] ) {
    my $pgn = new Chess::PGN::Parse( $ARGV[0] )
      or die "Can't open $ARGV[0]: $!\n";
    while ( $pgn->read_game() ) {
        my @epd;

        $pgn->parse_game();
        @epd = reverse epdlist( @{ $pgn->moves() } );
        print '[ECO,"',     epdcode( 'ECO',     \@epd ), "\"]\n";
        print '[NIC,"',     epdcode( 'NIC',     \@epd ), "\"]\n";
        print '[Opening,"', epdcode( 'Opening', \@epd ), "\"]\n";
    }
}

lib/Chess/PGN/EPD.pm  view on Meta::CPAN

use strict;
use warnings;

package Chess::PGN::EPD;

use v5.24;
use Chess::PGN::Moves;
use File::ShareDir qw(dist_file);
use File::Slurper qw(read_text);
use Cpanel::JSON::XS qw(decode_json);

require Exporter;

my ( $hECO, $hNIC, $hOpening );
my %hash = (
    ECO     => \$hECO,
    NIC     => \$hNIC,
    Opening => \$hOpening
);

my ( $ECO_path, $NIC_path, $Opening_path ) = _GetPaths('Chess-PGN-EPD');

$hECO     = decode_json read_text($ECO_path);
$hNIC     = decode_json read_text($NIC_path);
$hOpening = decode_json read_text($Opening_path);

sub _GetPaths {
    my $dist      = shift;
    my $dbECO     = dist_file( $dist, 'ECO.db' );
    my $dbNIC     = dist_file( $dist, 'NIC.db' );
    my $dbOpening = dist_file( $dist, 'Opening.db' );

    return ( $dbECO, $dbNIC, $dbOpening );
}

our @ISA    = qw(Exporter);
our @EXPORT = qw(
    epdcode
    epdset
    epdfromto
    epdstr
    epdlist
    epdgetboard
    epdTaxonomy
    psquares
    %font2map
);
our $VERSION = '0.34';

our %font2map = (
    'Chess Cases'           => 'leschemelle',
    'Chess Adventurer'      => 'marroquin',
    'Chess Alfonso-X'       => 'marroquin',
    'Chess Alpha'           => 'bentzen1',
    'Chess Berlin'          => 'bentzen2',
    'Chess Condal'          => 'marroquin',
    'Chess Harlequin'       => 'marroquin',
    'Chess Kingdom'         => 'marroquin',
    'Chess Leipzig'         => 'marroquin',
    'Chess Line'            => 'marroquin',
    'Chess Lucena'          => 'marroquin',
    'Chess Magnetic'        => 'marroquin',
    'Chess Mark'            => 'marroquin',
    'Chess Marroquin'       => 'marroquin',
    'Chess Maya'            => 'marroquin',
    'Chess Mediaeval'       => 'marroquin',
    'Chess Merida'          => 'marroquin',
    'Chess Millennia'       => 'marroquin',
    'Chess Miscel'          => 'marroquin',
    'Chess Montreal'        => 'katch',
    'Chess Motif'           => 'marroquin',
    'Chess Plain'           => 'hickey',
    'Chess Regular'         => 'scott1',
    'Chess Usual'           => 'scott2',
    'Chess Utrecht'         => 'bodlaender',
    'Tilburg'               => 'tilburg',
    'Traveller Standard V3' => 'cowderoy',
);

my %board = qw(
    a1 R a2 P a7 p a8 r
    b1 N b2 P b7 p b8 n
    c1 B c2 P c7 p c8 b
    d1 Q d2 P d7 p d8 q
    e1 K e2 P e7 p e8 k
    f1 B f2 P f7 p f8 b
    g1 N g2 P g7 p g8 n
    h1 R h2 P h7 p h8 r
);
my $Kc = 1;
my $Qc = 1;
my $kc = 1;
my $qc = 1;
my $w  = 1;

my @onwhite = (
    1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0,
    1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1,
    0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1,
);

my %FontMap = (
    hicky => {
        OnBlack            => 'OMASTLPNBRQK@',
        OnWhite            => 'omastlpnbrqk:',
        SingleBox          => '12345678',
        DoubleBox          => '!"#$%&\'(',
        SingleRounded      => '[]\^',
        DoubleRounded      => '<>;=/',
        SingleLeftLegend   => 'cdefghij',
        DoubleLeftLegend   => 'CDEFGHIJ',
        SingleBottomLegend => 'wxyz{|}~',
        DoubleBottomLegend => ')*+,-./0',
    },
    marroquin => {
        OnBlack            => 'OMVTWLPNBRQK+',
        OnWhite            => 'omvtwlpnbrqk ',
        SingleBox          => '12345789',
        DoubleBox          => '!"#$%/()',
        SingleRounded      => 'asdf',
        DoubleRounded      => 'ASDF',
        SingleLeftLegend   => "\300\301\302\303\034\305\306\307",
        DoubleLeftLegend   => "\340\341\342\343\344\345\346\347",
        SingleBottomLegend => "\310\311\312\313\314\315\316\317",
        DoubleBottomLegend => "\350\351\352\353\354\355\356\357",
    },
    leschemelle => {
        OnBlack            => 'OMVTWLPNBRQK+',
        OnWhite            => 'omvtwlpnbrqk ',
        SingleBox          => '12345789',
        DoubleBox          => '!"#$%/()',
        SingleRounded      => 'asdf',
        DoubleRounded      => 'ASDF',
        SingleLeftLegend   => "\300\301\302\303\034\305\306\307",
        DoubleLeftLegend   => "\340\341\342\343\344\345\346\347",
        SingleBottomLegend => "\310\311\312\313\314\315\316\317",
        DoubleBottomLegend => "\350\351\352\353\354\355\356\357",
    },
    linares => {
        OnBlack            => '0hg41i)HG$!Id',
        OnWhite            => 'pnbrqkPNBRQKw',
        SingleBox          => 'W_W[]W-W',
        DoubleBox          => 'cuC{}vlV',
        SingleRounded      => 'WWWW',
        DoubleRounded      => 'cCvV',
        SingleLeftLegend   => "\332\333\334\335\336\337\340\341",
        DoubleLeftLegend   => '(765&32%',
        SingleBottomLegend => "\301\302\303\304\305\306\307\310",
        DoubleBottomLegend => ',./9EFJM',
    },
    linares1 => {
        OnBlack            => '0hg41i)HG$!Id',
        OnWhite            => 'pnbrqkPNBRQKw',
        SingleBox          => '>;?:<A=@',
        DoubleBox          => '>;?:<A=@',
        SingleRounded      => '>?A@',
        DoubleRounded      => '>?A@',
        SingleLeftLegend   => '::::::::',
        DoubleLeftLegend   => '::::::::',
        SingleBottomLegend => '========',
        DoubleBottomLegend => '========',
    },
    linares2 => {
        OnBlack            => '0hg41i)HG$!Id',
        OnWhite            => 'pnbrqkPNBRQKw',
        SingleBox          => '^xY|yUz\\',
        DoubleBox          => '^xY|yUz\\',
        SingleRounded      => '^YU\\',
        DoubleRounded      => '^YU\\',
        SingleLeftLegend   => '||||||||',
        DoubleLeftLegend   => '||||||||',
        SingleBottomLegend => 'zzzzzzzz',
        DoubleBottomLegend => 'zzzzzzzz',
    },
    cowderoy => {
        OnBlack            => '$#!&%"*)\',+(0',
        OnWhite            => 'pnbrqkPNBRQK ',
        SingleBox          => '78946123',
        DoubleBox          => '78946123',
        SingleRounded      => '7913',
        DoubleRounded      => '7913',
        SingleLeftLegend   => '44444444',
        DoubleLeftLegend   => '44444444',
        SingleBottomLegend => '22222222',
        DoubleBottomLegend => '22222222',
    },
    bentzen1 => {
        OnBlack            => 'OJNTWLPHBRQK+',
        OnWhite            => 'ojntwlphbrqk ',
        SingleBox          => '!"#$%&\'(',
        DoubleBox          => '12345789',
        SingleRounded      => '!#&(',
        DoubleRounded      => '1379',
        SingleLeftLegend   => "\340\341\342\343\344\345\346\347",
        DoubleLeftLegend   => "\300\301\302\303\304\305\306\307",
        SingleBottomLegend => "\350\351\352\353\354\355\356\357",
        DoubleBottomLegend => "\310\311\312\313\314\315\316\317",
    },
    bentzen2 => {
        OnBlack            => 'OJNTWLPHBRQK+',
        OnWhite            => 'ojntwlphbrqk ',
        SingleBox          => '12345789',
        DoubleBox          => '12345789',
        SingleRounded      => '1379',
        DoubleRounded      => '1379',
        SingleLeftLegend   => '44444444',
        DoubleLeftLegend   => '44444444',
        SingleBottomLegend => '88888888',
        DoubleBottomLegend => '88888888',
    },
    scott1 => {
        OnBlack            => 'OJNTWLPHBRQK+',
        OnWhite            => 'ojntwlphbrqk*',
        SingleBox          => '(-)/\[_]',
        DoubleBox          => '(-)/\[_]',
        SingleRounded      => '(-)/\[_]',
        DoubleRounded      => '(-)/\[_]',
        SingleLeftLegend   => '////////',
        DoubleLeftLegend   => '////////',
        SingleBottomLegend => '________',
        DoubleBottomLegend => '________',
    },
    scott2 => {
        OnBlack            => 'OMVTWLPNBRQK+',
        OnWhite            => 'omvtwlpnbrqk ',
        SingleBox          => '12345789',
        DoubleBox          => '!"#$%/()',
        SingleRounded      => 'asdf',
        DoubleRounded      => 'ASDF',
        SingleLeftLegend   => '44444444',
        DoubleLeftLegend   => '$$$$$$$$',
        SingleBottomLegend => '44444444',
        DoubleBottomLegend => '$$$$$$$$',
    },
    bodlaender => {
        OnBlack            => 'OMVTWLomvtwl/',
        OnWhite            => 'PNBRQKpnbrqk ',
        SingleBox          => '51632748',
        DoubleBox          => '51632748',
        SingleRounded      => '51632748',
        DoubleRounded      => '51632748',
        SingleLeftLegend   => '33333333',
        DoubleLeftLegend   => '33333333',
        SingleBottomLegend => '44444444',
        DoubleBottomLegend => '44444444',
    },
    katch => {
        OnBlack            => 'OMVTWLPNBRQK/',
        OnWhite            => 'omvtwlpnbrqk ',
        SingleBox          => '12345789',
        DoubleBox          => '12345789',
        SingleRounded      => '12345789',
        DoubleRounded      => '12345789',
        SingleLeftLegend   => '44444444',
        DoubleLeftLegend   => '44444444',
        SingleBottomLegend => '88888888',
        DoubleBottomLegend => '88888888',
    },
    dummy => {
        OnBlack            => '',
        OnWhite            => '',
        SingleBox          => '',
        DoubleBox          => '',
        SingleRounded      => '',
        DoubleRounded      => '',
        SingleLeftLegend   => '',
        DoubleLeftLegend   => '',
        SingleBottomLegend => '',
        DoubleBottomLegend => '',
    },
);

my %convertPalView = (
    'r',
    '<IMG SRC="jpc/br.gif">',
    'n',
    '<IMG SRC="jpc/bn.gif">',
    'b',
    '<IMG SRC="jpc/bb.gif">',
    'q',
    '<IMG SRC="jpc/bq.gif">',
    'k',
    '<IMG SRC="jpc/bk.gif">',
    'p',
    '<IMG SRC="jpc/bp.gif">',
    'R',
    '<IMG SRC="jpc/wr.gif">',
    'N',
    '<IMG SRC="jpc/wn.gif">',
    'B',
    '<IMG SRC="jpc/wb.gif">',
    'Q',
    '<IMG SRC="jpc/wq.gif">',
    'K',
    '<IMG SRC="jpc/wk.gif">',
    'P',
    '<IMG SRC="jpc/wp.gif">',
    ' ',
    '<IMG SRC="jpc/i.gif">',
    '-',
    '<IMG SRC="jpc/i.gif">',
);

sub epdcode {
    my $key = shift;
    my $epd = shift;
    my $code;
    my $h = ${ $hash{$key} };

    for ( @{$epd} ) {
        $code = $h->{$_};    ## no critic
        last if $code;
    }
    return ( $code or 'Unknown' );
}

sub epdset {
    if ( my $epd = shift ) {
        my @array = split( /\/|\s/, $epd );
        my $file = '8';

        %board = ();
        $Kc    = 0;
        $Qc    = 0;
        $kc    = 0;
        $qc    = 0;
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            my @row = split( '', $array[$_] );
            my $rank = 'a';
            for my $piece (@row) {
                $board{"$rank$file"} = $piece if $piece ne '_';
                $rank++;
            }
            $file--;
        }
        $w = ( $array[8] eq 'w' );
        for ( split( '', $array[9] ) ) {
            if ( $_ eq 'K' ) {
                $Kc = 1;
            }
            elsif ( $_ eq 'Q' ) {
                $Qc = 1;
            }
            elsif ( $_ eq 'k' ) {
                $kc = 1;
            }
            elsif ( $_ eq 'q' ) {
                $qc = 1;
            }
        }
    }
    else {
        %board = qw(
            a1 R a2 P a7 p a8 r
            b1 N b2 P b7 p b8 n
            c1 B c2 P c7 p c8 b
            d1 Q d2 P d7 p d8 q
            e1 K e2 P e7 p e8 k
            f1 B f2 P f7 p f8 b
            g1 N g2 P g7 p g8 n
            h1 R h2 P h7 p h8 r
        );
        $w  = 1;
        $Kc = 1;
        $Qc = 1;
        $kc = 1;
        $qc = 1;
    }
    return;
}

sub epdstr {
    my %parameters = @_;
    if ( $parameters{'board'} ) {
        my %board;
        my $hashref = $parameters{'board'};

        for ( keys %$hashref ) {
            $board{$_} = $$hashref{$_};
        }
        $parameters{'epd'} = epd( 0, 0, 0, 0, 0, 0, %board );
    }
    my $epd  = $parameters{'epd'};
    my $type = lc( $parameters{'type'} );
    my ( $border, $corner, $legend ) = ( 'single', 'square', 'no' );

    $border = lc( $parameters{'border'} ) if exists( $parameters{'border'} );
    $corner = lc( $parameters{'corner'} ) if exists( $parameters{'corner'} );
    $legend = lc( $parameters{'legend'} ) if exists( $parameters{'legend'} );
    my @array = split( /\/|\s/, $epd );
    my @board;
    if ( $type eq 'diagram' ) {
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/_/(((pos $array[$_]) % 2) xor ($_ % 2)) ? '-' : ' '/ge;
            push( @board, 8 - $_ . "  " . $array[$_] );
        }
        push( @board, '   abcdefgh' );
    }
    elsif ( $type eq 'text' ) {
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/_/(((pos $array[$_]) % 2) xor ($_ % 2)) ? '-' : ' '/ge;
            push( @board, $array[$_] );
        }
    }
    elsif ( $type eq 'palview' ) {
        my @diagram;
        my $table;

        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/_/(((pos $array[$_]) % 2) xor ($_ % 2)) ? '-' : ' '/ge;
            push( @diagram, $array[$_] );
        }
        for (@diagram) {
            for ( split(//) ) {
                $table .= $convertPalView{$_};
            }
            $table .= "<BR>";
            push( @board, $table );
            $table = '';
        }
    }
    elsif ( $type eq 'latex' ) {
        push( @board, '\\begin{diagram}' );
        push( @board, '\\board' );
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/_/(((pos $array[$_]) % 2) xor ($_ % 2)) ? '*' : ' '/ge;
            push( @board, '{' . $array[$_] . '}' );
        }
        push( @board, '\\end{diagram}' );
    }
    elsif ( $type eq 'tilburg' ) {
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/([pnbrqkPNBRQK_])/_mappiece(pos $array[$_],$_,$1,"\341\345\351\355\361\365\337\343\347\353\357\363
\335","\340\344\350\354\360\364\336\342\346\352\356\362\334")/ge;
            push( @board, $array[$_] );
        }
    }
    else {
        @board = _configureboard( $type, $border, $corner, $legend );
        for ( 0 .. 7 ) {
            $array[$_] =~ s/(\d+)/'_' x $1/ge;
            $array[$_]
                =~ s/([pnbrqkPNBRQK_])/_mappiece(pos $array[$_],$_,$1,$FontMap{$type}{'OnBlack'},$FontMap{$type}
{'OnWhite'})/ge;
            substr( $board[ $_ + 1 ], 1, 8 ) = $array[$_];
        }
    }
    return @board;
}

sub _configureboard {
    my $type   = shift;
    my $border = shift;
    my $corner = shift;
    my $legend = shift;
    my $single = $border eq 'single';
    my $box    = $FontMap{$type}{ $single ? 'SingleBox' : 'DoubleBox' };
    my @board;

    if ( $corner eq 'rounded' ) {
        my $corners
            = $FontMap{$type}{ $single ? 'SingleRounded' : 'DoubleRounded' };

        substr( $box, 0, 1 ) = substr( $corners, 0, 1 );
        substr( $box, 2, 1 ) = substr( $corners, 1, 1 );
        substr( $box, 5, 1 ) = substr( $corners, 2, 1 );
        substr( $box, 7, 1 ) = substr( $corners, 3, 1 );
    }
    push( @board,
              substr( $box, 0, 1 )
            . substr( $box, 1, 1 ) x 8
            . substr( $box, 2, 1 ) );
    for ( 0 .. 7 ) {
        push( @board, substr( $box, 3, 1 ) . ' ' x 8 . substr( $box, 4, 1 ) );
    }
    push( @board,
              substr( $box, 5, 1 )
            . substr( $box, 6, 1 ) x 8
            . substr( $box, 7, 1 ) );
    if ( $legend eq 'yes' ) {
        my $left = $FontMap{$type}{
            $single
            ? 'SingleLeftLegend'
            : 'DoubleLeftLegend'
        };
        my $bottom = $FontMap{$type}{
            $single
            ? 'SingleBottomLegend'
            : 'DoubleBottomLegend'
        };

        for ( 1 .. 8 ) {
            substr( $board[$_], 0, 1 ) = substr( $left, $_ - 1, 1 );
        }
        substr( $board[-1], 1, 8 ) = $bottom;

    }
    return @board;
}

sub _mappiece {
    my $x         = shift;
    my $y         = shift;
    my $piece     = shift;
    my $ifonblack = shift;
    my $ifonwhite = shift;
    my $onwhite   = $onwhite[ ( $y * 8 ) + $x ];
    my $which     = index( 'pnbrqkPNBRQK_', $piece );

    return substr( $onwhite ? $ifonwhite : $ifonblack, $which, 1 );
}

sub epdgetboard {
    if ( my $epd = shift ) {
        epdset($epd);
    }
    return $w, $Kc, $Qc, $kc, $qc, %board;
}

sub epdfromto {
    my @moves = @_;
    my @movelist;

    epdset();
    for (@moves) {
        if ($_) {
            my ( $piece, $to, $from, $promotion ) = _movetype( $w, $_ );
            my $enpassant;
            my $ep = '-';
            my $castles = /O/ ? $_ : '';

            $Kc = 0 if $to eq 'h1';
            $Qc = 0 if $to eq 'a1';
            $kc = 0 if $to eq 'h8';
            $qc = 0 if $to eq 'a8';

            if ( $piece eq "P" ) {
                $piece = "p" if not $w;
                $promotion = lc($promotion) if $promotion and not $w;
                if ($from) {
                    $from .= substr( $to, 1, 1 );
                    if ($w) {
                        substr( $from, 1, 1 ) -= 1;
                    }
                    else {
                        $from++;
                    }
                }
                else {
                    $from = $to;

                    if ($w) {
                        substr( $from, 1, 1 ) -= 1;
                        unless ( $board{$from} ) {
                            $ep = $from;
                            substr( $from, 1, 1 ) -= 1;
                        }
                    }
                    else {
                        $from++;
                        unless ( $board{$from} ) {
                            $ep = $from;
                            $from++;
                        }
                    }
                }

                if ( substr( $from, 0, 1 ) ne substr( $to, 0, 1 ) ) {
                    if ( not $board{$to} ) {
                        $enpassant = $to;
                        if ($w) {
                            substr( $enpassant, 1, 1 )
                                = chr(
                                ord( substr( $enpassant, 1, 1 ) ) - 1 );
                        }
                        else {
                            substr( $enpassant, 1, 1 )
                                = chr(
                                ord( substr( $enpassant, 1, 1 ) ) + 1 );
                        }
                        $board{$enpassant} = undef;
                        $enpassant = defined($enpassant) ? $enpassant : '';
                        $from      = defined($from)      ? $from      : '';
                        $to        = defined($to)        ? $to        : '';
                    }
                }
                ( $board{$to}, $board{$from} )
                    = ( $promotion ? $promotion : $board{$from}, undef );
                $piece     = defined($piece)     ? $piece     : '';
                $from      = defined($from)      ? $from      : '';
                $to        = defined($to)        ? $to        : '';
                $promotion = defined($promotion) ? $promotion : '';
            }
            elsif ( $piece eq "KR" ) {
                my ( $k_from, $r_from ) = unpack( "A2A2", $from );
                my ( $k_to,   $r_to )   = unpack( "A2A2", $to );

                ( $board{$k_to}, $board{$k_from} )
                    = ( $board{$k_from}, undef );
                ( $board{$r_to}, $board{$r_from} )
                    = ( $board{$r_from}, undef );
                if ($w) {
                    $Kc = $Qc = 0;
                }
                else {
                    $kc = $qc = 0;
                }
            }
            else {
                my @piece_at;
                my @fromlist;

                $piece = lc($piece) if not $w;
                @piece_at = psquares( $piece, %board );
                if ($from) {
                    my @tmp;

                    $from = defined($from) ? $from : '';
                    if ( $from =~ /[a-h]/ ) {
                        for (@piece_at) {
                            push( @tmp, $_ )
                                if ( substr( $_, 0, 1 ) eq $from );
                        }
                    }
                    else {

                        for (@piece_at) {
                            push( @tmp, $_ )
                                if ( substr( $_, 1, 1 ) eq $from );
                        }
                    }
                    @piece_at = @tmp;
                }

                for my $square (@piece_at) {
                    for ( @{ $move_table{ uc($piece) }{$square} } ) {
                        push( @fromlist, $square ) if $_ eq $to;
                    }
                }
                if ( scalar(@fromlist) != 1 ) {
                    for (@fromlist) {
                        if (    _canmove( $piece, $to, $_, %board )
                            and _isLegal( $w, $_, $to, %board ) )
                        {
                            $from = $_;
                            last;
                        }
                    }
                }
                else {
                    $from = $fromlist[0];
                }
                if ( $piece =~ /[RrKk]/ ) {
                    if ( $piece eq 'R' ) {
                        $Kc = 0 if $from eq 'h1';
                        $Qc = 0 if $from eq 'a1';
                    }
                    elsif ( $piece eq 'r' ) {
                        $kc = 0 if $from eq 'h8';
                        $qc = 0 if $from eq 'a8';
                    }
                    elsif ( $piece eq 'K' ) {
                        $Kc = $Qc = 0;
                    }
                    else {
                        $kc = $qc = 0;
                    }
                }
                ( $board{$to}, $board{$from} ) = ( $board{$from}, undef );
                $piece = defined($piece) ? $piece : '';
                $from  = defined($from)  ? $from  : '';
                $to    = defined($to)    ? $to    : '';
            }
            my $movehash = {
                piece     => defined($piece)     ? $piece     : '',
                from      => defined($from)      ? $from      : '',
                to        => defined($to)        ? $to        : '',
                promotion => defined($promotion) ? $promotion : '',
                enpassant => defined($enpassant) ? $enpassant : '',
                castles   => defined($castles)   ? $castles   : '',
            };
            push( @movelist, $movehash );
            $w ^= 1;
        }
    }
    %board = ();
    return @movelist;
}

sub epdlist {
    my @moves = @_;
    my $debug = 0;
    my @epdlist;
    my $lineno = 1;

    if ( scalar @moves and $moves[-1] eq '1' ) {
        $debug = 1;
        pop @moves;
        if (%board) {
            print "\%board initialized\n";
        }
        else {
            print "\%board uninitialized\n";
        }
    }
    epdset();
    for (@moves) {
        _Print(%board) if $debug;
        if ($_) {
            my ( $piece, $to, $from, $promotion ) = _movetype( $w, $_ );
            my $enpassant;
            my $ep = '-';

            $Kc = 0 if $to eq 'h1';
            $Qc = 0 if $to eq 'a1';
            $kc = 0 if $to eq 'h8';
            $qc = 0 if $to eq 'a8';

            if ($debug) {
                print "Move[$lineno]='$_'";
                $lineno++;
                if ($piece) {
                    print ", piece='$piece'";
                    print ", to='$to'"               if $to;
                    print ", from='$from'"           if $from;
                    print ", promotion='$promotion'" if $promotion;
                }
                print "\n";
            }

            if ( $piece eq "P" ) {
                $piece = "p" if not $w;
                $promotion = lc($promotion) if $promotion and not $w;
                if ($from) {
                    $from .= substr( $to, 1, 1 );
                    if ($w) {
                        substr( $from, 1, 1 ) -= 1;
                    }
                    else {

                        $from++;
                    }
                }
                else {
                    $from = $to;

                    if ($w) {
                        substr( $from, 1, 1 ) -= 1;
                        unless ( $board{$from} ) {
                            $ep = $from;
                            substr( $from, 1, 1 ) -= 1;
                        }
                    }
                    else {
                        $from++;
                        unless ( $board{$from} ) {
                            $ep = $from;
                            $from++;
                        }
                    }
                }

                if ( substr( $from, 0, 1 ) ne substr( $to, 0, 1 ) ) {
                    if ( not $board{$to} ) {
                        $enpassant = $to;
                        if ($w) {
                            substr( $enpassant, 1, 1 )
                                = chr(
                                ord( substr( $enpassant, 1, 1 ) ) - 1 );
                        }
                        else {
                            substr( $enpassant, 1, 1 )
                                = chr(
                                ord( substr( $enpassant, 1, 1 ) ) + 1 );
                        }
                        $board{$enpassant} = undef;
                        if ($debug) {
                            print "\$enpassant='$enpassant' " if $enpassant;
                            print "\$from='$from' "           if $from;
                            print "\$to='$to'"                if $to;
                            print "\n";
                        }
                    }
                }
                ( $board{$to}, $board{$from} )
                    = ( $promotion ? $promotion : $board{$from}, undef );
                if ($debug) {
                    print "\$piece='$piece' "         if $piece;
                    print "\$from='$from' "           if $from;
                    print "\$to='$to' "               if $to;
                    print "\$promotion='$promotion' " if $promotion;
                }
                push( @epdlist, epd( $w, $Kc, $Qc, $kc, $qc, $ep, %board ) );
                if ($debug) {
                    print "$epdlist[-1]\n";
                }
            }
            elsif ( $piece eq "KR" ) {
                my ( $k_from, $r_from ) = unpack( "A2A2", $from );
                my ( $k_to,   $r_to )   = unpack( "A2A2", $to );

                ( $board{$k_to}, $board{$k_from} )
                    = ( $board{$k_from}, undef );
                ( $board{$r_to}, $board{$r_from} )
                    = ( $board{$r_from}, undef );
                if ($w) {
                    $Kc = $Qc = 0;
                }
                else {
                    $kc = $qc = 0;
                }
                if ($debug) {
                    print $w ? "White" : "Black",
                        " castles from $k_from to $k_to\n";
                }
                push( @epdlist, epd( $w, $Kc, $Qc, $kc, $qc, $ep, %board ) );
                if ($debug) {
                    print "$epdlist[-1]\n";
                }
            }
            else {
                my @piece_at;
                my @fromlist;

                $piece = lc($piece) if not $w;
                @piece_at = psquares( $piece, %board );
                if ($debug) {
                    print "\@piece_at=", join( ",", @piece_at ), "\n"
                        if @piece_at;
                }
                if ($from) {
                    my @tmp;

                    if ($debug) {
                        print "\$from='$from'\n" if $from;
                    }
                    if ( $from =~ /[a-h]/ ) {
                        for (@piece_at) {
                            push( @tmp, $_ )
                                if ( substr( $_, 0, 1 ) eq $from );
                        }
                    }
                    else {

                        for (@piece_at) {
                            push( @tmp, $_ )
                                if ( substr( $_, 1, 1 ) eq $from );
                        }
                    }
                    @piece_at = @tmp;
                }

                for my $square (@piece_at) {
                    for ( @{ $move_table{ uc($piece) }{$square} } ) {
                        push( @fromlist, $square ) if $_ eq $to;
                    }
                }
                print "scalar \@fromlist = ", scalar(@fromlist), "\n"
                    if $debug;
                if ( scalar(@fromlist) != 1 ) {
                    if ($debug) {
                        print "\@fromlist=", join( ",", @fromlist ), "\n"
                            if @fromlist;
                    }
                    for (@fromlist) {
                        if (    _canmove( $piece, $to, $_, %board )
                            and _isLegal( $w, $_, $to, %board ) )
                        {
                            $from = $_;
                            last;
                        }
                    }
                }
                else {
                    $from = $fromlist[0];
                }
                if ( $piece =~ /[RrKk]/ ) {
                    if ( $piece eq 'R' ) {
                        $Kc = 0 if $from eq 'h1';
                        $Qc = 0 if $from eq 'a1';
                    }
                    elsif ( $piece eq 'r' ) {
                        $kc = 0 if $from eq 'h8';
                        $qc = 0 if $from eq 'a8';
                    }
                    elsif ( $piece eq 'K' ) {
                        $Kc = $Qc = 0;
                    }
                    else {
                        $kc = $qc = 0;
                    }
                }
                ( $board{$to}, $board{$from} ) = ( $board{$from}, undef );
                if ($debug) {
                    print "\@piece_at=", join( ",", @piece_at ), "\n"
                        if @piece_at;
                    print "\$piece='$piece' " if $piece;
                    print "\$from='$from' "   if $from;
                    print "\$to='$to' "       if $to;
                }
                push( @epdlist, epd( $w, $Kc, $Qc, $kc, $qc, $ep, %board ) );
                if ($debug) {
                    print "$epdlist[-1]\n";
                }
                if ( not $from ) {
                    _ShowPieces(%board);
                    _Print(%board);
                    print "From undefined\n";
                    exit;
                }
            }
            $w ^= 1;
        }
    }
    %board = ();
    return @epdlist;
}

sub _isLegal {
    my ( $w, $from, $to, %board ) = @_;
    my %board_copy = %board;
    my $kings_square;
    my @attack_list;

    ( $board_copy{$to}, $board_copy{$from} ) = ( $board_copy{$from}, undef );
    my $findking = $w ? 'K' : 'k';
    for ( keys %board_copy ) {
        if ( $board_copy{$_} and ( $board_copy{$_} eq $findking ) ) {
            $kings_square = $_;
            last;
        }
    }
    my $mask = $w ? 'qrnbp' : 'QRNBP';
    for my $square ( keys %board_copy ) {
        if ( $board_copy{$square} and $mask =~ /$board_copy{$square}/ ) {
            for ( @{ $move_table{ uc( $board_copy{$square} ) }{$square} } ) {
                push( @attack_list, $square ) if $_ eq $kings_square;
            }
        }
    }
    for (@attack_list) {
        if ( _canmove( $board_copy{$_}, $kings_square, $_, %board_copy ) ) {
            return 0;
        }
    }
    return 1;
}

sub _ShowPieces {
    my %board = @_;

    for my $square ( keys %board ) {
        my $piece = $board{$square};
        next unless $piece;
        print "'$square' == ", $piece, "\n";
    }
    return;
}

sub _Print {
    my (%board)     = @_;
    my $whitesquare = 1;
    my @rows        = (
        [qw(a8 b8 c8 d8 e8 f8 g8 h8)], [qw(a7 b7 c7 d7 e7 f7 g7 h7)],
        [qw(a6 b6 c6 d6 e6 f6 g6 h6)], [qw(a5 b5 c5 d5 e5 f5 g5 h5)],
        [qw(a4 b4 c4 d4 e4 f4 g4 h4)], [qw(a3 b3 c3 d3 e3 f3 g3 h3)],
        [qw(a2 b2 c2 d2 e2 f2 g2 h2)], [qw(a1 b1 c1 d1 e1 f1 g1 h1)]
    );

    for ( 0 .. 7 ) {
        print "\n", 8 - $_, "  ";
        for ( @{ $rows[$_] } ) {
            if ( $board{$_} ) {
                print $board{$_};
            }
            elsif ($whitesquare) {
                print ' ';
            }
            else {
                print '-';
            }
            $whitesquare ^= 1;
        }
        $whitesquare ^= 1;
    }
    print "\n   abcdefgh\n\n";
    return;
}

sub _movetype {
    my ( $w, $move ) = @_;
    my @result = "'$move':Not yet handled";
    my $from;
    my $to;

    if ( $move =~ /^O-O(?:\+|\#)?$/ ) {
        if ($w) {
            $from = "e1h1";
            $to   = "g1f1";
        }
        else {
            $from = "e8h8";
            $to   = "g8f8";
        }
        @result = ( "KR", $to, $from );
    }
    elsif ( $move =~ /^O-O-O(?:\+|\#)?$/ ) {

        if ($w) {
            $from = "e1a1";
            $to   = "c1d1";
        }
        else {
            $from = "e8a8";
            $to   = "c8d8";
        }
        @result = ( "KR", $to, $from );
    }
    elsif ( $move =~ /^([2-7])([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( "P", $2 );
    }
    elsif ( $move =~ /^([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( "P", $1 );
    }
    elsif ( $move =~ /^([a-h])x?([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( "P", $2, $1 );
    }
    elsif ( $move =~ /^([a-h][18])=?([RNBQ])(?:\+|\#)?$/ ) {
        @result = ( "P", $1, undef, $2 );
    }
    elsif ( $move =~ /^([a-h])x([a-h][18])=?([RNBQ])(?:\+|\#)?$/ ) {
        @result = ( "P", $2, $1, $3 );
    }
    elsif ( $move =~ /^([RNBQK])([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $2 );
    }
    elsif ( $move =~ /^([RNBQK])x([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $2 );
    }
    elsif ( $move =~ /^([RNBQK])([a-h]|[1-8])([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $3, $2 );
    }
    elsif ( $move =~ /^([RNBQK])([a-h][1-8])([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $3, $2 );
    }
    elsif ( $move =~ /^([RNBQK])([a-h]|[1-8])x([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $3, $2 );
    }
    elsif ( $move =~ /^([RNBQK])([a-h][1-8])x([a-h][1-8])(?:\+|\#)?$/ ) {
        @result = ( $1, $3, $2 );
    }
    return @result;
}

sub psquares {
    my ( $piece, %board ) = @_;

    return grep { $_ and $board{$_} and ( $board{$_} eq $piece ) }
        sort keys %board;
}

sub epd {
    my ( $w, $Kc, $Qc, $kc, $qc, $ep, %board ) = @_;
    my @key = qw(
        a8 b8 c8 d8 e8 f8 g8 h8
        a7 b7 c7 d7 e7 f7 g7 h7
        a6 b6 c6 d6 e6 f6 g6 h6
        a5 b5 c5 d5 e5 f5 g5 h5
        a4 b4 c4 d4 e4 f4 g4 h4
        a3 b3 c3 d3 e3 f3 g3 h3
        a2 b2 c2 d2 e2 f2 g2 h2
        a1 b1 c1 d1 e1 f1 g1 h1
    );
    my $n;
    my $piece;
    my $epd;

    for ( 0 .. 63 ) {
        if ( $_ and ( $_ % 8 ) == 0 ) {
            if ($n) {
                $epd .= "$n";
                $n = 0;
            }
            $epd .= "/";
        }
        $piece = $board{ $key[$_] };

        if ($piece) {
            if ($n) {
                $epd .= "$n";
                $n = 0;
            }
            $epd .= $piece;
        }
        else {
            $n++;
        }
    }

    $epd .= "$n" if $n;
    $epd .= ( $w ? " b" : " w" );

    if ( $Kc or $Qc or $kc or $qc ) {
        $epd .= " ";
        $epd .= "K" if $Kc;
        $epd .= "Q" if $Qc;
        $epd .= "k" if $kc;
        $epd .= "q" if $qc;
    }
    else {
        $epd .= " -";
    }
    $epd .= " $ep";
    return $epd;
}

sub _canmove {
    my ( $piece, $to, $from, %board ) = @_;
    my $lto;
    my $rto;
    my $lfrom;
    my $rfrom;
    my $result  = 1;
    my $offset  = 1;
    my $roffset = 1;
    my $loffset = 1;
    my $c       = 0;

    $to =~ /(.)(.)/;
    ( $lto, $rto ) = ( $1, $2 );
    $from =~ /(.)(.)/;
    ( $lfrom, $rfrom ) = ( $1, $2 );

    if ( $board{$from} and $board{to} ) {
        if ( defined( $board{$from} ) and defined( $board{$to} ) ) {
            if ( $board{$from}->color() == $board{$to}->color() ) {
                $result = 0;
            }
        }
    }
    elsif ( ( $rto eq $rfrom ) or ( $lto eq $lfrom ) ) {

        if (   ( $rto eq $rfrom and $lto lt $lfrom )
            or ( $lto eq $lfrom and $rto lt $rfrom ) )
        {
            $offset = -1;
        }

        if ( $lto eq $lfrom ) {
            $c = 1;
        }
        while ( $from ne $to ) {
            substr( $from, $c, 1 )
                = chr( ord( substr( $from, $c, 1 ) ) + $offset );
            if ( defined( $board{$from} ) ) {
                $result = 0 if ( $from ne $to );
                last;
            }
        }
    }
    elsif ( $piece =~ /[bq]/i ) {

        if ( $rto lt $rfrom ) {
            $roffset = -1;
        }
        if ( $lto lt $lfrom ) {
            $loffset = -1;
        }
        while ( $from ne $to ) {
            substr( $from, 0, 1 )
                = chr( ord( substr( $from, 0, 1 ) ) + $loffset );
            substr( $from, 1, 1 )
                = chr( ord( substr( $from, 1, 1 ) ) + $roffset );
            if ( defined( $board{$from} ) ) {
                $result = 0 if ( $from ne $to );
                last;
            }
        }
    }
    return $result;
}

sub epdTaxonomy {
    my (%options) = @_;
    my @moves = @{ $options{'moves'} };
    my @results;
    my ( $eco, $nic, $opening );
    my @epd = reverse( epdlist(@moves) );

    if ( $options{'all'} ) {
        $eco     = epdcode( 'ECO',     \@epd );
        $nic     = epdcode( 'NIC',     \@epd );
        $opening = epdcode( 'Opening', \@epd );
    }
    else {
        for ( lc( keys %options ) ) {
            if ( $_ eq 'eco' ) {
                $eco = epdcode( 'ECO', \@epd );
            }
            elsif ( $_ eq 'nic' ) {
                $nic = epdcode( 'NIC', \@epd );
            }
            elsif ( $_ eq 'Opening' ) {
                $opening = epdcode( 'Opening', \@epd );
            }
        }
    }
    if ( $options{'astags'} ) {
        push( @results, "[ECO \"$eco\"]" )         if $eco;
        push( @results, "[NIC \"$nic\"]" )         if $nic;
        push( @results, "[Opening \"$opening\"]" ) if $opening;
    }
    else {
        push( @results, $eco )     if $eco;
        push( @results, $nic )     if $nic;
        push( @results, $opening ) if $opening;
    }
    return @results;
}

1;
__END__

=for readme start

=head1 NAME

Chess::PGN::EPD - Perl extension to produce and manipulate EPD text.

=head1 VERSION

version 0.34

=head1 SYNOPSIS

From "Working With Epd Files" by Steve Lopez <http://www.chessbaseusa.com/portals/6/tn/Issues_Back/1999_autumn/1999_1031.htm>,

"There's a lot of chess information available on the Internet in a variety of formats. One of these is called
EPD (Extended Position Description) format; it's just a convenient way to provide a board position (rather than
a full game) in an ASCII text notation. For example, here's what the board position after 1.e4 looks like in
EPD format:

    rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

This was designed as a way for chess players and chess programs to pass board positions back and forth for
analysis. You'll frequently see posts to Usenet chess newsgroups or other message boards containing these
EPD positions.

There's a quick, easy way to copy and paste these board descriptions into ChessBase or any of our playing programs
(Fritz, Hiarcs, Nimzo, Junior). Just highlight the EPD line from a post or web page and hit CRTL-C on your keyboard.
Then open ChessBase, go to the Game menu, select "Setup position", and click the button marked "Paste FEN". You'll
instantly see the position appear on the board in the "Setup position" window. Click "OK" and you'll now have an
"Enter new game" window with the proper board position on it taken from the EPD file. You can then save the position
into a database just like any other game..."

Chess::PGN::EPD attempts to bring ease and convenience to its users programmatically by providing a set of
functions that manipulate EPD text.

=for readme stop

=head2 CODE examples

B<THIS>

 #!/usr/bin/perl
 #
 #
 use warnings;
 use strict;
 use Chess::PGN::Parse;
 use Chess::PGN::EPD;

 if ($ARGV[0]) {
     my $pgn = new Chess::PGN::Parse($ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
     while ($pgn->read_game()) {
         $pgn->parse_game();
         print join ( "\n", epdlist(  @{$pgn->moves()} ) ), "\n\n";
     }
 }

B<OR>

 #!/usr/bin/perl
 #
 #
 use warnings;
 use strict;
 use Chess::PGN::EPD;

 my $position = 'rnbqkb1r/ppp1pppp/5n2/3P4/8/8/PPPP1PPP/RNBQKBNR w KQkq -';
 print join("\n",epdstr(epd => $position,type => 'latex'));

B<OR>

 #!/usr/bin/perl
 #
 #
 use strict;
 use warnings;
 use Chess::PGN::Parse;
 use Chess::PGN::EPD;

 if ($ARGV[0]) {
     my $pgn = new Chess::PGN::Parse($ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
     while ($pgn->read_game()) {
         my @epd;

         $pgn->parse_game();
         my @moves = @{ $game{'GameMoves'} };
         print join("\n",epdTaxonomy(moves => \@moves,all => 1,astags => 1)),"\n";
     }
 }

=head1 DESCRIPTION

=head2 epdcode(I<code>,I<epdlistref>)

Determines the requested code given a list of B<epd> strings in reverse order.
Allowed codes are:

=over

=item 'ECO' from The Encyclopedia of Chess Openings.

=item 'NIC' from New in Chess.

=item 'Opening' Traditional Opening name in English.

=back

At the moment, this routine depends on three database files installed along with
the module. On demand other formats (the current is JSON) may be implemented. The 'ToDo' list
also mentions the possibility of extending the databases, although that might come in
the form of a 'How To' rather than any code solution. NOTE: This routine is deprecated
in favor of epdTaxonomy and will at some point be removed.

=head2 epdfromto(I<movelist>)

Returns an array of hashes that contain move information. Useful for conversions to other
forms of notation; i.e. telegraphic or english notation.

=head2 epdgetboard([I<epd>])

Provides access to the 'board' with the current epd postition set up. If given an EPD string,
set board accordingly. The returned values are:

=over

=item $w - boolean, white to move?

=item $Kc - boolean, has white castled king side?

=item $Qc - boolean, has white castled queen side?

=item $kc - boolean, has black castled king side?

=item $qc - boolean, has black castled queen side?

=item %board - hash board, keys are algebraic square names, values are occupying piece.

=back

=head2 epdlist(I<movelist>)

Returns an array of strings that represent the conversion of
game text into positional shorthand, one entry for each move
made in the game.

=head3 Concepts

B<EPD>

"Extended Position Description" is a standard for describing chess
positions along with an extended set of structured attribute values using the
ASCII character set.  It is intended for data and command interchange among
chessplaying programs.  It is also intended for the representation of portable
opening library repositories.

A single EPD uses one text line of variable length composed of four data field
followed by zero or more operations.  The four fields of the EPD specification
are the same as the first four fields of the FEN specification.

A text file composed exclusively of EPD data records should have a file name
with the suffix ".epd".

EPD is based in part on the earlier FEN standard; it has added extensions for
use with opening library preparation and also for general data and command
interchange among advanced chess programs.  EPD was developed by John Stanback
and Steven Edwards; its first implementation is in Stanback's master strength
chessplaying program Zarkov.

Like FEN, EPD can also be used for general position description.  However,
unlike FEN, EPD is designed to be expandable by the addition of new operations
that provide new functionality as needs arise.

B<FEN>

"Forsyth-Edwards Notation" is a standard for describing chess
positions using the ASCII character set.

A single FEN record uses one text line of variable length composed of six data
fields.  The first four fields of the FEN specification are the same as the
first four fields of the EPD specification.

A text file composed exclusively of FEN data records should have a file name
with the suffix ".fen".

B<History>

FEN is based on a 19th century standard for position recording designed by the
Scotsman David Forsyth, a newspaper journalist.  The original Forsyth standard
has been slightly extended for use with chess software by Steven Edwards with
assistance from commentators on the Internet.

B<Uses for a position notation>

Having a standard position notation is particularly important for chess
programmers as it allows them to share position databases.  For example, there
exist standard position notation databases with many of the classical benchmark
tests for chessplaying programs, and by using a common position notation format
many hours of tedious data entry can be saved.  Additionally, a position
notation can be useful for page layout programs and for confirming position
status for e-mail competition.

B<Data fields>

FEN specifies the piece placement, the active color, the castling availability,
the en passant target square, the halfmove clock, and the fullmove number.
These can all fit on a single text line in an easily read format.  The length
of a FEN position description varies somewhat according to the position. In
some cases, the description could be eighty or more characters in length and so
may not fit conveniently on some displays.  However, these positions aren't too
common.

A FEN description has six fields.  Each field is composed only of non-blank
printing ASCII characters.  Adjacent fields are separated by a single ASCII
space character.

=over

=item Piece placement data

The first field represents the placement of the pieces on the board.  The board
contents are specified starting with the eighth rank and ending with the first
rank.  For each rank, the squares are specified from file a to file h.  White
pieces are identified by uppercase SAN piece letters ("PNBRQK") and black
pieces are identified by lowercase SAN piece letters ("pnbrqk").  Empty squares
are represented by the digits one through eight; the digit used represents the
count of contiguous empty squares along a rank.  A solidus character "/" is
used to separate data of adjacent ranks.

=item Active color

The second field represents the active color.  A lower case "w" is used if
White is to move; a lower case "b" is used if Black is the active player.

=item Castling availability

The third field represents castling availability.  This indicates potential
future castling that may of may not be possible at the moment due to blocking
pieces or enemy attacks.  If there is no castling availability for either side,
the single character symbol "-" is used.  Otherwise, a combination of from one
to four characters are present.  If White has kingside castling availability,
the uppercase letter "K" appears.  If White has queenside castling
availability, the uppercase letter "Q" appears.  If Black has kingside castling
availability, the lowercase letter "k" appears.  If Black has queenside
castling availability, then the lowercase letter "q" appears.  Those letters
which appear will be ordered first uppercase before lowercase and second
kingside before queenside.  There is no white space between the letters.

=item En passant target square

The fourth field is the en passant target square.  If there is no en passant
target square then the single character symbol "-" appears.  If there is an en
passant target square then is represented by a lowercase file character
immediately followed by a rank digit.  Obviously, the rank digit will be "3"
following a white pawn double advance (Black is the active color) or else be
the digit "6" after a black pawn double advance (White being the active color).

An en passant target square is given if and only if the last move was a pawn
advance of two squares.  Therefore, an en passant target square field may have
a square name even if there is no pawn of the opposing side that may
immediately execute the en passant capture.

=item Halfmove clock

The fifth field is a nonnegative integer representing the halfmove clock.  This
number is the count of halfmoves (or ply) since the last pawn advance or
capturing move.  This value is used for the fifty move draw rule.

=item Fullmove number

The sixth and last field is a positive integer that gives the fullmove number.
This will have the value "1" for the first move of a game for both White and
Black.  It is incremented by one immediately after each move by Black.

=back

B<Examples>

Here's the FEN for the starting position:

rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1

And after the move 1. e4:

rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1

And then after 1. ... c5:

rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6 0 2

And then after 2. Nf3:

rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq - 1 2

For two kings on their home squares and a white pawn on e2 (White to move) with
thirty eight full moves played with five halfmoves since the last pawn move or
capture:

4k3/8/8/8/8/8/4P3/4K3 w - - 5 39

=head3 NOTE

With only a little observation, the astute user will notice that actually this function
doesn't return either EPD or FEN, but rather a bit of both. It is mostly FEN, but it lacks
the Fullmove number field, since for most usage that information is available else where
or can easily be reconstructed. As to why the module is called EPD, well I figured since it
wasn't one and it wasn't the other, that left it up to me to choose--besides, who would want
a module named after a swamp?!

=head2 epdset(I<epd>)

For those instances where the game in question does not begin
with a complete move list, this function allows the user to
set the starting position using a 'EPD' string as described
elsewhere in the document.

=head2 epdstr(I<epd>|I<board>,I<type> [I<border>,I<corner>,I<legend>])

Returns an array of strings that represent a diagramatic conversion of the
specified B<epd> string or board postion to the specified B<type>. Parameters are passed as
a anonymous hash, i.e. epdstr(epd => $position,type => 'diagram') or similar.

=head3 Types Supported

The following types are understood by B<epdstr>:

=over

=item 'diagram'

A plain ASCII diagram with simple border showing rank and file. Typical output:

 8  rnbqkb r
 7  ppp pppp
 6   - - n -
 5  - -P- -
 4   - - - -
 3  - - - -
 2  PPPP PPP
 1  RNBQKBNR
    abcdefgh

=item 'text'

A plain ASCII diagram. Typical output:

 rnbqkb r
 ppp pppp
  - - n -
 - -P- -
  - - - -
 - - - -
 PPPP PPP
 RNBQKBNR

=item 'palview'

An array of HTML information that represents the tabular diagram information for PalView.
Typical output:

<IMG SRC="jpc/br.gif"><IMG SRC="jpc/bn.gif"><IMG SRC="jpc/bb.gif"><IMG SRC="jpc/bq.gif"><IMG
SRC="jpc/bk.gif"><IMG SRC="jpc/bb.gif"><IMG SRC="jpc/bn.gif"><IMG SRC="jpc/br.gif"><BR>
<IMG SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><IMG
SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><IMG SRC="jpc/bp.gif"><BR>
<IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG
SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><BR>
<IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG
SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><BR>
<IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG
SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><BR>
<IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG
SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/wn.gif"><BR>
<IMG SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><IMG
SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><IMG SRC="jpc/wp.gif"><BR>
<IMG SRC="jpc/wr.gif"><IMG SRC="jpc/wn.gif"><IMG SRC="jpc/wb.gif"><IMG SRC="jpc/wq.gif"><IMG
SRC="jpc/wk.gif"><IMG SRC="jpc/wb.gif"><IMG SRC="jpc/i.gif"><IMG SRC="jpc/wr.gif"><BR>

=item 'latex'

The necessary text fragment to 'set' the diagram in LaTeX using
any variation of Piet Tutelars original chess12.tar.Z package. As given, the LaTeX
command 'diagram' is used. As an example here is the source to test.tex:

 %%
 %% test.tex -- example LaTeX file to demonstrate output from Chess::PGN::EPD
 %%
 \documentclass{article}
 \usepackage{chess}
 \usepackage{bdfchess}
 \begin{document}
 \newenvironment{diagram}{\begin{nochess}}{$$\showboardwithnotation$$\end{nochess}}
 %%
 %% fragment as produced by epdstr(epd => $position,type => 'latex');
 %%
 \begin{diagram}
 \board
 {rnbqkb r}
 {ppp pppp}
 { * * n *}
 {* *P* * }
 { * * * *}
 {* * * * }
 {PPPP PPP}
 {RNBQKBNR}
 \end{diagram}
 %%
 %% end of fragment
 %%
 \end{document}

=item 'linares'

Alpine Electronics' LinaresDiagram font. Mapping also works with both HastingsDiagram
and ZurichDiagram fonts. Single or double border, With or without algebraic legend.

=item 'linares1'

Standard mapping, single border, squares offset.

=item 'linares2'

Standard mapping, thick single border.

=item 'tilburg'

A borderless font designed by Eric Schiller and Bill Cone.

=item 'marroquin'

This type refers to any font designed by Armando H. Marroquin,
excepting his FigurineSymbol fonts. They having a different purpose,
have a different mapping.

=item 'leschemelle'

The map for Chess Cases designed by Matthieu Leschemelle.

=item 'bentzen1'

The map for Chess Alpha designed by Eric Bentzen.

=item 'bentzen2'

The map for Chess Berlin designed by Eric Bentzen.

=item 'hickey'

The map for Chess Plain designed by Alan Hickey.

=item 'scott1'

The map for Chess Regular a port of Adobe Cheq ported to
True Type by Alistair Scott.

=item 'scott2'

The map for Chess Usual a modification of Chess Regular
by Armando H. Marroquin.

=item 'bodlaender'

The map for Chess Utrecht designed by Hans Bodlaender.

=item 'cowderoy'

The map for Traveller Standard v3  designed by Alan Cowderoy.

=back

Note that 'type' is not case sensative so that 'latex' and 'LaTeX' will both
work equally well.

=head3 Fonts Supported

List with font name, font author, and type name:

=over

=item Chess Cases -- Matthieu Leschemelle -- leschemelle

=item Chess Adventurer -- Armando H. Marroquin -- marroquin

=item Chess Alfonso-X -- Armando H. Marroquin -- marroquin

=item Chess Alpha -- Eric Bentzen -- bentzen1

=item Chess Berlin -- Eric Bentzen -- bentzen2

=item Chess Condal -- Armando H. Marroquin -- marroquin

=item Chess Harlequin -- Armando H. Marroquin -- marroquin

=item Chess Kingdom -- Armando H. Marroquin -- marroquin

=item Chess Leipzig -- Armando H. Marroquin -- marroquin

=item Chess Line -- Armando H. Marroquin -- marroquin

=item Chess Lucena -- Armando H. Marroquin -- marroquin

=item Chess Magnetic -- Armando H. Marroquin -- marroquin

=item Chess Mark -- Armando H. Marroquin -- marroquin

=item Chess Marroquin -- Armando H. Marroquin -- marroquin

=item Chess Maya -- Armando H. Marroquin -- marroquin

=item Chess Mediaeval -- Armando H. Marroquin -- marroquin

=item Chess Merida -- Armando H. Marroquin -- marroquin

=item Chess Millennia -- Armando H. Marroquin -- marroquin

=item Chess Miscel -- Armando H. Marroquin -- marroquin

=item Chess Montreal -- Gary Katch -- katch

=item Chess Motif -- Armando H. Marroquin -- marroquin

=item Chess Plain -- Alan Hickey -- hickey

=item Chess Regular -- Alistair Scott -- scott1

=item Chess Usual -- Armando H. Marroquin -- scott2

=item Chess Utrecht -- Hans Bodlaender -- bodlaender

=item Tilburg -- Eric Schiller and Bill Cone -- tilburg

=item Traveller Standard v3 -- Alan Cowderoy -- cowderoy

=back

These are available at L<http://www.enpassant.dk/chess/fonteng.htm> along
with a good deal of useful information on chess desktop publishing.

=head3 Font Designers Supported

=over

=item Eric Bentzen

=item Bill Cone

=item Alan Cowderoy

=item Alan Hickey

=item Gary Katch

=item Armondo H. Marroquin

=item Eric Schiller

=item Alastair Scott

=item Steve Smith

=item Piet Tutelaers

=back

=head3 Borders and Such Like

Some fonts, for example those designed by Armondo H. Marroquin support a variety of border
styles and decorations. The border may be single or double, with square corners or rounded,
and with an algebraic legend. These effects are supported by the addition of the necessary
parameters to the allowed parameter list. In particular:

=over

=item * Border, values can be either 'single' or 'double' (default is 'single')

=item * Corner, values can be either 'square' or 'rounded' (default is 'square')

=item * Legend, values can be either 'yes' or 'no' (default is 'no')

=back

Again, letter case is not particularly important, 'yes' works as well as 'Yes' etc.
As for those fonts that don't support a particular feature, B<epdstr> will fail silently, that
is, the parameter will be ignored and processing will continue as though no such request
had been made.

=head2 epdTaxonomy(I<options>)

At one point the following was required in order to properly 'tag' a PGN file with opening
names and information:

 if ($ARGV[0]) {
     my $pgn = new Chess::PGN::Parse($ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
     while ($pgn->read_game()) {
         my @epd;

         $pgn->parse_game();
         @epd = reverse epdlist( @{$pgn->moves()} );
         print '[ECO,"',epdcode('ECO',\@epd),"\"]\n";
         print '[NIC,"',epdcode('NIC',\@epd),"\"]\n";
         print '[Opening,"',epdcode('Opening',\@epd),"\"]\n";
     }
 }

Not all that bad, but not all that clear either. As can be seen from the examples shown at the
begining of this documentation, I've created a new subroutine called epdTaxonomy that replaces
all of the above with:

 if ($ARGV[0]) {
     my $pgn = new Chess::PGN::Parse($ARGV[0]) or die "Can't open $ARGV[0]: $!\n";
     while ($pgn->read_game()) {
         my @epd;

         $pgn->parse_game();
         my @moves = @{ $game{'GameMoves'} };
         print join("\n",epdTaxonomy(moves => \@moves,all => 1,astags => 1)),"\n";
     }
 }

Clearly a win for the parsimonious team! This sub takes a single parameter, a hash with the following
possibilities:

=over

=item 'moves' -- required in order to have something to work with.

=item 'all' -- if true, create all three tags supported.

=item 'astags' -- if true, create complete PGN header tags for the specified codes.

=item 'eco' -- create tag information for ECO codes.

=item 'nic' -- create tag information for NIC codes.

=item 'opening' -- create tag information for Opening codes.

=back

See the description of epdcode for brief descriptions of what these codes represent.

=head2 psquares(I<piece>,I<board>)

Given a 'piece' (single character, uppercase for white, lowercase for black, KQRBNPkqrbnp) and
the current board hash, return a list of square names (algebraic) locating instances of the
piece.

=head1 EXPORT

=over

=item epdcode - given a list of EPD strings, return the requested code or 'unknown'.

=item epdfromto - given a list of moves, return an array of hashes which contain move information.

=item epdgetboard - given an EPD string setup board and related. Either way return board and related
information.

=item epdlist - given a list of moves, return a list of EPD strings.

=item epdset - allows the user to specifiy an initial position.

=item epdstr - given an EPD string or a board, convert it to the specified string representation.

=item epdTaxonomy - one stop shopping for conversion of epd array to ECO, NIC and opening tag information.

=item psquares - given the piece and the board, generate and return a list of squares occupied by that
type of piece.

=back

=head1 DEPENDENCIES

=over

=item Chess::PGN::Moves     => 0.05

=item Chess::PGN::Parse     => 0.20

=item Test::More            => 0.94

=item File::ShareDir        => 1.102

=item File::Slurper         => 0.008

=item Cpanel::JSON::XS      => 3.0213

=back

=head1 TODO

=over

=item Continue to improve documentation.

=item oo-ify support variables.

=item Allow font map customization.

=item Solve the english to algebraic problem.

=back

=head1 KNOWN BUGS

None known; Unknown? Of course, though I try to be neat...

=for readme start

=for readme plugin version

=for readme plugin changes

=for readme plugin requires

=head1 INSTALLATION

Traditional recipe based on Makefile.PL:

    perl Makefile.PL
    make
    make test
    make install

Note that some distributions will have a Build.PL file instead of
or in addition to Makefile.PL. In that case use this recipe:

    perl Build.PL
    ./Build
    ./Build test
    ./Build install

=head1 AUTHOR

Hugh S. Myers <hsmyers@gmail.com>

=head1 LICENSE

             The "Artistic License"

                Preamble

The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.

Definitions:

    "Package" refers to the collection of files distributed by the
    Copyright Holder, and derivatives of that collection of files
    created through textual modification.

    "Standard Version" refers to such a Package if it has not been
    modified, or has been modified in accordance with the wishes
    of the Copyright Holder as specified below.

    "Copyright Holder" is whoever is named in the copyright or
    copyrights for the package.

    "You" is you, if you're thinking about copying or distributing
    this Package.

    "Reasonable copying fee" is whatever you can justify on the
    basis of media cost, duplication charges, time of people involved,
    and so on.  (You will not be required to justify it to the
    Copyright Holder, but only to the computing community at large
    as a market that must bear the fee.)

    "Freely Available" means that no fee is charged for the item
    itself, though there may be fees involved in handling the item.
    It also means that recipients of the item may redistribute it
    under the same conditions they received it.

1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.

2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder.  A Package
modified in such a way shall still be considered the Standard Version.

3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:

    a) place your modifications in the Public Domain or otherwise make them
    Freely Available, such as by posting said modifications to Usenet or
    an equivalent medium, or placing the modifications on a major archive
    site such as uunet.uu.net, or by allowing the Copyright Holder to include
    your modifications in the Standard Version of the Package.

    b) use the modified Package only within your corporation or organization.

    c) rename any non-standard executables so the names do not conflict
    with standard executables, which must also be provided, and provide
    a separate manual page for each non-standard executable that clearly
    documents how it differs from the Standard Version.

    d) make other distribution arrangements with the Copyright Holder.

4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:

    a) distribute a Standard Version of the executables and library files,
    together with instructions (in the manual page or equivalent) on where
    to get the Standard Version.

    b) accompany the distribution with the machine-readable source of
    the Package with your modifications.

    c) give non-standard executables non-standard names, and clearly
    document the differences in manual pages (or equivalent), together
    with instructions on where to get the Standard Version.

    d) make other distribution arrangements with the Copyright Holder.

5. You may charge a reasonable copying fee for any distribution of this
Package.  You may charge any fee you choose for support of this
Package.  You may not charge a fee for this Package itself.  However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own.  You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.

6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package.  If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.

7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.

8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution.  Such use shall not be
construed as a distribution of this Package.

9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.

10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

                The End

=head1 COPYRIGHT

Copyright (C) 2017 Hugh S. Myers
=end :readme

share/ECO.db  view on Meta::CPAN

{"rnbqkb1r/ppp1pp1p/3p1np1/8/3PP3/2N2N2/PPP2PPP/R1BQKB1R b KQkq -":"B07","r1bq1rk1/2p1bppp/p1np1n2/1p2p3/4P3/1BPP1N2/PP3PPP/RNBQR1K1 b - -":"C90","rnbk1bnr/pppp2pp/8/8/2B1pp1q/2N5/PPPPQ1PP/R1BK2NR w - -":"C33","rnbqr1k1/ppbp1pp1/2p2n1p/4p3/NP2P3/P2P1...

share/NIC.db  view on Meta::CPAN

{"rnbqk2r/pp1pppbp/5np1/2P5/8/4PN2/PPP2PPP/RNBQKB1R b KQkq -":"RE 10*","rnbqk1nr/ppp1ppbp/3p2p1/8/2PPP3/2N5/PP3PPP/R1BQKBNR b KQkq -":"KF 4","rnbqkb1r/pppppppp/5n2/8/8/8/PPPPPPPP/RNBQKBNR w KQkq -":"QP 11*","r1bqrbk1/pp3ppp/2n2n2/2ppp3/4P3/2PP1NP1/PP...

share/Opening.db  view on Meta::CPAN

{"r1bqkbnr/pp1ppppp/2n5/2p5/4PP2/2N5/PPPP2PP/R1BQKBNR b KQkq -":"Sicilian: Grand Prix attack","rnbqk1nr/ppp1ppbp/3p2p1/8/3PP3/2N1B3/PPP2PPP/R2QKBNR b KQkq -":"Pirc-Robatsch","rnbqkbnr/ppp2ppp/8/3p4/3Np3/3P4/PPP1PPPP/RNBQKB1R b KQkq -":"Alekhine's def...

t/00_dependancy.t  view on Meta::CPAN

#!/usr/bin/perl
# 00_dependancy.t -- test for dependancies
use Test::More tests => 2;

BEGIN {
    require_ok Chess::PGN::Moves
        or BAIL_OUT "Can't load needed dependancy Chess::PGN::Moves";
    use_ok(Chess::PGN::EPD);
}

t/01_epdcode.t  view on Meta::CPAN

#!/usr/bin/perl
# 01_epdcode.t -- test epdcode.
use Test::More tests => 7;
use Chess::PGN::EPD qw( epdlist epdcode );

ok(1); # 1. If we made it this far, we're ok.

my @epd1;
my @epd2;
my @moves1 = qw(
e4 e6 f4 d5 e5 c5 Nf3 Nc6 d3 Be7 Be2 Nh6 c3 O-O O-O f6
exf6 Bxf6 d4 cxd4 cxd4 Qb6 Nc3 Bxd4+ Kh1 Bxc3 bxc3 Ng4
Nd4 Nxd4 cxd4 Nf6 Ba3 Rf7 Rb1 Qd8 Bd3 Bd7 Qf3 Bc6
f5 Ne4 Bxe4 dxe4 Qd1 exf5 Rb2 Qd5 Rbf2 e3 Re2 Bb5
);
my @moves2 = qw(
d4 Nf6 c4 e6 Nc3 Bb4 e3 b6 Ne2 Bb7 a3 Be7 f3 d5 cxd5 exd5 Ng3 O-O Bd3 c5
O-O Re8 Nf5 Bf8 g4 g6 Ng3 Nc6 g5 cxd4 exd4 Nd7 Nge2 Bg7 Nb5 Nf8 f4 a6 f5
axb5 f6 Bh8 Bxb5 Ba6 Bxa6 Rxa6 Bf4 Qd7 Rc1 Raa8 Rc3 Re4 Ng3 Rxd4 Qc2 Na5
Be3 Rg4 Qd1 Nc4 Bc1 b5 Rd3 d4 Re1 h5 b3 Nb6 Re7 Qd6 Re4 Rxe4 Nxe4 Qc6 Nd2
Ne6 Nf3 Rd8 Be3 Qe4
);

@epd1 = reverse epdlist( @moves1 );
@epd2 = reverse epdlist( @moves2 );

is(ECO(\@epd1),'C00','ECO lookup #1'); # 2.
is(NIC(\@epd1),'FR 1','NIC lookup #1'); # 3.
is(Opening(\@epd1),'French: Labourdonnais variation','Opening lookup #1'); # 4.
is(ECO(\@epd2),'E44','ECO lookup #2'); # 5.
is(NIC(\@epd2),'NI 13','NIC lookup #2'); # 6.
is(Opening(\@epd2),'Nimzo-Indian: Fischer variation, 5.Ne2'); # 7.

sub ECO {
    my $movesref = shift;

    return epdcode('ECO',$movesref);
}

sub NIC {
    my $movesref = shift;

    return epdcode('NIC',$movesref);
}

sub Opening {
    my $movesref = shift;

    return epdcode('Opening',$movesref);
}

t/02_Shareable.t  view on Meta::CPAN

#!/usr/bin/perl
# 02_Shareable.t -- test 'Shared' DBs.
#
use strict;
use warnings;
use diagnostics;
use File::Slurper qw{read_text write_text};
use Cpanel::JSON::XS qw(encode_json decode_json);
use File::ShareDir qw(dist_file);
use Test::More tests => 4;


ok(1);    # load failure check...

my ( $ECO_path, $NIC_path, $Opening_path ) = GetPaths('Chess-PGN-EPD');

my $hECO     = decode_json read_text($ECO_path);
my $hNIC     = decode_json read_text($NIC_path);
my $hOpening = decode_json read_text($Opening_path);

ok( $hECO->{"r1b1kbnr/ppq1pppp/2n5/1Bpp4/2P5/4PN2/PP1P1PPP/RNBQK2R b KQkq -"}
        eq "E38*",
    'test ECO.db'
);
ok( $hNIC->{"r1b1kbnr/ppq1pppp/2n5/1Bpp4/2P5/4PN2/PP1P1PPP/RNBQK2R b KQkq -"}
        eq "NI 22*",
    'test NIC.db'
);
ok( $hOpening->{
        "r1b1k2r/2q1bppp/p2p1n2/npp1p3/P2PP3/2P2N2/1PB2PPP/RNBQR1K1 b kq -"}
        eq "Ruy Lopez: closed, Balla variation",
    'test Opening.db'
);

sub GetPaths {
    my $dist      = shift;
    my $dbECO     = dist_file( $dist, 'ECO.db' );
    my $dbNIC     = dist_file( $dist, 'NIC.db' );
    my $dbOpening = dist_file( $dist, 'Opening.db' );

    return ( $dbECO, $dbNIC, $dbOpening );
}

t/03_epdlist.t  view on Meta::CPAN

#!/usr/bin/perl
# 03_epdlist.t - test epdlist
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw( epdlist );
use Test::More tests => 4;

ok(1); # load failure check...

my @game = qw ( e4 c5 Nf3 );
my @answers = (
	'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3',
	'rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6',
	'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq -',
);

is(check_epd(0,@game),$answers[0],'Check epdlist function');
is(check_epd(1,@game),$answers[1],'Check epdlist function');
is(check_epd(2,@game),$answers[2],'Check epdlist function');

sub check_epd {
	my ($which,@moves) = @_;
	my @epdstrings = epdlist(@moves);
	return $epdstrings[$which];
}

t/04_epdstr.t  view on Meta::CPAN

#!/usr/bin/perl
# 04_epdstr.t - test epdstr
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw ( epdstr );
use Test::More tests => 2;

ok(1);    # load failure check...

my $position = 'rnbqkb1r/ppp1pppp/5n2/3P4/8/8/PPPP1PPP/RNBQKBNR w KQkq -';
my $result =
    "\\begin{diagram}\n"
  . "\\board\n"
  . "{rnbqkb r}\n"
  . "{ppp pppp}\n"
  . "{ * * n *}\n"
  . "{* *P* * }\n"
  . "{ * * * *}\n"
  . "{* * * * }\n"
  . "{PPPP PPP}\n"
  . "{RNBQKBNR}\n"
  . "\\end{diagram}";

is( join( "\n", epdstr( epd => $position, type => 'latex' ) ), $result, 'Check epdstr' );

t/05_list-str.t  view on Meta::CPAN

#!/usr/bin/perl
# 05_list-str.t - test epdlist and epdstr
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw( epdlist epdcode );
use Chess::PGN::Parse;
use Test::More tests => 2;

ok(1);    # load failure check...

my $text = 
    "[Event \"ICC 2 12 u\"]\n" .
    "[Site \"Internet Chess Club\"]\n" .
    "[Date \"2003.03.31\"]\n" .
    "[Round \"-\"]\n" .
    "[White \"hsmyers\"]\n" .
    "[Black \"guest2023\"]\n" .
    "[Result \"1-0\"]\n" .
    "[ICCResult \"Black resigns\"]\n" .
    "[WhiteElo \"1492\"]\n" .
    "[Opening \"KGA: Fischer defense\"]\n" .
    "[ECO \"C30\"]\n" .
    "[NIC \"KG.05\"]\n" .
    "[Time \"14:36:59\"]\n" .
    "[TimeControl \"120+12\"]\n" .
    "\n" .
    "1. e4 e5 2. f4 d6 3. Nf3 exf4 4. Be2 g5 5. O-O Bg4 6. d4 Nc6 7. c3 Qf6 8.\n" .
    "Bb5 Ne7 9. d5 a6 10. dxc6 axb5 11. cxb7 Rb8 12. Qb3 Rxb7 13. a4 Bg7 14. axb5\n" .
    "O-O 15. Na3 Rfb8 16. c4 c6 17. Qc2 cxb5 18. cxb5 Rc8 19. Qd2 Bxf3 20. Rxf3\n" .
    "Qd4+ 21. Qxd4 Bxd4+ 22. Kh1 Re8 23. Rd3 Be5 24. Rb1 g4 25. Bd2 g3 26. hxg3\n" .
    "fxg3 27. Bc3 Bf4 28. Rf3 Ng6 29. Re1 Rbe7 30. b6 Rxe4 31. Rxe4 Rxe4 32. b7\n" .
    "d5 33. Rxf4 Nxf4 34. b8=Q+ {Black resigns} 1-0\n" ;
my $answer =
    "[ECO,\"C34\"]\n" .
    "[NIC,\"KP 10\"]\n" .
    "[Opening,\"KGA: Fischer defense\"]";

is(check_both($text),$answer,'Check both epdlist and epdcode');

sub check_both {
    my $text = shift;
    my @epd;
    my @results;
    my $pgn = new Chess::PGN::Parse undef, $text;

    while ( $pgn->read_game() ) {
        $pgn->parse_game();
        @epd = reverse epdlist( @{ $pgn->moves() } );
        push(@results, '[ECO,"' . epdcode( 'ECO',     \@epd ) . "\"]");
        push(@results, '[NIC,"' . epdcode( 'NIC',     \@epd ) . "\"]");
        push(@results, '[Opening,"' . epdcode( 'Opening', \@epd ) . "\"]");
    }
    return join("\n",@results);
}

t/06_epdgetboard.t  view on Meta::CPAN

#!/usr/bin/perl
# 06_epdgetboard.t - test epdgetboard
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw( epdgetboard );
use Test::More tests => 4;

ok(1);    # load failure check...

my @answers = (
    ',1,1,1,1',
    '1,1,1,1,1',
    ',1,1,1,1',
);
my @epd = (
	'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3',
	'rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6',
	'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq -',
);

is(check_epdgetboard($epd[0]),$answers[0],'Check epdgetboard');
is(check_epdgetboard($epd[1]),$answers[1],'Check epdgetboard');
is(check_epdgetboard($epd[2]),$answers[2],'Check epdgetboard');

sub check_epdgetboard {
    my $epd = shift;
    my ($w,$Kc,$Qc,$kc,$qc,%board) = epdgetboard($epd);
    return "$w,$Kc,$Qc,$kc,$qc";
}

t/07_psquares.t  view on Meta::CPAN

#!/usr/bin/perl
# 07_psquares.t - test psquares
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw( epdgetboard psquares );
use Test::More tests => 7;

ok(1);    # load failure check...

my @answers = ( 
    'b1 g1', 
    'b1 g1', 
    'b1 f3', 
    'b8 g8',
    'b8 g8',
    'b8 g8',
);
my @epd = (
    'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3',
    'rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6',
    'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq -',
);

is( check_psquares( $epd[0], 'N' ), $answers[0], 'Check psquares' );
is( check_psquares( $epd[1], 'N' ), $answers[1], 'Check psquares' );
is( check_psquares( $epd[2], 'N' ), $answers[2], 'Check psquares' );
is( check_psquares( $epd[0], 'n' ), $answers[3], 'Check psquares' );
is( check_psquares( $epd[1], 'n' ), $answers[4], 'Check psquares' );
is( check_psquares( $epd[2], 'n' ), $answers[5], 'Check psquares' );

sub check_psquares {
    my ( $epd, $piece ) = @_;
    my ( $w, $Kc, $Qc, $kc, $qc, %board ) = epdgetboard($epd);
    my @result = psquares( $piece, %board );
    return join( " ", @result );
}

t/08_epdset.t  view on Meta::CPAN

#!/usr/bin/perl
# 08_epdset.t - test epdset
#
use strict;
use warnings;
use diagnostics;
use Chess::PGN::EPD qw( epdset epdgetboard psquares );
use Test::More tests => 4;

ok(1);    # load failure check...

my @answers = ( 
    'b1 g1', 
    'b1 g1', 
    'b1 f3', 
);
my @epd = (
    'rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3',
    'rnbqkbnr/pp1ppppp/8/2p5/4P3/8/PPPP1PPP/RNBQKBNR w KQkq c6',
    'rnbqkbnr/pp1ppppp/8/2p5/4P3/5N2/PPPP1PPP/RNBQKB1R b KQkq -',
);

is( check_epdset( $epd[0]), $answers[0], 'Check epdset' );
is( check_epdset( $epd[1]), $answers[1], 'Check epdset' );
is( check_epdset( $epd[2]), $answers[2], 'Check epdset' );

sub check_epdset {
    epdset(shift);
    my ( $w, $Kc, $Qc, $kc, $qc, %board ) = epdgetboard();
    my @result = psquares( 'N', %board );
    return join( " ", @result );
}

t/09_epdTaxonomy.t  view on Meta::CPAN

#!/usr/bin/perl
# 09_epdTaxonomy.t -- test epdTaxonomy.
use Test::More tests => 13;
use Chess::PGN::EPD qw( epdlist epdTaxonomy );

ok(1); # 1. If we made it this far, we're ok.

my @moves1 = qw(
e4 e6 f4 d5 e5 c5 Nf3 Nc6 d3 Be7 Be2 Nh6 c3 O-O O-O f6
exf6 Bxf6 d4 cxd4 cxd4 Qb6 Nc3 Bxd4+ Kh1 Bxc3 bxc3 Ng4
Nd4 Nxd4 cxd4 Nf6 Ba3 Rf7 Rb1 Qd8 Bd3 Bd7 Qf3 Bc6
f5 Ne4 Bxe4 dxe4 Qd1 exf5 Rb2 Qd5 Rbf2 e3 Re2 Bb5
);
my @moves2 = qw(
d4 Nf6 c4 e6 Nc3 Bb4 e3 b6 Ne2 Bb7 a3 Be7 f3 d5 cxd5 exd5 Ng3 O-O Bd3 c5
O-O Re8 Nf5 Bf8 g4 g6 Ng3 Nc6 g5 cxd4 exd4 Nd7 Nge2 Bg7 Nb5 Nf8 f4 a6 f5
axb5 f6 Bh8 Bxb5 Ba6 Bxa6 Rxa6 Bf4 Qd7 Rc1 Raa8 Rc3 Re4 Ng3 Rxd4 Qc2 Na5
Be3 Rg4 Qd1 Nc4 Bc1 b5 Rd3 d4 Re1 h5 b3 Nb6 Re7 Qd6 Re4 Rxe4 Nxe4 Qc6 Nd2
Ne6 Nf3 Rd8 Be3 Qe4
);

is(ECO1(\@moves1),'C00','ECO lookup #1'); # 2.
is(NIC1(\@moves1),'FR 1','NIC lookup #1'); # 3.
is(Opening1(\@moves1),'French: Labourdonnais variation','Opening lookup #1'); # 4.
is(ECO1(\@moves2),'E44','ECO lookup #2'); # 5.
is(NIC1(\@moves2),'NI 13','NIC lookup #2'); # 6.
is(Opening1(\@moves2),'Nimzo-Indian: Fischer variation, 5.Ne2','Opening lookup #2'); # 7.

is(ECO2(\@moves1),'[ECO "C00"]','ECO lookup #3'); # 8.
is(NIC2(\@moves1),'[NIC "FR 1"]','NIC lookup #3'); # 9.
is(Opening2(\@moves1),'[Opening "French: Labourdonnais variation"]','Opening lookup #3'); # 10.
is(ECO2(\@moves2),'[ECO "E44"]','ECO lookup #4'); # 11.
is(NIC2(\@moves2),'[NIC "NI 13"]','NIC lookup #4'); # 12.
is(Opening2(\@moves2),'[Opening "Nimzo-Indian: Fischer variation, 5.Ne2"]','Opening lookup #4'); # 13.

sub ECO1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[0];
}

sub NIC1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[1];
}

sub Opening1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[2];
}

sub ECO2 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 1);
    return $taxonomy[0];
}

sub NIC2 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 1);
    return $taxonomy[1];
}

sub Opening2 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 1);
    return $taxonomy[2];
}

t/10_ludens.t  view on Meta::CPAN

#!/usr/bin/perl
# 10_ludens.t -- ludens reported bug(s)
use Test::More tests => 7;
use Chess::PGN::EPD qw( epdlist epdTaxonomy );

ok(1); # 1. If we made it this far, we're ok.

my @moves1 = qw(
d4 g6 Bf4 Bg7 Nf3 d6 Nc3 Nf6 e3 O-O Qd3 Nbd7 h4 c5 
dxc5 Nxc5 Qe2 b6 O-O-O Ba6 Qe1 Bxf1 Qxf1 Nce4 
Nxe4 Nxe4 g4 Rc8 Qd3 Nc5 Qe2 b5 h5 Qa5 a3 Qa4 
c3 Nb3+ Kb1 b4 cxb4 a5 bxa5 Nxa5 hxg6 fxg6 Bh6 Bxb2 
Bxf8 Qxa3 Qxb2 Qa4 Qa2+ Qc4 Qxc4+ Rxc4 Bxe7 Nc6 
Bxd6 Ra4 Rd2 Rxg4 Ne5 Ra4 Nxc6 Ra6 Rc2 Rb6+ Kc1 Kf7 
Rxh7+ Ke6 Bf4 Kd5 Ne7+ Ke4 Rg7 Kf3 Rxg6 Ra6 Rxa6 Kg2 
Kd1 Kf1 Rca2 Kg2 Bh6 Kf3 Re6 Kg4 Nc6 Kf5 Rd6 Kg4 
Rdd2 Kf3 Bf8 Kg2 Re2 Kf3 e4 Kf4 e5 Kf3 e6 Kg2 
Ba3 Kf1 e7 Kg2 Re1 Kf3 e8=R Kf4 Rf8+ Kg5 f3 Kg6 
f4 Kg7 f5 Kh7 Ra8 Kg7 Rf1 Kf6 Nd4 Kf7 f6 Kg6 
f7 Kg5 f8=R Kg4 Rf8f2 Kg3 Rae2 Kg4 Rae8 Kg3 R8e3+ Kg4 
Ree1 Kg5 Bb2 Kg4 Bc3 Kg5 Re1e2 Kg4 Be1 Kg5 Nc2 Kg4 
Kd2 Kg5 Kd3 Kg4 Kd4 Kg5 Kc4 Kg4 Kd5 Kg5 Bd2 Kg4 
Ne1 Kg5 Rd3+ Kg4 Bc1 Kh5 Rd1 Kg6 Bd2 Kg7 Re3 Kg6 
Rfe2 Kg7 Rff3 Kg6 Rff2 Kg7 Rf1 Kg6 Rff2 Kg7 Rf4 Kg6 
Rd4 Kg7 Rdd3 Kg6 Rc3 Kg7 Rc2 Kg6 Rcc1 Kg7 Rcc3 Kg6 
Rc2 Kg7 Rcc1 Kg6 Rc4 Kg7 Rb4 Kg6 Rbb3
);

my @moves2 = (
);

is(ECO1(\@moves1),'A40','ECO lookup #1'); # 2.
is(NIC1(\@moves1),'VO 23','NIC lookup #1'); # 3.
is(Opening1(\@moves1),'Modern defense','Opening lookup #1'); # 4.
is(ECO1(\@moves2),'Unknown','ECO lookup #2'); # 5.
is(NIC1(\@moves2),'Unknown','NIC lookup #2'); # 6.
is(Opening1(\@moves2),'Unknown','Opening lookup #2'); # 7.

sub ECO1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[0];
}

sub NIC1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[1];
}

sub Opening1 {
    my $movesref = shift;
    my @taxonomy = epdTaxonomy(moves => $movesref,all => 1,astags => 0);
    return $taxonomy[2];
}

t/11_ludens-2.t  view on Meta::CPAN

#!/usr/bin/perl
# 11_ludens-2.t -- ludens reported bug
use Test::More tests => 2;
use Chess::PGN::EPD qw( epdlist );

ok(1); # 1. If we made it this far, we're ok.

my $answer = 'r1b1kbnr/pp1ppppp/2N5/8/4P3/4B3/P1P2PPP/qN1QKB1R w Kkq -';
my @moves = qw(
e4 c5 Nf3 Nc6 d4 cxd4 Nxd4 Qb6 Be3 Qxb2 Nxc6 Qxa1
);

is(EPD(@moves),$answer,'EPD result'); # 2.

sub EPD {
    my @EPD = epdlist(@_);
    return $EPD[-1];
}

t/author-critic.t  view on Meta::CPAN

#!perl

BEGIN {
  unless ($ENV{AUTHOR_TESTING}) {
    print qq{1..0 # SKIP these tests are for testing by the author\n};
    exit
  }
}


use strict;
use warnings;

use Test::More;
use English qw(-no_match_vars);

eval "use Test::Perl::Critic";
plan skip_all => 'Test::Perl::Critic required to criticise code' if $@;
Test::Perl::Critic->import( -profile => "perlcritic.rc" ) if -e "perlcritic.rc";
all_critic_ok();



( run in 1.242 second using v1.01-cache-2.11-cpan-a1d94b6210f )