Compare commits

..
8 Commits
21 changed files with 3449 additions and 1 deletions

No files matched your search

-1
View File
@@ -10,4 +10,3 @@ server.log
# 抓包/调试产物 # 抓包/调试产物
frames.log frames.log
main.js main.js
Pikafish-2026-09-06/
+24
View File
@@ -0,0 +1,24 @@
# Founders of the Pikafish project
PikaCat++ (PikaCat-OuO)
New Horizons (skystarspython)
d:blue (dhbloo)
Vincentzyx
# All other authors of Pikafish (in alphabetical order)
afkbad (xiangqishare) -> Xiangqi Rule Consultant
Celine chen,水殿風來 -> Logo Design
Harshycn
杰哥教你登dua郎 (RMCQAZ)
妙神 (iaoedsz2008)
macteki
mualanhlung017
ousc (SunDaiyue)
the Fairy-Stockfish developers (https://github.com/fairy-stockfish/Fairy-Stockfish/blob/master/AUTHORS)
the Stockfish developers (https://github.com/official-stockfish/Stockfish/blob/master/AUTHORS)
小张 (shuangqiao999)
以往 (subarashikihibi)
陶然 (pickaxe919)
Velithia
wxc
Xusheng (jeffli678)
张大仙 (fengxs001)
+86
View File
@@ -0,0 +1,86 @@
# Contributing to Pikafish
Welcome to the Pikafish project! We are excited that you are interested in
contributing. This document outlines the guidelines and steps to follow when
making contributions to Pikafish.
## Table of Contents
- [Building Pikafish](#building-pikafish)
- [Making Contributions](#making-contributions)
- [Reporting Issues](#reporting-issues)
- [Submitting Pull Requests](#submitting-pull-requests)
- [Code Style](#code-style)
- [Community and Communication](#community-and-communication)
- [License](#license)
## Building Pikafish
In case you do not have a C++ compiler installed, you can follow the
instructions from our wiki.
- [Linux][linux-compiling-link]
- [Windows][windows-compiling-link]
- [macOS][macos-compiling-link]
## Making Contributions
### Reporting Issues
If you find a bug, please open an issue on the
[issue tracker][issue-tracker-link]. Be sure to include relevant information
like your operating system, build environment, and a detailed description of the
problem.
_Please note that Pikafish's development is not focused on adding new features.
Thus any issue regarding missing features will potentially be closed without
further discussion._
### Submitting Pull Requests
- Functional changes need to be tested on fishtest. See
[Creating my First Test][creating-my-first-test] for more details.
The accompanying pull request should include a link to the test results and
the new bench.
- Non-functional changes (e.g. refactoring, code style, documentation) do not
need to be tested on fishtest, unless they might impact performance.
- Provide a clear and concise description of the changes in the pull request
description.
_First time contributors should add their name to [AUTHORS](./AUTHORS)._
_Pikafish's development is not focused on adding new features. Thus any pull
request introducing new features will potentially be closed without further
discussion._
## Code Style
Changes to Pikafish C++ code should respect our coding style defined by
[.clang-format](.clang-format). You can format your changes by running
`make format`. This requires clang-format version 20 to be installed on your system.
## Community and Communication
- Join the [Pikafish discord][discord-link] to discuss ideas, issues, and
development.
- Participate in the [Pikafish GitHub discussions][discussions-link] for
broader conversations.
## License
By contributing to Pikafish, you agree that your contributions will be licensed
under the GNU General Public License v3.0. See [Copying.txt][copying-link] for
more details.
Thank you for contributing to Pikafish and helping us make it even better!
[copying-link]: https://github.com/official-pikafish/Pikafish/blob/master/Copying.txt
[discord-link]: https://discord.com/invite/uSb3RXb7cY
[discussions-link]: https://github.com/official-pikafish/Pikafish/discussions/new
[creating-my-first-test]: https://github.com/glinscott/fishtest/wiki/Creating-my-first-test#create-your-test
[issue-tracker-link]: https://github.com/official-pikafish/Pikafish/issues
[linux-compiling-link]: https://github.com/official-pikafish/Pikafish/wiki/Compiling-from-source#linux
[windows-compiling-link]: https://github.com/official-pikafish/Pikafish/wiki/Compiling-from-source#windows
[macos-compiling-link]: https://github.com/official-pikafish/Pikafish/wiki/Compiling-from-source#macos
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), 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 prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey 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;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU 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 that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
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.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
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.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
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 the public, 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
state 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) <year> <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 3 of the License, 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, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program 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, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+11
View File
@@ -0,0 +1,11 @@
### NNUE-License
Any usage of the Pikafish weights constitutes agreement to this License.
The weights file (pikafish.nnue) released with the Pikafish and the weights file further derived from them are:
1. Only for legal use, any consequences caused by any use beyond the legal scope (e.g. online cheating) shall be borne by the user.
2. No commercial use without permission.
The use of nnue weights for commercial purposes by [these individuals and organizations](https://pikafish.org/list.html) is permitted.
However, the weights we train for the xiangqi variant of the [Fairy-Stockfish](https://github.com/fairy-stockfish/Fairy-Stockfish) are licensed under [CC0 license](https://github.com/official-stockfish/networks/blob/master/LICENSE). Even though they are derived from the Pikafish training data and follow the same training procedure, they are not constrained by this license.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+168
View File
@@ -0,0 +1,168 @@
<div align="center">
[![Pikafish][pikafish-logo]][website-link]
<h3>Pikafish</h3>
A free and strong UCI xiangqi engine.
<br>
<strong>[Explore Pikafish docs »][wiki-link]</strong>
<br>
<br>
[Report bug][issue-link]
·
[Open a discussion][discussions-link]
·
[Discord][discord-link]
·
[Blog][website-blog-link]
[![Build][build-badge]][build-link]
[![License][license-badge]][license-link]
[![RuleBook][rulebook-badge]][rulebook-link]
<br>
[![Release][release-badge]][release-link]
[![Commits][commits-badge]][commits-link]
<br>
[![Website][website-badge]][website-link]
[![Fishtest][fishtest-badge]][fishtest-link]
[![Discord][discord-badge]][discord-link]
</div>
## Overview
[Pikafish][website-link] is a **free and strong UCI xiangqi engine** derived from
[Stockfish][stockfish-link] that analyzes xiangqi positions and computes the optimal moves.
Pikafish **does not include a graphical user interface** (GUI) that is required
to display a chessboard and to make it easy to input moves. These GUIs are
developed independently from Pikafish and are available online. **Read the
documentation for your GUI** of choice for information about how to use
Pikafish with it.
See also the Pikafish [documentation][wiki-usage-link] for further usage help.
## Files
This distribution of Pikafish consists of the following files:
* [README.md][readme-link], the file you are currently reading.
* [Copying.txt][license-link], a text file containing the GNU General Public
License version 3.
* [AUTHORS][authors-link], a text file with the list of authors for the official Pikafish project.
* [src][src-link], a subdirectory containing the full source code, including a
Makefile that can be used to compile Pikafish on Unix-like systems.
* a file with the .nnue extension, storing the neural network for the NNUE
evaluation.
## Contributing
__See [Contributing Guide](./CONTRIBUTING.md).__
### Donating hardware
Improving Pikafish requires a massive amount of testing. You can donate your
hardware resources by installing the [Fishtest Worker][worker-link] and viewing
the current tests on [Fishtest][fishtest-link].
### Improving the code
In the [chessprogramming wiki][programming-link], many techniques used in
Pikafish are explained with a lot of background information.
The [section on Stockfish][programmingsf-link] describes many features
and techniques used by Stockfish. However, it is generic rather than
focused on Stockfish's precise implementation.
The engine testing is done on [Fishtest][fishtest-link].
If you want to help improve Pikafish, please read this [guideline][guideline-link]
first, where the basics of Pikafish development are explained.
Discussions about Pikafish take place these days mainly in the Pikafish
[Discord server][discord-link]. This is also the best place to ask questions
about the codebase and how to improve it.
## Compiling Pikafish
Pikafish has support for 32 or 64-bit CPUs, certain hardware instructions,
big-endian machines such as Power PC, and other platforms.
On Unix-like systems, it should be easy to compile Pikafish directly from the
source code with the included Makefile in the folder `src`. In general, it is
recommended to run `make help` to see a list of make targets with corresponding
descriptions.
```
cd src
make -j profile-build
```
Detailed compilation instructions for all platforms can be found in our
[documentation][wiki-compile-link]. Our wiki also has information about
the [UCI commands][wiki-uci-link] supported by Pikafish.
## Terms of use
### GNU General Public License version 3
Pikafish is free and distributed under the
[**GNU General Public License version 3**][license-link] (GPL v3). Essentially,
this means you are free to do almost exactly what you want with the program,
including distributing it among your friends, making it available for download
from your website, selling it (either by itself or as part of some bigger
software package), or using it as the starting point for a software project of
your own.
The only real limitation is that whenever you distribute Pikafish in some way,
you MUST always include the license and the full source code (or a pointer to
where the source code can be found) to generate the exact binary you are
distributing. If you make any changes to the source code, these changes must
also be made available under GPL v3.
## Acknowledgements
Pikafish uses neural networks trained on [data provided by the Pika Xiangqi Zero
project][px0-data-link], which is made available under the [Open Database License][odbl-link] (ODbL).
[authors-link]: https://github.com/official-pikafish/Pikafish/blob/master/AUTHORS
[build-badge]: https://img.shields.io/github/actions/workflow/status/official-pikafish/Pikafish/pikafish.yml?branch=master&style=for-the-badge&label=pikafish&logo=github
[build-link]: https://github.com/official-pikafish/Pikafish/actions/workflows/pikafish.yml
[commits-badge]: https://img.shields.io/github/commits-since/official-pikafish/Pikafish/latest?style=for-the-badge
[commits-link]: https://github.com/official-pikafish/Pikafish/commits/master
[discord-badge]: https://img.shields.io/discord/1013130558089478144?style=for-the-badge&label=discord&logo=Discord
[discord-link]: https://discord.com/invite/uSb3RXb7cY
[discussions-link]: https://github.com/official-pikafish/Pikafish/discussions/new
[fishtest-badge]: https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=Fishtest&up_color=success&up_message=Online&url=https://test.pikafish.org
[fishtest-link]: https://test.pikafish.org
[guideline-link]: https://github.com/glinscott/fishtest/wiki/Creating-my-first-test
[issue-link]: https://github.com/official-pikafish/Pikafish/issues/new?assignees=&labels=&template=BUG-REPORT.yml
[license-badge]: https://img.shields.io/github/license/official-pikafish/Pikafish?style=for-the-badge&label=license&color=success
[license-link]: https://github.com/official-pikafish/Pikafish/blob/master/Copying.txt
[pikafish-logo]: https://pikafish.org/assets/logo_256.png
[programming-link]: https://www.chessprogramming.org/Main_Page
[programmingsf-link]: https://www.chessprogramming.org/Stockfish
[qqgroup-link]: https://jq.qq.com/?_wv=1027&k=FORWUh4W
[readme-link]: https://github.com/official-pikafish/Pikafish/blob/master/README.md
[release-badge]: https://img.shields.io/github/v/release/official-pikafish/Pikafish?style=for-the-badge&label=official%20release
[release-link]: https://github.com/official-pikafish/Pikafish/releases/latest
[rulebook-badge]: https://img.shields.io/badge/computer%20rule-20B2AA?style=for-the-badge&logo=mdbook
[rulebook-link]: https://pikafish.org/rule.html
[src-link]: https://github.com/official-pikafish/Pikafish/tree/master/src
[stockfish-link]: https://github.com/official-stockfish/Stockfish
[uci-link]: https://backscattering.de/chess/uci/
[website-badge]: https://img.shields.io/website?style=for-the-badge&down_color=red&down_message=Offline&label=website&up_color=success&up_message=Online&url=https://pikafish.org
[website-link]: https://pikafish.org
[website-blog-link]: https://pikafish.org/
[wiki-link]: https://github.com/official-pikafish/Pikafish/wiki
[wiki-compile-link]: https://github.com/official-pikafish/Pikafish/wiki/Compiling-from-source
[wiki-uci-link]: https://github.com/official-pikafish/Pikafish/wiki/UCI-&-Commands
[wiki-usage-link]: https://github.com/official-pikafish/Pikafish/wiki/Download-and-usage
[worker-link]: https://github.com/xyztnecniV/yolo
[px0-data-link]: https://www.kaggle.com/datasets/pikacat/px0data
[odbl-link]: https://opendatacommons.org/licenses/odbl/odbl-10.txt
@@ -0,0 +1,183 @@
1. Contributors for training data generation with >10,000,000 positions generated, as of 2023-02-16.
Thank you!
Positions Username
-----------------------------------------------
452524769438 kaka
344221381035 千百
273861027419 戒烟戒酒
192541202211 meamas-teamo
137760509027 浮生若梦
104120272676 xiaoyan
83650612424 影子
80934057399 长安
60702209001 Duck-King
56920483079 huorongrong
54841370630 ifater
42325903141 VinXiangQi
37475865590 句号
37145000000 初见
20579354634 黑夜白天
19863119595 开摆小能手
19193335104 以往
18136147902 封大雨
16999907321 党晓阳
16115418102 lenovo2022
12429846638 jiangxiaoyu
11357670472 laweye
11043809172 ǧ
10674400782 Wang
10385894838 滚石
7721078599 天天象棋8848手机
7400273314 a寒月
5572130911 LDZBG
4510988876 gykchessA
4366000000 flyforever
4326449785 XiaoZhang
3467370327 WuMing
3178137384 看看你的飞刀
3126138553 广东陈教练
3062316420 人生如弈
3040583048 linglei
2774808804 huaze
2278946010 taoran
2019551632 烟云
1860711259 rainbowm
1720387893 绵羊姐
1473888640 咸鱼加油
1395000000 扫地神僧
1305000000 张大仙
1228000000 麦片
1195185718 棋软大王屠龙库
1102035798 NewHorizons
1077048480 从心之怂
906574409 xiezhiyi
873000000 跑谱2亿领屠龙商业库
800000000 辽宁沈阳
799353308 qoo_charly_cai
797988151 约德尔大王
782498240 sodeep
728000000 Coach_Chen
725000000 loseyourself
696000000 T
611000000 屠龙库无敌
564072890 风满楼
532000000 qianyan
513000000 yangliucq
509999999 随风
477766768 abcde
454000000 棋软大王谷歌
445416436 达瓦里希
424000000 atay2022
421000000 棋软大王谷歌家里挂
420000000 喜气洋洋
353000000 蝴蝶飞
342178600 MEIBING
342000000 白羽
301060240 王文辉
295934542 笨笨
282270530 ldzbg
258000000 十二
258000000 颞颥孔
250856964 QQ348984539
243000000 huluobo321
241283790 。1
241000000 jinbozhang
214000000 小迷
207689256 xjYY
171000000 净念相继
169327100 J
161000000 666666
159000000 Vinchess
153000000 123
152494942 fisherfan
150000000 Small8
141000000 mshzy
128548160 北极以北
127993836
126000000 asgh
126000000 zhizi-test
122304415 DanTaLian
118000000 sigmoid
110000000 。
110000000 kai小能手
107055360 华弈开局库
99558300 ellie
92561800 Arkhalis
89548900 阳光
84702200 yi
84289275 萨克丽芙
70772472 375398705
67377924 花天
63343859 Smawe
63224700 ya
63174000 SmartAss
62447080 ghh_蓝天
56793022 Gdhy
55572948 ouyangjian
55339092 buyunok
51909700 snow
50005465 金玉满堂
47912800 ZDX
46944831 无敌暴龙战士
45693580 若愚
41140829 菩提无数
39421396 EverGreen
36678744 Ӱ
36283120 高士
36070887 福州第一深情
35332232 始于海
34750846 HeAng
34620723 饭盒
29989540 夏天
29966960 iezhiyi
27734520 星月
27521280 求短信轰炸求干
26667000 浠ュ線
26568800 无限
26371552 云涌昱宇
25153966 老厨尸
24786080 童年
23817502 zengsky
23667900 小何
22810700 youdaddy
22693200 奋斗的男人
22200380 少帅
20073308 LinkStart
20027755 悖
20010300 huluobo123
18931980 这不是说笑
18788600 佛爷
17750200 dblue
15589780 AyachiNene
15548400 小雨
15062800 KAIbai
13295040 Yuan
13062786 水木清华
12534315 修心养性
12078180 跑谱1亿领屠龙库
12032080 人生赢家
11415160 a寒月の手机
11118200 bouncybear
10588500 娴嬭瘯
2. Contributors to Fishtest with >10,000 CPU hours, as of 2023-07-31.
Thank you!
CPU Hours Username
-----------------------------------------------
5029923 浮生若梦
1719666 VinXiangQi
624430 fsluobing
399621 kaka
396855 戒烟戒酒
276494 长安
96701 bacl
89853 huorongrong
59943 dblue
39465 qianbai
3. Stockfish Fishtest Contributors (https://github.com/official-stockfish/Stockfish/blob/master/Top CPU Contributors.txt)
Thank you!
+158
View File
@@ -0,0 +1,158 @@
# A note on NNUE evaluation
This approaches assign a value to a position that is used in alpha-beta (PVS) search to find the best move. The NNUE evaluation computes this value with a neural network based on basic inputs (e.g. piece positions only). The network is optimized and trained on the evaluations of millions of positions at moderate search depth.
The NNUE evaluation was first introduced in shogi, and ported to Stockfish afterward. It can be evaluated efficiently on CPUs, and exploits the fact that only parts of the neural network need to be updated after a typical chess move. [The nodchip repository](https://github.com/nodchip/Stockfish) provided the first version of the needed tools to train and develop the NNUE networks. Today, more advanced training tools are available in [the nnue-pytorch repository](https://github.com/official-pikafish/pikafish-nnue-pytorch), while data generation tools are available in [a dedicated branch](https://github.com/official-pikafish/Pikafish/tree/tools).
On CPUs supporting modern vector instructions (avx2 and similar), the NNUE evaluation results in much stronger playing strength, even if the nodes per second computed by the engine is somewhat lower (roughly 50% of nps is typical).
Notes:
1. the NNUE evaluation depends on the Pikafish binary and the network parameter file (see the EvalFile UCI option). Not every parameter file is compatible with a given Pikafish binary, but the default value of the EvalFile UCI option is the name of a network that is guaranteed to be compatible with that binary.
2. to use the NNUE evaluation, the additional data file with neural network parameters needs to be available. The filename for the default (recommended) net can be found as the default value of the `EvalFile` UCI option, with the format `pikafish.nnue`. This file can be downloaded from `http://test.pikafish.org`.
---
## Large Pages
Pikafish supports large pages on Linux and Windows. Large pages make the hash access more efficient, improving the engine speed, especially on large hash sizes.
The support is automatic, Pikafish attempts to use large pages when available and will fall back to regular memory allocation when this is not the case.
Typical increases are 5-10% in terms of nodes per second, but speed increases up to 30% have been measured.
### Linux
Large page support on Linux is obtained by the Linux kernel transparent huge pages functionality. Typically, transparent huge pages are already enabled, and no configuration is needed.
### Windows
The use of large pages requires "Lock Pages in Memory" privilege. See [Enable the Lock Pages in Memory Option (Windows)](https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/enable-the-lock-pages-in-memory-option-windows) on how to enable this privilege, then run [RAMMap](https://docs.microsoft.com/en-us/sysinternals/downloads/rammap) to double-check that large pages are used.
We suggest that you reboot your computer after you have enabled large pages, because long Windows sessions suffer from memory fragmentation, which may prevent Pikafish from getting large pages: a fresh session is better in this regard.
---
## Measure the speed of Pikafish
The "speed of Pikafish" is the number of nodes (positions) Pikafish can search per second.
Nodes per second (nps) is a useful benchmark number as the same version of Pikafish playing will play stronger with larger nps.
Different versions of Pikafish will play at different nps, for example, if the NNUE network architecture changes, but in this case the nps difference is not related to the strength difference.
Notes:
* Stop all other applications when measuring the speedup of Pikafish
* Run at least 20 default benches (depth 13) for each build of Pikafish to have accurate measures
* A speedup of 0.3% could be meaningless (i.e. within the measurement noise)
To measure the speed of several builds of Pikafish, use one of these applications:
* All OS:
* [pyshbench](https://github.com/hazzl/pyshbench): Latest release [pyshbench](https://github.com/hazzl/pyshbench/archive/master.zip)
* bash script `bench_parallel.sh` (run `bash bench_parallel.sh` for the help)
it might be that you have to install gawk as well on your system to not get syntax errors.
<details><summary>Click to view</summary>
```bash
#!/bin/bash
_bench () {
${1} << EOF > /dev/null 2>> ${2}
bench 16 1 ${depth} default depth
EOF
}
# _bench function customization example
# setoption name SyzygyPath value C:\table_bases\wdl345;C:\table_bases\dtz345
# bench 128 4 ${depth} default depth
if [[ ${#} -ne 4 ]]; then
cat << EOF
usage: ${0} ./pikafish_base ./pikafish_test depth n_runs
fast bench:
${0} ./pikafish_base ./pikafish_test 13 10
slow bench:
${0} ./pikafish_base ./pikafish_test 20 10
EOF
exit 1
fi
pf_base=${1}
pf_test=${2}
depth=${3}
n_runs=${4}
# preload of CPU/cache/memory
printf "preload CPU"
(_bench ${pf_base} pf_base0.txt)&
(_bench ${pf_test} pf_test0.txt)&
wait
# temporary files initialization
: > pf_base0.txt
: > pf_test0.txt
: > pf_temp0.txt
# bench loop: SMP bench with background subshells
for ((k=1; k<=${n_runs}; k++)); do
printf "\rrun %3d /%3d" ${k} ${n_runs}
# swap the execution order to avoid bias
if [ $((k%2)) -eq 0 ]; then
(_bench ${sf_base} pf_base0.txt)&
(_bench ${sf_test} pf_test0.txt)&
wait
else
(_bench ${sf_test} pf_test0.txt)&
(_bench ${sf_base} pf_base0.txt)&
wait
fi
done
# text processing to extract nps values
cat pf_base0.txt | grep second | grep -Eo '[0-9]{1,}' > pf_base1.txt
cat pf_test0.txt | grep second | grep -Eo '[0-9]{1,}' > pf_test1.txt
for ((k=1; k<=${n_runs}; k++)); do
echo ${k} >> pf_temp0.txt
done
printf "\rrun pf_base pf_test diff\n"
paste pf_temp0.txt pf_base1.txt pf_test1.txt | awk '{printf "%3d %8d %8d %8+d\n", $1, $2, $3, $3-$2}'
#paste pf_temp0.txt pf_base1.txt pf_test1.txt | awk '{printf "%3d\t%8d\t%8d\t%7+d\n", $1, $2, $3, $3-$2}'
paste pf_base1.txt pf_test1.txt | awk '{printf "%d\t%d\t%d\n", $1, $2, $2-$1}' > pf_temp0.txt
# compute: sample mean, 1.96 * std of sample mean (95% of samples), speedup
# std of sample mean = sqrt(NR/(NR-1)) * (std population) / sqrt(NR)
cat pf_temp0.txt | awk '{sum1 += $1 ; sumq1 += $1**2 ;sum2 += $2 ; sumq2 += $2**2 ;sum3 += $3 ; sumq3 += $3**2 } END {printf "\nsf_base = %8d +/- %6d (95%)\nsf_test = %8d +/- %6d (95%)\ndiff = %8d +/- %6d (95%)\nspeedup = %.5f% +/- %.3f% (95%)\n\n", sum1/NR , 1.96 * sqrt(sumq1/NR - (sum1/NR)**2)/sqrt(NR-1) , sum2/NR , 1.96 * sqrt(sumq2/NR - (sum2/NR)**2)/sqrt(NR-1) , sum3/NR , 1.96 * sqrt(sumq3/NR - (sum3/NR)**2)/sqrt(NR-1) , 100*(sum2 - sum1)/sum1 , 100 * (1.96 * sqrt(sumq3/NR - (sum3/NR)**2)/sqrt(NR-1)) / (sum1/NR) }'
# remove temporary files
rm -f pf_base0.txt pf_test0.txt pf_temp0.txt pf_base1.txt pf_test1.txt
```
</details>
<details><summary>Bench two git branches with bench_parallel</summary>
```bash
#!/bin/bash
if [ "$#" -ne 5 ]; then
echo "Usage: $0 branch1 branch2 depth runs compile_flags"
exit 1
fi
BRANCH1=$1
BRANCH2=$2
DEPTH=$3
RUNS=$4
COMPILE_FLAGS=$5
set -e
echo "Switching to $BRANCH1 and building..."
git switch $BRANCH1
make clean
make -j profile-build EXE=pikafish-$BRANCH1 $COMPILE_FLAGS
echo "Switching to $BRANCH2 and building..."
git switch $BRANCH2
make clean
make -j profile-build EXE=pikafish-$BRANCH2 $COMPILE_FLAGS
echo "Running bench_parallel.sh with pikafish-$BRANCH1 and pikafish-$BRANCH2..."
./bench_parallel.sh ./pikafish-$BRANCH1 ./pikafish-$BRANCH2 $DEPTH $RUNS
```
</details>
* Windows only:
* [FishBench](https://github.com/zardav/FishBench): Latest release [Fishbench v6.0](https://github.com/zardav/FishBench/releases/download/v6.0/FishBench.zip)
* [Buildtester](http://software.farseer.org/): Latest release [Buildtester 1.4.7.0](http://software.farseer.org/Software/BuildTester.7z)
@@ -0,0 +1,883 @@
## General
`make target [ARCH=arch] [COMP=compiler] [COMPCXX=cxx]`
### Targets
```
help > Display architecture details
profile-build > standard build with profile-guided optimization
build > skip profile-guided optimization
strip > Strip executable
install > Install executable
clean > Clean up
```
### Archs
```
native > select the best architecture for the host processor (default)
x86-64-vnni512 > x86 64-bit with vnni 512bit support
x86-64-vnni256 > x86 64-bit with vnni 512bit support, limit operands to 256bit wide
x86-64-avx512 > x86 64-bit with avx512 support
x86-64-avxvnni > x86 64-bit with vnni 256bit support
x86-64-bmi2 > x86 64-bit with bmi2 support
x86-64-avx2 > x86 64-bit with avx2 support
x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support
x86-64-modern > deprecated, currently x86-64-sse41-popcnt
x86-64-ssse3 > x86 64-bit with ssse3 support
x86-64-sse3-popcnt > x86 64-bit with sse3 and popcnt support
x86-64 > x86 64-bit generic (with sse2 support)
x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support
x86-32-sse2 > x86 32-bit with sse2 support
x86-32 > x86 32-bit generic (with mmx and sse support)
ppc-64 > PPC 64-bit
ppc-32 > PPC 32-bit
armv7 > ARMv7 32-bit
armv7-neon > ARMv7 32-bit with popcnt and neon
armv8 > ARMv8 64-bit with popcnt and neon
armv8-dotprod > ARMv8 64-bit with popcnt, neon and dot product support
e2k > Elbrus 2000
apple-silicon > Apple silicon ARM64
general-64 > unspecified 64-bit
general-32 > unspecified 32-bit
riscv64 > RISC-V 64-bit
```
### Compilers
```
gcc > GNU compiler (default)
mingw > GNU compiler with MinGW under Windows
clang > LLVM Clang compiler
icc > Intel compiler
ndk > Google NDK to cross-compile for Android
```
### Simple examples
If you don't know what to do, you likely want to run:
Fast compile for most common modern CPUs
```bash
make -j build
```
Slow compile for 64-bit systems
```bash
make -j build ARCH=x86-64
```
Slow compile for 32-bit systems
```bash
make -j build ARCH=x86-32
```
### Advanced examples
For experienced users looking for performance:
```bash
# Providing no ARCH so it will try to find the best ARCH for you
make -j profile-build
```
```bash
make -j profile-build ARCH=x86-64-bmi2
```
```bash
make -j profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-9.0
```
```bash
make -j build ARCH=x86-64-ssse3 COMP=clang
```
_See also: [How to lower compilation time](#lower-compilation-time) and [How to optimize for your CPU](#optimize-for-your-cpu)._
---
## Linux
On Unix-like systems, it should be easy to compile Pikafish directly from the source code with the included Makefile in the folder `src`.
In general it is recommended to run `make help` to see a list of make targets with corresponding descriptions.
```bash
cd src
make help
make -j profile-build ARCH=x86-64-avx2
```
---
## Windows
### About MSYS2 & MinGW-w64
MSYS2 is a software distribution and building platform for Windows. It provides a Unix-like environment, a command line interface, and a software repository, making it easy to install software on Windows or build software on Windows with either the GCC compiler or the Clang/LLVM compiler and using the Microsoft Visual C++ Runtime (mvscrt, shipped with all Windows versions) or the newer Microsoft Universal C Runtime (ucrt, shipped by default starting with Windows 10).
MSYS2 consists of several subsystems, `msys2`, `mingw32`, and `mingw64`:
* The `mingw32` and `mingw64` subsystems are native Windows applications that use either the mvscrt or the ucrt.
* The `msys2` subsystem provides an emulated mostly-POSIX-compliant environment based on Cygwin.
Each subsystem has an associated "terminal/shell", which is essentially a set of environment variables that allows the subsystems to co-operate properly:
* `MSYS2 MinGW x64`, to build Windows-native 64-bit applications with GCC compiler using mvscrt.
* `MSYS2 MinGW x86`, to build Windows-native 32-bit applications using GCC compiler using mvscrt.
* `MSYS2 MSYS`, to build POSIX applications using the Cygwin compatibility layer.
* `MSYS2 MinGW UCRT x64`, to build Windows-native 64-bit applications with GCC compiler using ucrt.
* `MSYS2 MinGW Clang x64`, to build Windows-native 64-bit applications with Clang/LLVM compiler using ucrt.
Refer to the [MSYS2 homepage](https://www.msys2.org/) for more detailed information on the MSYS2 subsystems and terminals/shells.
### Installing MSYS2
### Install MSYS2 with Chocolatey
[Chocolatey](https://chocolatey.org/) is a command line package manager for Windows, always run Chocolatey commands in a powershell/cmd with administrator rights (right click on `Start` menu, select `Windows Powershell (Admin)` or `Command Prompt (Admin)`):
1. Open a powershell (admin) (not a cmd) and copy the official [Chocolatey install command](https://chocolatey.org/install) to install Chocolatey
2. In a powershell/cmd (admin) execute the command `choco install msys2 -y`
As alternative write this text file `install_choco_msys2.cmd`, right click and select `Run as administrator`:
<details><summary>Click to view</summary>
```cmd
@echo off
::https://chocolatey.org/install
::https://chocolatey.org/courses/installation/installing?method=installing-chocolatey?quiz=true
::download and run install.ps1
"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
::install msys2
choco install msys2 -y
```
</details>
### Install MSYS2 with the official installer
1. Download and start the [one-click installer for MSYS2](https://www.msys2.org/). It's suggested to choose `C:\tools\msys64` as installation folder to be compatible with fishtest framework. MSYS2 no longer support an installer for Windows 32-bit, the [latest provided](https://github.com/msys2/msys2-installer/releases/tag/2020-05-17) is not able to install packages.
2. The installer runs a `MSYS2 MSYS` shell as a last step. Update the core packages by typing and executing `pacman -Syuu`. When finished, close the `MSYS2 MSYS` shell.
With MSYS2 installed to `C:\tools\msys64` your home directory will be `C:\tools\msys64\home\<your_username>`. Note that within the MSYS2 shell, paths are written in Unix-like way:
* Windows path: `C:\tools\msys64`
* Unix-like path: `/c/tools/msys64`
* Windows path: `C:\tools\msys64\home`
* Unix-like path: `/home` or `/c/tools/msys64/home`
_Note: You can also use `ls` to list the files and folders in a directory, similar to how you would use `dir` in Windows._
### GCC
This works with all the Windows versions.
1. Using your favorite text editor, copy and paste the following bash script, calling it `makefish.sh`:
<details><summary>64-bit Windows</summary>
```bash
#!/bin/bash
# makefish.sh
# install packages if not already installed
pacman -S --noconfirm --needed unzip make mingw-w64-x86_64-gcc
branch='master'
github_user='official-pikafish'
# download the Pikafish source code
wget -O ${branch}.zip https://github.com/${github_user}/Pikafish/archive/refs/heads/${branch}.zip
unzip -o ${branch}.zip
cd Stockfish-${branch}/src
# check all given flags
check_flags () {
for flag; do
printf '%s\n' "$flags" | grep -q -w "$flag" || return 1
done
}
# find the CPU architecture
output=$(g++ -Q -march=native --help=target)
flags=$(printf '%s\n' "$output" | awk '/\[enabled\]/ {print substr($1, 3)}' | tr '\n' ' ')
arch=$(printf '%s\n' "$output" | awk '/march/ {print $NF; exit}' | tr -d '[:space:]')
if check_flags 'avx512vnni' 'avx512dq' 'avx512f' 'avx512bw' 'avx512vl'; then
arch_cpu='x86-64-vnni256'
elif check_flags 'avx512f' 'avx512bw'; then
arch_cpu='x86-64-avx512'
elif check_flags 'bmi2' && [ $arch != 'znver1' ] && [ $arch != 'znver2' ]; then
arch_cpu='x86-64-bmi2'
elif check_flags 'avx2'; then
arch_cpu='x86-64-avx2'
elif check_flags 'sse4.1' 'popcnt'; then
arch_cpu='x86-64-sse41-popcnt'
elif check_flags 'ssse3'; then
arch_cpu='x86-64-ssse3'
elif check_flags 'sse3' 'popcnt'; then
arch_cpu='x86-64-sse3-popcnt'
else
arch_cpu='x86-64'
fi
# build the fastest Pikafish executable
make -j profile-build ARCH=${arch_cpu} COMP=mingw
make strip
mv pikafish.exe ../../pikafish_${arch_cpu}.exe
make clean
cd
```
</details>
<details><summary>32-bit Windows</summary>
```bash
#!/bin/bash
# makefish.sh
# install packages if not already installed
pacman -S --noconfirm --needed unzip make mingw-w64-i686-gcc
branch='master'
github_user='official-pikafish'
# download the Pikafish source code
wget -O ${branch}.zip https://github.com/${github_user}/Pikafish/archive/refs/heads/${branch}.zip
unzip -o ${branch}.zip
cd Stockfish-${branch}/src
# find the CPU architecture
gcc_enabled=$(g++ -Q -march=native --help=target | grep "\[enabled\]")
gcc_arch=$(g++ -Q -march=native --help=target | grep "march")
if [[ "${gcc_enabled}" =~ "-mpopcnt " && "${gcc_enabled}" =~ "-msse4.1 " ]] ; then
arch_cpu="x86-32-sse41-popcnt"
elif [[ "${gcc_enabled}" =~ "--msse2 " ]] ; then
arch_cpu="x86-32-sse2"
else
arch_cpu="x86-32"
fi
# build the fastest Pikafish executable
make -j profile-build ARCH=${arch_cpu} COMP=mingw
make strip
mv pikafish.exe ../../pikafish_${arch_cpu}.exe
make clean
cd
```
</details>
2. Start a `MSYS2 MinGW x64` shell (not a `MSYS2 MSYS` one), `C:\tools\msys64\mingw64.exe`, or start a `MSYS2 MinGW x86` shell, `C:\tools\msys64\mingw32.exe`, to build a 32 bit application.
3. Navigate to wherever you saved the script (e.g. type and execute `cd '/d/Program Files/Pikafish'` to navigate to `D:\Program Files\Pikafish`).
4. Run the script by typing and executing `bash makefish.sh`.
### Clang/LLVM
With Windows version older than Windows 10 you could need to install the Microsoft Windows Universal C Runtime.
1. Using your favorite text editor, copy and paste the following bash script, calling it `makefish.sh`:
<details><summary>64-bit Windows</summary>
```bash
#!/bin/bash
# makefish.sh
# install packages if not already installed
pacman -S --noconfirm --needed unzip make mingw-w64-clang-x86_64-clang
branch='master'
github_user='official-pikafish'
# download the Pikafish source code
wget -O ${branch}.zip https://github.com/${github_user}/Pikafish/archive/refs/heads/${branch}.zip
unzip -o ${branch}.zip
cd Stockfish-${branch}/src
# check all given flags
check_flags () {
for flag; do
printf '%s\n' "$flags" | grep -q -w "$flag" || return 1
done
}
# find the CPU architecture
output=$(clang++ -E - -march=native -### 2>&1)
flags=$(printf '%s\n' "$output" | grep -o '"-target-feature" "[^"]*"' | cut -d '"' -f 4 | grep '^\+' | cut -c 2- | tr '\n' ' ')
arch=$(printf '%s\n' "$output" | grep -o '"-target-cpu" "[^"]*"' | cut -d '"' -f 4)
if check_flags 'avx512vnni' 'avx512dq' 'avx512f' 'avx512bw' 'avx512vl'; then
arch_cpu='x86-64-vnni256'
elif check_flags 'avx512f' 'avx512bw'; then
arch_cpu='x86-64-avx512'
elif check_flags 'bmi2' && [ $arch != 'znver1' ] && [ $arch != 'znver2' ]; then
arch_cpu='x86-64-bmi2'
elif check_flags 'avx2'; then
arch_cpu='x86-64-avx2'
elif check_flags 'sse4.1' 'popcnt'; then
arch_cpu='x86-64-sse41-popcnt'
elif check_flags 'ssse3'; then
arch_cpu='x86-64-ssse3'
elif check_flags 'sse3' 'popcnt'; then
arch_cpu='x86-64-sse3-popcnt'
else
arch_cpu='x86-64'
fi
# build the fastest Pikafish executable
make -j profile-build ARCH=${arch_cpu} COMP=clang
make strip COMP=clang
mv pikafish.exe ../../pikafish_${arch_cpu}.exe
make clean COMP=clang
cd
```
</details>
2. Start a `MSYS2 MinGW Clang x64` shell, `C:\tools\msys64\clang64.exe`.
3. Navigate to wherever you saved the script (e.g. type and execute `cd '/d/Program Files/Pikafish'` to navigate to `D:\Program Files\Pikafish`).
4. Run the script by typing and executing `bash makefish.sh`.
### Microsoft Visual Studio
_Note: Building Pikafish with Visual Studio is **not officially supported**._
It is required to explicitly set the stack reserve to avoid crashes. See point 5. below.
If you want to use MSVC to get a "optimized" build, you can change these settings in the IDE:
1. Add "NDEBUG;USE_POPCNT;USE_PEXT" to preprocessor definitions. Optionally, depending on your processor's support, add one of the following definitions: USE_AVX512 / USE_AVX2 / USE_SSSE3 / USE_SSE2 / USE_MMX. Also, if your processor supports VNNI instructions, add the USE_AVXVNNI definition. For a 64-bit target, if your CPU supports AVX or later extensions set one of the following: /arch:AVX or /arch:AVX2 or /arch:AVX512.
2. Optimization flags: /O2, /Oi, /Ot, /Oy, /GL
3. Static link with runtime: /MT.
4. Disable stack cookies: /GS-.
5. Set stack reserve to 8388608 in under Linker -> System or use the linker option /STACK:reserve=8388608.
6. Disable debugging information in compiler/linker.
7. (VS 2017 only): Make a PGO instrument build(set under General), it should depend on "pgort140.dll" and it probably won't start.
8. (VS 2017 only): Copy pgort140.dll from "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64" to the output folder.
9. Run bench with the instrument build(very slow) and quit, it should generate "Pikafish.pgd" and "Pikafish!1.pgc".
10. Make a PGO optimized build(set under General), should show something like:
```
1>0 of 0 ( 0.0%) original invalid call sites were matched.
1>0 new call sites were added.
1>54 of 4076 ( 1.32%) profiled functions will be compiled for speed, and the rest of the functions will be compiled for size
1>18615 of 46620 inline instances were from dead/cold paths
1>4076 of 4076 functions (100.0%) were optimized using profile data
1>14499840744 of 14499840744 instructions (100.0%) were optimized using profile data
```
11. Enjoy, local tests show comparable speed to GCC builds.
### Troubleshooting
If this tutorial will not work on your pc, you may try to change the `Windows Security` settings in via `Windows Security` >> `App & Browser Control` >> `Exploit Protection Settings`:
1. Try to turn off _"Force randomization for images (Mandatory ASLR)"_, if this not solve the problem then,
2. Try to turn off also _"Randomize memory allocations (Bottom-up ASLR)"_ .
### Using other MinGW-w64 with MSYS2
To use with MSYS2 a MinGW-w64 built by other projects, simply follow these instructions (Windows 64 bit):
1. Download another version of MinGW-w64, e.g. [MinGW-w64 (64-bit) GCC 8.1.0](https://www.msys2.org/), extract the *mingw64* folder renaming it to *mingw64-810*, copy the folder into *C:\msys64*, check to have the directory *C:\msys64\mingw64-810\bin*
2. Build Pikafish writing and executing this bash script
<details><summary>Click to view</summary>
```bash
#!/bin/bash
# makefish.sh
# set PATH to use GCC 8.1.0
if [ -d "/mingw64-810/bin" ] ; then
PATH="/mingw64-810/bin:${PATH}"
else
echo "folder error"
exit 1
fi
branch='master'
github_user='official-pikafish'
# download the Pikafish source code
wget -O ${branch}.zip https://github.com/${github_user}/Pikafish/archive/refs/heads/${branch}.zip
unzip -o ${branch}.zip
cd Stockfish-${branch}/src
# find the CPU architecture
# CPU without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge)
arch_cpu=x86-64
# CPU with bmi2 instruction (e.g. Intel Haswell or newer)
if [ "$(g++ -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then
# CPU AMD zen
if [ "$(g++ -Q -march=native --help=target | grep march | grep 'znver[12]')" ] ; then
arch_cpu=x86-64-avx2
else
arch_cpu=x86-64-bmi2
fi
# CPU with popcnt instruction (e.g. Intel Sandy Bridge)
elif [ "$(g++ -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then
arch_cpu=x86-64-sse41-popcnt
fi
# build the Pikafish executable
make profile-build ARCH=${arch_cpu} COMP=mingw
make strip
mv pikafish.exe ../../pikafish_${arch_cpu}.exe
make clean
cd
```
</details>
To use the compiler in the CLI write and run the script `use_gcc810.sh` in the user home folder
```bash
# set PATH to use GCC 8.1.0
# use this command: source use_gcc810.sh
if [ -d "/mingw64-810/bin" ] ; then
PATH="/mingw64-810/bin:${PATH}"
else
echo "folder error"
fi
```
---
## macOS
On macOS 10.14 or higher, it is possible to use the Clang compiler provided by Apple
to compile Pikafish out of the box, and this is the method used by default
in our Makefile (the Makefile sets the macosx-version-min=10.14 flag to select
the right libc++ library for the Clang compiler with recent c++17 support).
But it is quite possible to compile and run Pikafish on older versions of macOS! Below
we describe a method to install a recent GNU compiler on these Macs, to get
the c++17 support. We have tested the following procedure to install gcc10 on
machines running macOS 10.7, macOS 10.9 and macOS 10.13.
1) Install Xcode for your machine.
2) Install Apple command-line developer tools for Xcode, by typing the following
command in a Terminal:
```bash
sudo xcode-select --install
```
3) Go to the Pikafish "src" directory, then try a default build and run Pikafish:
```bash
make clean
make build
./pikafish
```
4) If step 3 worked, congrats! You have a compiler recent enough on your Mac
to compile Pikafish. If not, continue with step 5 to install GNU gcc10 :-)
5) Install the MacPorts package manager (https://www.macports.org/install.php),
for instance using the fast method in the "macOS Package (.pkg) Installer"
section of the page.
6) Use the "port" command to install the gcc10 package of MacPorts by typing the
following command:
```bash
sudo port install gcc10
```
With this step, MacPorts will install the gcc10 compiler under the name "g++-mp-10"
in the /opt/local/bin directory:
```
which g++-mp-10
/opt/local/bin/g++-mp-10 <--- answer
```
7) You can now go back to the "src" directory of Pikafish, and try to build
Pikafish by pointing at the right compiler:
```bash
make clean
make build COMP=gcc COMPCXX=/opt/local/bin/g++-mp-10
./pikafish
```
8) Enjoy Pikafish on macOS!
See [this pull request](https://github.com/official-pikafish/Pikafish/pull/3049) for further discussion.
---
## For Android
You can build Pikafish for your ARM CPU based mobile Android device,
using the Pikafish supplied Makefile.
Supported architectures are:
- **armv7**: 32 bit ARM CPUs without Neon extension
- **armv7-neon**: 32 bit ARM CPUs with Neon SIMD Instruction Set Extension
- **armv8**: 64 bit ARM CPUs, with Neon extension
As most modern Android smartphones and tablets nowadays use armv8 64 bit CPUs,
we will cover these in this example. Before you try to build Pikafish, make sure
that you know what kind of CPU architecture your device uses. You will have to specify
one of the three mentioned architectures later on in the MAKE command by giving the
`"ARCH=..."` variable on the command line.
Furthermore you should be aware of the fact that Pikafish is just the chess engine.
You cannot use it stand-alone, rather you need a host program, i.e. a Chess GUI that
displays the chess board, takes your moves etc. on the one hand, and on the other hand
"talks" to the Pikafish chess engine so that it analyses the chess position in a game
and calculates its moves or variations, and gives that back to the GUI for display.
The Chess GUI which is probably used most often on Android is Droidfish, so we will
cover this here. You can get it from the [F-Droid](https://f-droid.org/repository/browse/?fdid=org.petero.droidfish) alternative app store.
To build Pikafish, you need:
1. The Android Native Development Kit (NDK), which contains a C/C++ compiler toolchain
and all required headers and libraries to build native software for Android.
2. POSIX compatible build enviroment with GNU `coreutils`, `fileutils`and the `make`, `git`,
`expect` (if you want to run the testsuite) and either `wget` or `curl` utilities.
On Linux, install those tools using the package manager of your Linux distribution.
On Windows, you can use MSYS2. We will assume further down in this example that
you installed it to "C:\msys64". Adapt the instructions accordingly, if you installed
it elsewhere.
Please see [how to compile on Windows](#windows)
for more details about MSYS2, but _**please note**_ that you ONLY need to install the basic
MSYS environment and the package groups `base-devel`, `expect` and `git` with this command:
```bash
pacman -S --noconfirm --needed base-devel expect git wget curl
```
You do NOT need any of the MINGW64, MINGW32 nor the CLANG64 compiler toolchain for an Android build.
We will use the Android NDK compiler toolchain instead.
To get the Android NDK, you have two options:
a) If you already have Android Studio installed, use its built-in SDK manager to download
and install the NDK, as follows:
- On the "Welcome to Android Studio" start page of the IDE, click "Customize" on the left pane,
then click "All Settings..." on the bottom. This should open the "Android SDK" maintenance dialog.
- Click on the "SDK Tools" tab on top of the list window.
- Click and select the "NDK (Side by Side)" option and then click on "OK"
This will download and install the latest NDK version under the directory
of the "Android SDK Location" directory.
In this example, for the Windows environment we will assume that Android Studio is installed
in "C:\Android\Android Studio", and that the Android SDK is installed in "C:\Android\Sdk".
The NDK will then have been installed in "C:\Android\Sdk\ndk" by the above installation process.
b) If you do NOT have Android Studio installed, don't worry! You don't need it.
To download just the Android NDK, go to https://developer.android.com/ndk/downloads
and pick the latest version for your platform. In this example we will stick to either Windows
or Linux, but the Mac version should be not much different to use.
_Note: The latest LTS version is r23b (23.1.7779620). This will work fine. The minimum version you need is r21e (21.4.7075529), so if you already have that, you are all set._
If you downloaded it directly, unzip it to "C:\Android\Sdk\ndk\", or if you are on Linux, inside your home
directory to /home/(your user name)/Android/Sdk/ndk
When the installation is finished, locate the NDK compiler toolchain directory.
On Windows, this should be something like:
"C:\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64"
On Linux, the path might look like:
/home/johndoe/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64
On Linux, we are now almost ready to go. On Windows however, to simplify its use with MSYS2, we will
now create a symbolic link to that directory inside the MSYS2 installation directory.
To do that, open a CMD.EXE command prompt with Administrator privileges, and use the Windows command MKLINK as follows:
```cmd
mklink /D "C:\msys64\Android" "C:\Android\Sdk\ndk\23.1.7779620\toolchains\llvm\prebuilt\windows-x86_64"
```
Now the Android NDK compiler toolchain is available from inside an MSYS environment terminal session
in the same way as the MINGW64 toolchain would be, and we don't have to type such long path names anymore.
On Windows, you should now start the MSYS environment launcher. This will give you a terminal session
with the Bash (1) shell. The PATH environment variable DOES NOT include a compiler toolchain yet. Verify this by entering:
```bash
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/c/Windows/System32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
```
On Linux, you can just open a plain terminal session.
Now we prepend the NDK compiler toolchain bin/ subdirectory to our PATH:
On Windows:
```bash
$ export PATH=/Android/bin:$PATH
```
On Linux:
```bash
$ export PATH=/home/johndoe/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
```
_Note: These PATH settings are in effect only for your current session._
Now you should be able to call the compiler we will use from the command line.
Let's check which version we have, this example output is from Windows, the Linux output should be quite similar.
```bash
$ aarch64-linux-android21-clang++ --version
Android (7019983 based on r365631c3) clang version 9.0.9 (https://android.googlesource.com/toolchain/llvm-project a2a1e703c0edb03ba29944e529ccbf457742737b) (based on LLVM 9.0.9svn)
Target: aarch64-unknown-linux-android21
Thread model: posix
InstalledDir: C:\msys64\Android\bin
$
```
If you get an error message that the command "aarch64-linux-android21-clang++" could not be found, please go back
and check that you have got all the path names correct in the above steps.
Now we will checkout the Pikafish source code with git, and start the build. The steps for Windows in the MSYS environment
session and for Linux are now basically the same. In your home directory, make subdirectories for the git checkout:
```bash
$ mkdir -p ~/repos/official-pikafish
$ cd ~/repos/official-pikafish
$ git clone https://github.com/official-pikafish/Pikafish.git
.
.
.
$ cd Pikafish/src
```
Now lets start the build. First we can display a help page with all the supported make targets (and ignore them :-)
```bash
$ make help
```
Now we are ready to build. You now need to know your architecture (see the start of this documentation).
We will use armv8 as an example here. Issue the command:
```bash
$ make -j build ARCH=armv8 COMP=ndk
```
After a short amount of time (or a minute, or two, depending on the speed of your machine) the compilation and
linking should complete with messages like this:
```bash
.
.
aarch64-linux-android21-clang++ -o pikafish benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o search.o thread.o timeman.o tt.o uci.o ucioption.o tune.o tbprobe.o evaluate_nnue.o half_ka_v2_hm.o -static-libstdc++ -pie -lm -latomic -Wall -Wcast-qual -fno-exceptions -std=c++17 -stdlib=libc++ -fPIE -DUSE_PTHREADS -DNDEBUG -O3 -fexperimental-new-pass-manager -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -flto
make[1]: Leaving directory '/home/johndoe/repos/official-pikafish/Pikafish/src'
```
You will now have a binary file called `pikafish` in your current directory. Check with the file command that
it is indeed an ARM binary for Android:
```bash
$ file pikafish
pikafish: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, with debug_info, not stripped
```
To make it smaller and run faster, we should strip the symbol table from the executable; this is not needed for running it, only for debugging.
Issue the command:
```bash
$ make strip ARCH=armv8 COMP=ndk
aarch64-linux-android-strip pikafish
```
Issuing the file command again shows that it has been stripped:
```bash
$ file pikafish
pikafish: ELF 64-bit LSB shared object, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /system/bin/linker64, stripped
```
It is a good idea to rename the binary:
```bash
$ mv pikafish pikafish_DEV_armv8
```
So in Droidfish you will be able to see that you are running your self compiled DEVelopment version of Pikafish, and not the built-in
version, which is substantially older.
Voilà: you have your Android build of Pikafish. What is now left to do is to copy it over to your smartphone or tablet,
to the "uci" subdirectory of your Droidfish installation. You can find the Droidfish documentation here:
https://github.com/peterosterlund2/droidfish/tree/master/doc
To do this, the easiest possibility is to have your build machine and your Android device on the same network,
create a Windows network share, copy the Pikafish binary into that share directory, and then on your Android
device use the File Manager app to connect to that network share and copy the Pikafish binary over to the
Droidfish uci (engines) directory.
In Droidfish, open the left menu, find the Engines management submenu, pick the `pikafish_DEV_armv8` binary,
and in the configuration menu adjust its UCI parameter settings. Depending on the CPU power of your device
and the available memory, you should probably give it more than the default one Thread, and more than the default
16 MB of Hash memory. A good start would be to try 2 Threads, and 512 MB for the Hash tables, and see if you can beat it ;-)
_Note: As Pikafish is a very computation-intense program, you should probably not give it as many threads as
your device CPU has processor cores. Especially in Analysis mode, when Pikafish is thinking permanently, and for
extended amounts of time, this might suck your device battery empty quite quickly._
Enjoy!
---
## Cross compilation
### For Windows in Ubuntu
The script works with Ubuntu 18.04, Ubuntu 21.10 and Ubuntu 22.04, other versions could still have a packaging bug.
<details><summary>Click to view</summary>
```bash
#!/bin/bash
# functions to build Pikafish
_build_pf () {
make build ARCH=x86-64$1 COMP=mingw -j
make strip COMP=mingw
mv pikafish.exe ../../pikafish-x64${1}.exe
make clean COMP=mingw
}
_build_pf_pgo () {
make profile-build ARCH=x86-64$1 COMP=mingw PGOBENCH="wine ./pikafish.exe bench" -j
make strip COMP=mingw
mv pikafish.exe ../../pikafish-x64${1}-pgo.exe
make clean COMP=mingw
}
# full-upgrade and install required packages
sudo apt update && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean
sudo apt install -y \
make \
mingw-w64 \
git \
wine64 \
binutils
# clone Pikafish source code
git clone --single-branch --branch master https://github.com/official-pikafish/Pikafish.git
cd Pikafish/src
# build Pikafish executables
# to speedup the building process you can keep only the section fitting your CPU architecture
# build the binary for CPUs without popcnt and bmi2 instructions (e.g. older than Intel Sandy Bridge)
_build_pf_pgo
# build the binary for CPU with popcnt instruction (e.g. Intel Sandy Bridge)
if [ "$(x86_64-w64-mingw32-c++-posix -Q -march=native --help=target | grep mpopcnt | grep enabled)" ] ; then
_build_pf_pgo -sse41-popcnt
else
_build_pf -sse41-popcnt
fi
# build the binary for CPU with bmi2 instruction (e.g. Intel Haswell or newer)
if [ "$(x86_64-w64-mingw32-c++-posix -Q -march=native --help=target | grep mbmi2 | grep enabled)" ] ; then
_build_pf_pgo -bmi2
else
_build_pf -bmi2
fi
```
</details>
### For all platforms using Zig
[Zig](https://ziglang.org/) is a programming language in early development stage that is binary compatible with C.
The Zig toolchain, based on LLVM, ships the source code of all the required libraries to easily cross compile Zig/C/C++ code for several CPU Architecture and OS combinations. All the work required is to set as target the proper supported [triple \<arch-os-abi\>](https://github.com/ziglang/zig-bootstrap#supported-triples) (eg `x86_64-windows-gnu`, `aarch64-linux-musl`).
You can use Zig:
* installing Zig with a [package manager](https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager) for your OS, or
* unzipping the [Zig archive](https://ziglang.org/download/) (~50 Mbi) and setting the PATH for the shell with `export PATH=/home/username/zig:$PATH`
Note: `snap` does not work on WSL, download the archive.
Here is a script to cross compile from a clean Ubuntu a static build of Pikafish targeting an armv8 or armv7 CPU running on Linux or Android:
<details><summary>Click to view</summary>
```bash
# Use a clean Ubuntu to cross compile
# a static build for armv8 and armv7 on Linux/Android
# one time configuration
sudo apt update && sudo apt install -y make git
sudo snap install zig --classic --edge
sudo apt install -y qemu-user
# armv8 static build with musl libc
git clone https://github.com/official-pikafish/Pikafish.git
cd Pikafish/src
make -j build ARCH=armv8 COMP=gcc CXX="zig c++ -target aarch64-linux-musl"
# test: qemu's magic at work
qemu-aarch64 pikafish compiler
qemu-aarch64 pikafish bench
# armv7 static build with musl libc
# comment out "-latomic" flag in Makefile
make clean
make -j build ARCH=armv7 COMP=gcc CXX="zig c++ -target arm-linux-musleabihf"
# test: qemu's magic at work
qemu-arm pikafish compiler
qemu-arm pikafish bench
```
</details>
Here is a script to cross compile from a msys2 msys/mingw-w64 shell a static build of Pikafish targeting an armv8 or armv7 CPU running on Linux or Android:
<details><summary>Click to view</summary>
```bash
# Use msys2 to cross compile
# a static build for armv8 and armv7 on Linux/Android
# one time configuration
pacman -S --noconfirm --needed git make unzip
wget https://ziglang.org/builds/zig-windows-x86_64-0.10.0-dev.2220+802f22073.zip
unzip zig-windows-x86_64-0.10.0-dev.2220+802f22073.zip
PATH=$(pwd)/zig-windows-x86_64-0.10.0-dev.2220+802f22073:${PATH}
# armv8 static build with musl libc
git clone https://github.com/official-pikafish/Pikafish.git
cd Pikafish/src
make -j build ARCH=armv8 COMP=gcc CXX="zig c++ -target aarch64-linux-musl"
mv pikafish.exe pikafish_armv8
```
</details>
---
## Lower compilation time
It is possible to lower the compile time on cpu multi core using make with the flag *-j \<n_jobs\>*, where \<n_jobs\> is the number of jobs (commands) to run simultaneously. The flag *-j* enables one job for each logical CPU core.
```bash
make -j <n_jobs> profile-build ARCH=x86-64-avx2 COMP=mingw
```
---
## Optimize for your CPU
To get the max speedup for your CPU (1.5% on Ivy Bridge) simply prepend the shell variable `CXXFLAGS='-march=native'` to the `make` command. At example, for a CPU Sandy/Ivy Bridge use this command:
```bash
CXXFLAGS='-march=native' make -j profile-build ARCH=x86-64-avx2 COMP=gcc
```
To view the compiler flags for your CPU:
```
# for gcc
gcc -Q -march=native --help=target | grep -v "\[disabled\]"
# for clang
clang -E - -march=native -###
```
*-march=native* implies *-mtune=native*, below a high level explanation of the compiler flags *-march* and *-mtune*, view the [gcc manual](https://gcc.gnu.org/onlinedocs/gcc-5.3.0/gcc/x86-Options.html#x86-Options) for more technically sound details:
* *-march*: determines what instruction sets are used in the binary. An instruction set is the list of commands implemented by the cpu. **The generated code may not run at all on processors other than the one indicated.**
* *-mtune*: determines the cost model that is used when generating code. The cost model describes how long it takes the cpu to do operations. This information is used by the scheduler to decide what operations to use and in what order.
+218
View File
@@ -0,0 +1,218 @@
## Pikafish Development Setup
### Windows
<details>
<summary>Show more</summary>
#### Installing a compiler
1. https://www.msys2.org/
2. Download the installer
In the MSYS2 Installer change the installation folder to:
`C:\tools\msys64`
In the `URTC64` Shell run:
`pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain`
#### clang-format
Download [LLVM 17](https://github.com/llvm/llvm-project/releases/download/llvmorg-17.0.3/LLVM-17.0.3-win64.exe)
Run the executable and in the installer choose:
`Add LLVM to the system PATH for current user`
#### Video Setup
_There's a much higher quality version of this available on our [Discord](https://discord.com/channels/435943710472011776/1032922913499783169/1191837643256901732)._
https://github.com/official-stockfish/Stockfish/assets/45608332/d0323339-21f1-4d1d-aa86-183a7e10ed06
_More in depth information about various compilers can be found [here](https://github.com/official-pikafish/Pikafish/wiki/Compiling-from-source#windows)._
</details>
### Ubuntu
<details>
<summary>Show more</summary>
#### Installing a compiler
On Unix-like systems you will most likely have all the tools installed,
which are required to build Pikafish. Expect `clang-format` which we use to format our codebase.
```bash
sudo apt install build-essential git
```
#### clang-format
```bash
sudo apt install clang-format-17
```
</details>
### MacOS
<details>
<summary>Show more</summary>
#### Installing a compiler
On MacOS you will need to install the Xcode Command Line Tools.
It is enough to run the following command in your terminal, instead of installing the full Xcode.
```bash
sudo xcode-select --install
```
#### clang-format
```bash
brew install clang-format@17
```
</details>
## Participating in the project
Pikafish's improvement over the last decade has been a great community effort.
Nowadays most development talk takes place on [Discord](https://discord.com/invite/uSb3RXb7cY).
There are many ways to contribute to Pikafish:
- [Pikafish](#pikafish) (C++)
- [Fishtest](#fishtest) (Python)
- [nnue-pytorch](#nnue-pytorch) (C++ and Python)
- [Donating hardware](#donating-hardware)
### Pikafish
If you want to contribute to Pikafish directly, you can do so in a couple of ways.
Follow the steps described in our [Fishtest wiki](https://github.com/official-pikafish/PikaFishtest/wiki/Creating-my-first-test) to create your first test.
__It is advised to first follow the [development setup](https://github.com/official-pikafish/Pikafish/wiki/Developers#pikafish-development-setup) steps for your platform__
New commits to pikafish can mostly be categorised in 2 categories:
#### Non functional changes
These are changes that don't change the search behaviour and can be directly
submitted as pull requests.
#### Functional changes
These change the search behaviour and lead to a different search tree.
Every functional patch (commit) has to be verified by
[Fishtest](https://test.pikafish.org), our testing framework.
### NNUE Pytorch
NNUE Pytorch is the trainer for Pikafish's neural network.
Usually changes here are tested by training a new network and testing it against the current network via Fishtest.
### Donating hardware
Improving Pikafish requires a massive amount of testing.
You can donate your hardware resources by installing the [Fishtest Worker](https://github.com/xyztnecniV/visualgpt/wiki/Running-the-worker) and view the current tests on [Fishtest](https://test.pikafish.org).
## Using Stockfish in your own project
First of all, you should **read our [Terms of Use](#terms-of-use)** and follow them carefully.
Pikafish is a UCI chess engine, but what does that mean? It means that Pikafish follows the UCI protocol, which you find explained [here](https://backscattering.de/chess/uci/) in great detail. This is the usual way of communicating with Pikafish, so you do not need to write any C++!
Your next step is probably gonna be researching how you can open an executable in your programming language. You will need to write to `stdin` and listen to `stdout`, that is where Pikafish's output will end up.
---
### Examples
- Python: https://python-chess.readthedocs.io/en/latest/engine.html
- NodeJS: You can follow [this guide](https://blog.logrocket.com/using-stdout-stdin-stderr-node-js/) on how to communicate with a program.
- C++: [Boost.Process](https://www.boost.org/doc/libs/1_64_0/doc/html/process.html) can be used for easy process communication.
- Rust: Examine the documentation on [how to spawn a Command](https://doc.rust-lang.org/std/process/struct.Command.html).
### Limitations
> I want Pikafish to comment on the move it made, what do I need to do?
That is not possible. You will have to write your own logic to create such a feature.
> I want to get an evaluation of the current position.
While Pikafish has an [`eval`](Commands#eval) command, it only statically evaluates positions without performing any search. A more precise evaluation is available after you use the [`go`](Commands#go) command together with a specified limit.
### Other resources
- [Commands](UCI-&-Commands)
- [Advanced topics](Advanced-topics)
- [Useful data](Useful-data)
### Terms of use
Pikafish is free and distributed under the [**GNU General Public License version 3**](https://github.com/official-pikafish/Pikafish/blob/master/Copying.txt) (GPL v3). Essentially, this means you are **free to do almost exactly what you want** with the program, including **distributing it** among your friends, **making it available for download** from your website, **selling it** (either by itself or as part of some bigger software package), or **using it as the starting point** for a software project of your own. This also means that you can distribute Pikafish [alongside your proprietary system](https://www.gnu.org/licenses/gpl-faq.html#GPLInProprietarySystem), but to do this validly, you must make sure that Pikafish and your program communicate at arm's length, that they are not combined in a way that would make them effectively a single program.
The only real limitation is that whenever you distribute Pikafish in some way, **you MUST always include the license and the full source code** (or a pointer to where the source code can be found) to generate the exact binary you are distributing. If you make any changes to the source code, these changes must also be made available under GPL v3.
## Git Hooks
Place the following file into `.git/hooks/pre-push` and make it executable.
`chmod +x .git/hooks/pre-push`. This will prevent you from pushing commits that
do not contain a Bench or 'No functional change' in the commit message.
Only really useful for maintainers.
```bash
#!/bin/bash
if ! which clang-format-18 >/dev/null; then
CLANG_FORMAT=clang-format
else
CLANG_FORMAT=clang-format-18
fi
# Extracted from the Makefile
SRCS=$(awk '/^SRCS = /{flag=1; sub(/^SRCS = /,""); print} /^$/{flag=0} flag && !/^SRCS = /{print}' ./src/Makefile | tr -d '\\' | xargs echo | tr ' ' '\n' | sed 's|^|./src/|')
HEADERS=$(awk '/^HEADERS = /{flag=1; sub(/^HEADERS = /,""); print} /^$/{flag=0} flag && !/^HEADERS = /{print}' ./src/Makefile | tr -d '\\' | xargs echo | tr ' ' '\n' | sed 's|^|./src/|')
while read local_ref local_sha remote_ref remote_sha; do
if [[ "$remote_ref" == "refs/heads/master" ]]; then
# Check open diffs
if [[ -n $(git status --porcelain) ]]; then
echo "Please commit or stash your changes before pushing."
exit 1
fi
# Check formatting
if ! $CLANG_FORMAT --dry-run -Werror -style=file $SRCS $HEADERS; then
echo "Please run 'make format' to fix formatting issues and rebase the last commit."
exit 1
fi
# Iterate through commits
for commit in $(git rev-list --no-merges $remote_sha..$local_sha); do
commit_msg=$(git log --format=%B -n 1 $commit)
# bench regex as defined in ci
# check for the existence of a bench in the commit message
bench_regex='\b[Bb]ench[ :]+[1-9][0-9]{5,7}\b'
if echo "$commit_msg" | grep -m 1 -o -x -E "$bench_regex" >/dev/null; then
continue
fi
# check for the existence of "No functional change" in the commit message
no_functional_change_regex='\b[Nn]o[[:space:]][Ff]unctional[[:space:]][Cc]hange\b'
if echo "$commit_msg" | grep -o -x -E "$no_functional_change_regex" >/dev/null; then
continue
fi
echo "Commit $commit does not contain a Bench or 'No functional change'."
exit 1
done
fi
done
exit 0
```
@@ -0,0 +1,147 @@
## Download Pikafish
> [!NOTE]
> Pikafish is a [**command line program**](Pikafish-FAQ#executing-pikafish-opens-a-cmd-window). You may want to use it in your own UCI-compatible [xiangqi GUI](#download-a-xiangqi-gui).
> Developers should communicate with Pikafish via the [UCI protocol](https://github.com/official-pikafish/Pikafish/wiki/UCI-&-Commands#standard-commands).
### Get started
1. First [download](#official-downloads) Pikafish. Pikafish itself is *completely free* with all its options.
2. Next, [download a GUI](#download-a-xiangqi-gui) (Graphical User Interface) as it is needed to conveniently use Pikafish. There are multiple free and commercial GUIs available. Different GUI's have more or less advanced features, for example, an opening explorer or automatic game analysis.
3. Now Pikafish must be made available to the GUI. [Install in a Xiangqi GUI](#install-in-a-xiangqi-gui) explains how this can be done for some of them. If a different GUI is used, please read the GUI's manual.
4. Ultimately, change the default [settings](#change-settings) of Pikafish to get the [best possible analysis](Pikafish-FAQ#optimal-settings).
---
### Official downloads
#### Latest release
https://pikafish.org/
Binaries are also available on GitHub: https://github.com/official-pikafish/Pikafish/releases/latest
#### Latest development build
1. Navigate to our [actions](https://github.com/official-pikafish/Pikafish/actions/workflows/pikafish.yml)
2. Choose the latest run
3. Scroll to the bottom
3. Download your preferred binary
> [!NOTE]
> We **only** recommend downloading from the [official GitHub releases](https://github.com/official-pikafish/Pikafish/releases).
> Websites such as [棋中论坛](<http://www.qqzze.com/>) are third parties, so we cannot guarantee the safety, reliability, and availability of those binaries because we are not responsible for them.
### Choose a binary
In order of preference:
1. x86-64-vnni512
2. x86-64-avx512
* AMD: Zen 4 and newer (e.g. Ryzen 9 7950X).
3. x86-64-avx512f
4. x86-64-avxvnni
5. x86-64-bmi2
* Intel: 4th Gen and newer (e.g. i7 4770K, i5 13600K).
* AMD: Zen 3 (e.g. Ryzen 5 5600X).
6. x86-64-avx2
* AMD: Zen, Zen+, and Zen 2 (e.g. Ryzen 5 1600, Ryzen 5 3600).
7. x86-64-sse41-popcnt
---
## Download a Xiangqi GUI
A xiangqi graphical user interface allows you to interact with the engine in a user-friendly way. Popular GUIs are:
### Free
#### Computer
| **[SharkChess](http://www.sharkchess.com/)** <br>[How to install Pikafish](#sharkchess)<br>[Change settings](#sharkchess-1) | **[XBoard](https://www.gnu.org/software/xboard/#download)** ([source code](https://ftp.gnu.org/gnu/xboard/)) <br>[How to install Pikafish](#xboard)<br>[Change settings](#xboard-1) |
|:---|:---|
| [![][sharkchess]][sharkchess] | [![][xboard]][xboard] |
### Online
> [!NOTE]
> If you don't want to download a GUI, you can also use some of the available online interfaces. Keep in mind that you might not get the latest version of Pikafish, settings might be limited and speed will be slower.
| **[XiangqiAI](https://xiangqiai.com)**<br>[Change settings](#xiangqiai) |
|:---|
| [![][xiangqiai]][xiangqiai] |
---
## Install in a Xiangqi GUI
### SharkChess
1. Engines > Engines Settings
<img src="https://github.com/user-attachments/assets/29fd347f-0c45-459a-9c87-87fbe55a8ea3" width="300">
2. Switch to Engines Management tab and click the add button
<img src="https://github.com/user-attachments/assets/4424f644-facc-45d3-a59b-050d37f815fc" width="300">
3. Select and open the Pikafish executable
<img src="https://github.com/user-attachments/assets/3b0fbb50-1240-4d05-adce-20bb52c789cc" width="300">
### XBoard
1. Install `uci2wb`
For Ubuntu distributions:
`sudo apt install uci2wb`
For other distros, clone and build uci2wb:
```
git clone 'http://hgm.nubati.net/git/uci2wb.git'
cd uci2wb
make uci2wb
make prefix=/usr install
```
2. Configure Pikafish as Xboard engine
`Engine > Load New 1st Engine...`
![2023-07-15-12:49:50-screenshot](https://github.com/official-pikafish/Pikafish/assets/49029378/65eb5062-7958-425c-b02c-d0026a8cd42d)
> [!IMPORTANT]
> - Engine Command is `uci2wb pikafish`
> - Make sure the first three boxes are _unchecked_
---
## Change settings
> [!NOTE]
> Please check our [FAQ guide](Pikafish-FAQ#optimal-settings) to set the optimal settings.
### SharkChess
* Click the configure button
![image](https://github.com/user-attachments/assets/14ce3d20-736a-49d2-ab23-e746c7be11ae)
### Xboard
* Engine > Engine #1 Settings...
![2023-07-15-13:00:16-screenshot](https://github.com/official-pikafish/Pikafish/assets/49029378/c08aad04-1cf0-4c03-8537-d12dc4f4572e)
> [!IMPORTANT]
> Make sure `EvalFile` field is configured and pointed to the correct Pikafish NNUE file. If you don't configure this field or the path to the file is wrong then the engine will die.
### XiangqiAI
* Click the setting button
![2023-07-15-13:00:16-screenshot](https://github.com/user-attachments/assets/94b1e18f-7883-4ad5-bafc-a4c9fffdd6e8)
* Engine Settings
![image](https://github.com/user-attachments/assets/cfb14ed7-9cd6-4c30-9730-f3f3190bfbf8)
[sharkchess]: https://www-x-sharkchess-x-com.img.addlink.cn/wp-content/uploads/2018/09/shark.jpg
[xboard]: https://www.gnu.org/software/xboard/graphics/xboard-4.4.0-XQ.png
[xiangqiai]: https://github.com/user-attachments/assets/33a18c00-bad5-46e1-87f9-57dae0b40991
+38
View File
@@ -0,0 +1,38 @@
[Pikafish](https://pikafish.org/) is a **free, open source, and strong UCI xiangqi engine** derived from Stockfish that analyzes xiangqi positions and computes the optimal moves.
Pikafish **does not include a graphical user interface** (GUI) that is required to display a xiangqi board and to make it easy to input moves. Several [Free GUIs](Download-and-usage#free) are developed independently from Pikafish and are available online.
**Read the documentation for your GUI** of choice for information about how to use Pikafish with it.
## Guides
* For users
* [Download Pikafish](Download-and-usage#download-pikafish)
* [Download GUI](Download-and-usage#download-a-xiangqi-gui)
* [Install in GUI](Download-and-usage#install-in-a-xiangqi-gui)
* [Commands and options](UCI-&-Commands)
* [Frequently asked questions (FAQ)](Pikafish-FAQ)
* [For Developers](Developers)
* [Compiling from sources](Compiling-from-source)
* [Using Pikafish in your project](Developers#using-pikafish-in-your-own-project)
* [Contributing](Developers#participating-in-the-project)
* [Copying](https://github.com/official-pikafish/Pikafish/blob/master/Copying.txt)
## Support
If you're looking for any kind of assistance with Pikafish.
* [Discord](https://discord.com/invite/uSb3RXb7cY)
* [Github discussions](https://github.com/official-pikafish/Pikafish/discussions/categories/q-a)
## Related repositories (some of them are not publicly available right now)
* Trainer: [official-pikafish/pikafish-nnue-pytorch](https://github.com/official-pikafish/pikafish-nnue-pytorch)
* Fishtest:
* Frontend: [official-pikafish/PikaFishtestFrontend](https://github.com/official-pikafish/PikaFishtestFrontend)
* Backend: [official-pikafish/PikaFishtest](https://github.com/official-pikafish/PikaFishtest)
* Worker: [xyztnecniV/visualgpt](https://github.com/xyztnecniV/visualgpt)
* WDL model: [official-stockfish/WDL_model](https://github.com/official-stockfish/WDL_model)
* Matetrack: [vondele/matetrack](https://github.com/vondele/matetrack)
see also [Our overview of Governance and Responsibilities](Governance-and-responsibilities)
+149
View File
@@ -0,0 +1,149 @@
Table of Contents
- [Interpretation of the Pikafish evaluation](#interpretation-of-the-pikafish-evaluation)
- [Optimal settings](#optimal-settings)
- [Threads](#threads)
- [Hash](#hash)
- [MultiPV](#multipv)
- [The Elo rating of Pikafish](#the-elo-rating-of-pikafish)
- [Background information](#background-information)
- [Caveats](#caveats)
- [Conclusion](#conclusion)
- [Pikafish crashed](#pikafish-crashed)
- [Does Pikafish support xiangqi variants?](#does-pikafish-support-xiangqi-variants)
- [Can Pikafish use my GPU?](#can-pikafish-use-my-gpu)
- [Executing Pikafish opens a CMD window](#executing-pikafish-opens-a-cmd-window)
- [User-friendly experience](#user-friendly-experience)
- [Available commands](#available-commands)
- [What is depth?](#what-is-depth)
- [Minimax](#minimax)
- [Pruning](#pruning)
- [Extensions](#extensions)
- [Conclusion](#conclusion-1)
## Interpretation of the Pikafish evaluation.
The evaluation of a position that results from search has traditionally been measured in `pawns` or `centipawns` (1 pawn = 100 centipawns). A value of 1, implied a 1 pawn advantage. However, with engines being so strong, and the NNUE evaluation being much less tied to material value, a new scheme was needed. The new normalized evaluation is now linked to the probability of winning, with a 1.0 pawn advantage being a 0.5 (that is 50%) win probability. An evaluation of 0.0 means equal chances for a win or a loss, but also nearly 100% chance of a draw.
Some GUIs will be able to show the win/draw/loss probabilities directly when the `UCI_ShowWDL` engine option is set to `True`.
The full plots of win, loss, and draw probability are given below. From these probabilities, one can also obtain the expected match score.
| Probabilities | Expected match score |
|:----------------------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://user-images.githubusercontent.com/4202567/206894542-a5039063-09ff-4f4d-9bad-6e850588cac9.png" width="400"> | <img src="https://user-images.githubusercontent.com/4202567/206895934-f861a6a8-2e60-4592-a8f1-89d9aad8dac4.png" width="400"> |
The probability of winning or drawing a game, of course, depends on the opponent and the time control. With bullet games, the draw rate will be lower, and against a weak opponent, even a negative evaluation could result in a win. These graphs have been generated from a model derived from Fishtest data for Pikafish playing against Stockfish (so an equally strong opponent), at 60+0.6s per game. The curves are expected to evolve, i.e. as the engines get stronger, an evaluation of 0.0 will approach the 100% draw limit. These curves are for Pikafish 2023-03-05.
## Optimal settings
To get the best possible evaluation or the strongest move for a given position, the key is to let Pikafish analyze long enough, using a recent release (or development version), properly selected for the CPU architecture.
The following settings are important as well:
### Threads
**Set it to the maximum - (1 or 2 threads).**
Set the number of threads to the maximum available, possibly leaving 1 or 2 threads free for other tasks. SMT or Hyper-threading is beneficial, so normally the number of threads available is twice the number of cores available. Consumer hardware typically has at least 4-8 threads. Pikafish supports hundreds of threads.
[More detailed results](Useful-data#threading-efficiency-and-elo-gain) on the efficiency of threading are available.
### Hash
**Set it to the maximum - (1 or 2 GiB RAM).**
Set the hash to nearly the maximum amount of memory (RAM) available, leaving some memory free for other tasks. The Hash can be any value, not just powers of two. The value is specified in MiB, and typical consumer hardware will have GiB of RAM. For a system with 8GiB of RAM one could use 6000 as a reasonable value for the Hash.
[More detailed results](Useful-data#elo-cost-of-small-hash) on the cost of too little hash are available.
### MultiPV
**Set it to 1.**
A value higher than 1 weakens the quality of the best move computed, as resources are used to compute other moves.
[More detailed results](Useful-data#elo-cost-of-using-multipv) on the cost of MultiPV are available.
## The Elo rating of Pikafish
"What is the Elo of Pikafish?": A seemingly simple question, with no easy answer. First, the obvious: it is higher than any human Elo, and when PF 2023-03-05 ranked with more than 3678 Elo on some rating lists, [Bilibili knew](https://www.bilibili.com/video/BV1Tg4y1E7p1). To answer the question in more detail, some background information is needed.
### Background information
In its simplest form, the [Elo rating system](https://en.wikipedia.org/wiki/Elo_rating_system) predicts the score of a match between two players, and conversely, a match between two players gives information about the Elo difference between them.
The Elo difference depends on the conditions of the match. For human players, time control (blitz vs. classical TC) or variant (standard xiangqi vs. Jieqi) are well-known factors that influence the Elo difference between two players.
Finally, given an Elo difference between two players, one needs to know the Elo rating of one of them to know the Elo rating of the other. More generally, you need an anchor or reference within a group of opponents, and if that reference is different in different groups, the Elo value cannot be compared.
### Caveats
The same observations apply to the calculation of Pikafish's Elo rating, with the caveat that top engines play at an extremely high level and, from the starting position or any balanced opening, have achieved a draw rate approaching 100% against other engines of similar strength, especially at rapid or longer time controls, and even more so on powerful hardware. This results in small Elo differences between top engines, e.g. +19 -2 =79 is a convincing win, but a small Elo difference.
Carefully constructed books of starting positions with a clear advantage for one side can significantly reduce this draw rate and increase Elo differences. The book used in the match is therefore an important factor in the computed Elo difference.
Similarly, the pool of opponents and their rankings has a large impact on the Elo rating, and Elo ratings computed with different pools of opponents are difficult to compare, especially if weaker (but different) engines are part of that pool.
Finally, to accurately compute Elo differences at this level, a very large number of games (typically tens of thousands of games) are needed, as small samples of games (regardless of time control) will lead to large relative errors.
Having introduced all these caveats, accurately measuring Elo differences is central to the development of Pikafish, and our Fishtest framework constantly measures with great precision the Elo difference of Pikafish and its proposed improvements. These performance improvements are accurately tracked over time on the [regression testing](Regression-Tests) wiki page. The same page also links to [various external websites](Regression-Tests#external-links) that rank Pikafish against a wide range of other engines.
### Conclusion
Rating Pikafish on a human scale (e.g. FIDE Elo) has become an almost impossible task, as the difference in strength between it and humans is now so large that this difference can hardly be measured. This would require a human to play Stockfish long enough to have at least a handful of draws and wins.
## Pikafish crashed
Pikafish may crash if fed incorrect fens, or fens with illegal positions. Full validation code is complex to write, and within the UCI protocol, there is no established mechanism to communicate such an error back to the GUI. Therefore Pikafish is written with the expectation that the input fen is correct.
On the other hand, the GUI must carefully check fens. If you find a GUI through which you can crash Pikafish or any other engine, then by all means report it to that GUI's developers.
## Does Stockfish support chess variants?
The official Pikafish engine only supports standard xiangqi. However, various forks based on Stockfish support variants, most notably the [Fairy-Stockfish project](https://github.com/ianfab/Fairy-Stockfish).
## Can Stockfish use my GPU?
No, Pikafish is a chess engine that uses the CPU only for chess evaluation. Its NNUE evaluation ([see this in-depth description](https://github.com/official-pikafish/pikafish-nnue-pytorch/blob/master/docs/nnue.md)) is very effective on CPUs. With extremely short inference times (sub-micro-second), this network can not be efficiently evaluated on GPUs, in particular with the alpha-beta search that Pikafish employs. However, for training networks, Pikafish employs GPUs with effective code that is part of the [NNUE pytorch trainer](https://github.com/official-pikafish/pikafish-nnue-pytorch). Other chess engines require GPUs for effective evaluation, as they are based on large convolutional or transformer networks, and use a search algorithm that allows for batching evaluations. See also the [Pika Xiangqi Zero (Px0) project](https://github.com/official-pikafish/px0).
## Executing Pikafish opens a CMD window
<img width="780" alt="image" src="https://github.com/official-pikafish/Pikafish/assets/73384062/461bf721-6287-4cef-8310-d91a611c5b05">
Pikafish is a command line program, when you execute it, you might notice that it simply opens a Command Prompt (CMD) window. **This behavior is intentional** and serves as the interface for interacting with the engine.
### User-friendly experience
If you prefer a **more user-friendly experience** with a **xiangqi board and additional features**, you can consider using a graphical user interface (GUI) alongside Stockfish. To set up a GUI, you can visit the [Download and Usage](Download-and-usage#download-a-chess-gui) page.
### Available commands
The CMD window allows you to input various commands and receive corresponding outputs from Pikafish. If you want to explore the available commands and their explanations, you can refer to the [Commands](UCI-&-Commands) page but this is **only recommended for advanced users and developers**.
## What is depth?
First, we need to understand how minimax search works. We will go with the vanilla one because explaining what Alpha-beta is does not do much.
### Minimax
**Each player tries to maximize the score in their favor**. White wants the evaluation to be as positive as it can, and Black as negative as it can - we do this all the time when we play chess. Search works in a similar way - you explore your moves, explore the opponent's replies, assign a value called evaluation to each resulting board position (which is not precise but tries to be), and find a sequence where White plays some move that has the maximum evaluation for the best opponent's reply.
Then you search one ply (half-move) deeper - exploring your reply to the last opponent's replies. This process is called iterative deepening - you explore a position up to depth 1, then to depth 2, then to depth 3, and so on - you deepen your search with each iteration and this is why it is called this way.
So, for now, "depth" is a perfect thing - it means you fully calculated the search tree up to this "depth" and you know everything that can happen within it. For a mate in 5, you will need depth 9 to see it (because depth is written in half-moves). But chess has a lot of possible moves, 20 from the starting position and usually many more from any middlegame position. Even if you can evaluate millions of positions per second as engines like Stockfish do, you will still hit a wall in what depths you can realistically reach, and it would not be that high - depth 8, maybe 10.
### Pruning
How to combat this? With a thing called pruning. Pruning splits into quite a lot of different heuristics, but they mostly serve one purpose - **remove branches in search that do not look too desirable**, to re-explore them later when iterative deepening depth goes higher. So this is where "depth" starts to mean less - because you do not search the entire game tree and modern engines prune large percentages of branches.
### Extensions
But then there is also a thing called "**extensions**" which is more or less the opposite of pruning. With extensions, you start by **searching "important" branches deeper** (for example, checks) than what is needed to complete the iterative deepening iteration.
### Conclusion
With all of this, instead of a search tree that is strictly cut off at this "depth", you have **most of the branches ending really early and a lot of branches searched deeper** than the given "depth". Pikafish is the most aggressive engine in both pruning and extensions, so its search tree looks nothing like what you usually see on [Wikipedia](https://en.wikipedia.org/wiki/Minimax).
Coming back to how much Pikafish prunes, there is some data [here](Useful-data#branching-factor-of-pikafish). The branching factor indicates how many moves you calculate on average per depth increase, calculated as $nodes^{\frac{1}{depth}}$. Pikafish 2023-03-05 with higher depths goes all the way down to 1.5, so at depth 50 considers approximately 1.5 moves per ply from the full 20-30-40 moves we usually have. And this is why it [misses some short mates up to high depths](https://www.reddit.com/r/chess/comments/1028i0e/stockfishs_search_tree_trying_to_find_a_mate_in_2/) while vanilla minimax would
have found them at lower ones. It just throws away 90%+ of the moves.
+103
View File
@@ -0,0 +1,103 @@
## General terms
### Threads
Also known as "cores", "CPUs" or "vCPUs".
The amount of CPU threads that the engine will use, usually the higher the better.
Note that a modern CPU will have multiple cores, that typically can run two threads each.
### Hash
Also known as "memory".
The amount of Hash is the amount of RAM that the engine will use to store positions in the game tree.
This information can be reused during the analysis, for example after a transposition,
which means usually [the higher the Hash the better](Useful-data#elo-cost-of-small-hash). See also [Transposition Table](#transposition-table).
### Depth
Counter of [iterative deepening](#iterative-deepening) loop at the root of the game tree, thus also known as rootDepth. Regardless of the name, there is no simple connection to the actual depth searched in the game tree. The deepest lines searched are usually quite a bit deeper than the rootDepth. See also [a discussion on rootDepth vs depth](https://github.com/official-stockfish/Stockfish/discussions/3888).
### Selective Depth
Also known as "seldepth".
Is the depth of the deepest principal variation line in the search.
### Multiple PVs
Also known as "number of lines" or "multiple lines".
The top N moves and their [principal variations](#principal-variation) can be computed. This gives additional insight in the options of the position. However, in Stockfish, this weakens the quality of the best move computed, as resources are used to compute other moves.
### Transposition Table
Also known as "TT".
A database / hash table that stores results of previously performed searches. See also [Hash](#hash).
### Lazy Symmetric Multiprocessing
Also known as "Lazy SMP".
The idea of executing the search function on N many threads and share the Transposition table. This allows for faster filling of the transposition table, resulting in a faster and wider search.
This approach to parallelism is [known to scale well](Useful-data#threading-efficiency-and-elo-gain), especially with longer searches.
### Iterative deepening
The idea of performing consecutive searches at higher depths each time.
### Null Move
Also known as "passing move". TODO
### Time Control
Also known as "TC". How the time limits are set for playing a game. For xiangqi engine testing, Pikafish uses 10+0.1s (10 seconds for the game, 0.1 seconds for every move), and 60+0.6s. These TCs are known as STC (short TC) and LTC (long TC).
## Principal Variation Search
### Principal Variation
Also known as "PV".
The sequence of moves that the engine considers best and therefore expects to be played.
### Pruning
The idea of ignoring certain parts of the search tree in order to reduce the amount of time it takes to execute a search.
### Null Move Pruning
Based on the assumption that, if we can reach beta by not making a move at lower depths, we will most likely be able to reach it anyway.
### Futility Pruning
The idea that quiet moves don't tend to improve positions significantly, therefore we can safely prune quiet moves in positions where the current position is evaluated to be below alpha by a margin.
### Late Move Pruning
Also known as "LMP".
The idea that all quiet moves can be pruned after searching the first few given by the move ordering algorithm.
### Late Move Reductions
Also known as "LMR".
A way of proving if a move is lower than alpha quickly. This is done by searching moves that are expected to underperform at a lower depth.
## Extensions
The idea of extending certain moves, usually by one ply, to try to find better moves faster.
### Check Extensions
They can have two distinct forms: one of them extends when giving check, the other when evading it. The reason behind check extension is that we are in a forcing sequence, so that it is desirable to know its outcome with more certainty.
### Move Ordering
In order to maximize the efficiency of alpha-beta search, we optimally want to try the best moves first.
### Quiescence Search
Also known as "qSearch".
Performed at the end of the main search, the purpose of this search is to only evaluate "quiet" positions, or positions where there are no winning tactical moves to be made.
## Evaluation
### Efficiently Updatable Neural Network
Also known as "NNUE". The first NNUE implementation was added in Stockfish 12, and evaluates positions using a neural network, which is trained on a large set of training data. NNUE is typically much more accurate than classical evaluation, gaining hundreds of Elo.
+606
View File
@@ -0,0 +1,606 @@
The [Universal Chess Interface](https://backscattering.de/chess/uci/) (UCI) is a standard text-based protocol used to communicate with a xiangqi engine and is the recommended way to do so for typical graphical user interfaces (GUI) or chess tools. Pikafish implements the majority of its options.
Developers can see the default values for the UCI options available in Pikafish by typing `./pikafish uci` in a terminal, but most users should typically use a xiangqi GUI to interact with Pikafish.
## Standard commands
### `quit`
Quit the program as soon as possible.
### `uci`
Tell the engine to use the UCI (universal chess interface).
This will be sent once, by a GUI, as a first command after the program boots to tell the engine to switch to UCI mode.
After receiving the `uci` command the engine will identify itself with the `id` command and send the `option` commands to tell the GUI which engine settings the engine supports.
After that, the engine will send `uciok` to acknowledge the UCI mode.
If no `uciok` is sent within a certain time period, the engine task will be killed by the GUI.
<details>
<summary>Example</summary>
```
> uci
id name Pikafish dev-20240822-nogit
id author the Pikafish developers (see AUTHORS file)
option name Debug Log File type string default
option name NumaPolicy type string default auto
option name Threads type spin default 1 min 1 max 1024
option name Hash type spin default 16 min 1 max 33554432
option name Clear Hash type button
option name Ponder type check default false
option name MultiPV type spin default 1 min 1 max 128
option name Move Overhead type spin default 10 min 0 max 5000
option name nodestime type spin default 0 min 0 max 10000
option name UCI_ShowWDL type check default false
option name EvalFile type string default pikafish.nnue
uciok
```
</details>
### `setoption`
Usage: `setoption name <id> [value <x>]`
This is sent to the engine when the user wants to change the internal parameters of the engine. For the `button` type no value is needed.
One string will be sent for each parameter and this will only be sent when the engine is waiting.
Examples:
```
> setoption name Threads value 6
> setoption name EvalFile value pikafish.nnue
> setoption name UCI_ShowWDL value true
> setoption name Clear Hash
```
List of options:
* `Debug Log File` `type string default`
Write all communication to and from the engine into a text file.
* `NumaPolicy` `type string default auto`
Bind threads to ensure execution on a specific NUMA node.
Improves performance on systems with multiple CPUs or CPUs with multiple NUMA domains.
The following values can be used:
* `system` - gathers NUMA node information from the system (including affinities preset by the user or the GUI), for each thread binds it to a single NUMA node
* `none` - assumes there is 1 NUMA node, never binds threads
* `auto` - this is the default value, automatically selects `system` or `none` depending on the number of set threads and available NUMA nodes. Will only select `system` when the number of threads reaches a system-dependent threshold.
* `hardware` - gathers NUMA node information for the underlying hardware (disregards and overrides affinities preset by the user or the GUI), for each thread binds it to a single NUMA node
* `[[custom]]` - specify precisely the available CPUs per numa domain. ':' separates numa nodes; ',' separates cpu indices; supports "first-last" range syntax for cpu indices, for example `0-15,32-47:16-31,48-63`
* `Threads` `type spin default 1 min 1 max 1024`
The number of CPU threads used for searching a position. For best performance, set this equal to the number of CPU cores available.
* `Hash` `type spin default 16 min 1 max 33554432`
The size of the hash table in MB. It is recommended to set Hash after setting Threads.
* `Clear Hash` `type button`
Clear the hash table.
* `Ponder` `type check default false`
Let Pikafish ponder its next move while the opponent is thinking.
* `MultiPV` `type spin default 1 min 1 max 500`
Output the N best lines (principal variations, PVs) when searching.
Leave at 1 for the best performance.
* `Move Overhead` `type spin default 10 min 0 max 5000`
Assume a time delay of x ms due to network and GUI overheads. This is useful to avoid losses on time in those cases.
* `nodestime` `type spin default 0 min 0 max 10000`
Tells the engine to use nodes searched instead of wall time to account for elapsed time. Useful for engine testing. When this option is set, the engine is only limited by the total amount of nodes searched per game; this limit is calculated once per game. The initial time control values in milliseconds (time `time` and increment per move `inc`) are used as input values to calculate the total number of nodes per game (`totalnodes`). The increment per move `inc` is used as if it was just one move per game. The formula is `totalnodes = (time + inc * 1) * nodestime`. Suppose you specified `nodestime = 600`, and the time control per game is 300 seconds plus 3 seconds increment per move ("300+3s"), or 300000 milliseconds plus 3000 milliseconds increment per move. In that case, the maximum total number of nodes searched per game by the engine is `totalnodes = (300000 + 3000 * 1) * 1000 = 181800000` (one hundred eighty-one million, eight hundred thousand) nodes, regardless of how much wall time it will actually take.
* `UCI_ShowWDL` `type check default false`
If enabled, show approximate WDL statistics as part of the engine output.
These WDL numbers model expected game outcomes for a given evaluation and game ply for engine self-play at fishtest LTC conditions (60+0.6s per game).
* `EvalFile` `type string default pikafish.nnue`
The name of the file of the NNUE evaluation parameters. Depending on the GUI the filename might have to include the full path to the folder/directory that contains the file. Other locations, such as the directory that contains the binary and the working directory, are also searched.
### `position`
Usage: `position [fen <fenstring> | startpos ] moves <move1> .... <movei>`
Set up the position described in `fenstring`.
> [!NOTE]
> If this position is from a different game than the last position sent to the engine, the GUI should have sent a `ucinewgame` in between.
Examples:
```
> position startpos
> position fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1
> position fen rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1 moves h2e2 h9g7 h0g2 g6g5
```
### `ucinewgame`
This is sent to the engine when the next search (started with `position` and `go`) will be from a different game. This can be a new game the engine should play or a new game it should analyze but also the next position from a test suite with positions only.
If the GUI hasn't sent a `ucinewgame` before the first `position` command, the engine won't expect any further `ucinewgame` commands as the GUI is probably not supporting the `ucinewgame` command.
So the engine will not rely on this command even though all new GUIs should support it.
As the engine's reaction to `ucinewgame` can take some time the GUI should always send `isready` after `ucinewgame` to wait for the engine to finish its operation. The engine will respond with `readyok`.
_This clears the hash and any information which was collected during the previous search._
<details>
<summary>Example</summary>
```
> ucinewgame
> isready
readyok
> position startpos
> go depth 1
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 8 nodes 74 nps 37000 hashfull 0 tbhits 0 time 2 pv b2e2
bestmove b2e2
> ucinewgame
> isready
readyok
> position fen rnbakabr1/9/1c4nc1/p1p1p2Rp/6p2/9/P1P1P1P1P/1C2C1N2/9/RNBAKAB2 b - - 7 4
```
</details>
### `isready`
This is used to synchronize the engine with the GUI.
When the GUI has sent a command or multiple commands that can take some time to complete, this command can be used to wait for the engine to be ready again or to ping the engine to find out if it is still alive.
e.g. this should be sent after setting the path to the tablebases as this can take some time.
This command is also required once, before the engine is asked to do any searching, to wait for the engine to finish initializing.
This command will always be answered with `readyok` and can be sent also when the engine is calculating in which case the engine will also immediately answer with `readyok` without stopping the search.
Example:
```
> isready
readyok
```
### `go`
Start calculating on the current position set up with the `position` command.
There are a number of parameters that can follow this command and all will be sent in the same string.
If no parameter is sent, then `go depth 245` will be executed.
<details>
<summary>Example: go infinite</summary>
```
> position startpos
> go infinite
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 8 nodes 74 nps 37000 hashfull 0 tbhits 0 time 2 pv b2e2
info depth 2 seldepth 2 multipv 1 score cp 20 nodes 191 nps 95500 hashfull 0 tbhits 0 time 2 pv h2e2
info depth 3 seldepth 2 multipv 1 score cp 21 nodes 267 nps 89000 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 4 seldepth 2 multipv 1 score cp 65 nodes 342 nps 114000 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 5 seldepth 2 multipv 1 score cp 320 nodes 389 nps 129666 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 6 seldepth 6 multipv 1 score cp 30 nodes 925 nps 231250 hashfull 0 tbhits 0 time 4 pv h2e2 h7e7 h0g2
info depth 7 seldepth 5 multipv 1 score cp 35 nodes 1636 nps 327200 hashfull 0 tbhits 0 time 5 pv b2e2 b7e7 b0c2
info depth 8 seldepth 8 multipv 1 score cp 34 nodes 2972 nps 424571 hashfull 1 tbhits 0 time 7 pv b2e2 h7e7 h0g2 b9c7 b0c2 h9g7
info depth 9 seldepth 9 multipv 1 score cp 33 nodes 5284 nps 587111 hashfull 3 tbhits 0 time 9 pv h2e2 b7e7 h0g2 b9c7 i0h0 h9g7 b0c2
> stop
info depth 10 seldepth 10 multipv 1 score cp 22 nodes 12888 nps 758117 hashfull 7 tbhits 0 time 17 pv h2e2 h9g7 h0g2 i9h9 c3c4 b7e7 i0h0 b9c7
bestmove b2e2 ponder h9g7
```
</details>
<details>
<summary>Example: go depth</summary>
```
> position startpos
> go depth 25
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 8 nodes 74 nps 37000 hashfull 0 tbhits 0 time 2 pv b2e2
info depth 2 seldepth 2 multipv 1 score cp 20 nodes 191 nps 95500 hashfull 0 tbhits 0 time 2 pv h2e2
info depth 3 seldepth 2 multipv 1 score cp 21 nodes 267 nps 89000 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 4 seldepth 2 multipv 1 score cp 65 nodes 342 nps 114000 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 5 seldepth 2 multipv 1 score cp 320 nodes 389 nps 129666 hashfull 0 tbhits 0 time 3 pv b2e2
info depth 6 seldepth 6 multipv 1 score cp 30 nodes 925 nps 231250 hashfull 0 tbhits 0 time 4 pv h2e2 h7e7 h0g2
info depth 7 seldepth 5 multipv 1 score cp 35 nodes 1636 nps 327200 hashfull 0 tbhits 0 time 5 pv b2e2 b7e7 b0c2
info depth 8 seldepth 8 multipv 1 score cp 34 nodes 2972 nps 424571 hashfull 1 tbhits 0 time 7 pv b2e2 h7e7 h0g2 b9c7 b0c2 h9g7
info depth 9 seldepth 9 multipv 1 score cp 33 nodes 5284 nps 587111 hashfull 3 tbhits 0 time 9 pv h2e2 b7e7 h0g2 b9c7 i0h0 h9g7 b0c2
info depth 10 seldepth 10 multipv 1 score cp 22 nodes 12888 nps 805500 hashfull 7 tbhits 0 time 16 pv h2e2 h9g7 h0g2 i9h9 c3c4 b7e7 i0h0 b9c7
info depth 11 seldepth 14 multipv 1 score cp 29 nodes 23685 nps 845892 hashfull 13 tbhits 0 time 28 pv h2e2 h9g7 h0g2 i9h9 i0h0 h7h3 g3g4 h3g3 h0h9 g7h9 e2e6
info depth 12 seldepth 16 multipv 1 score cp 24 nodes 40104 nps 891200 hashfull 21 tbhits 0 time 45 pv h2e2 h9g7 h0g2 i9h9 i0h0 g6g5 h0h6 c9e7 b0c2 h7i7 h6g6 h9h3 b2a2 h3g3
info depth 13 seldepth 15 multipv 1 score cp 26 nodes 51293 nps 884362 hashfull 25 tbhits 0 time 58 pv h2e2 h9g7 h0g2 b9c7 i0h0 i9h9 g3g4 c6c5 b0a2 a6a5 h0h6 c9e7 b2d2
info depth 14 seldepth 19 multipv 1 score cp 28 nodes 63360 nps 880000 hashfull 32 tbhits 0 time 72 pv h2e2 h9g7 h0g2 b9c7 i0h0 i9h9 g3g4 c6c5 b0a2 h7h3 g2f4 b7b3 g4g5 h3g3 h0h9 g7h9
info depth 15 seldepth 17 multipv 1 score cp 28 nodes 78800 nps 875555 hashfull 38 tbhits 0 time 90 pv h2e2 h9g7 h0g2 i9h9 i0h0 b9c7 g3g4 c6c5 b0a2 h7h3 g2f4 b7b3 g4g5 h3g3 h0h9 g7h9
info depth 16 seldepth 20 multipv 1 score cp 24 nodes 127092 nps 901361 hashfull 63 tbhits 0 time 141 pv b2e2 b7e7 b0c2 b9c7 a0b0 a9a8 h0g2 a8f8 c3c4 f8f3
info depth 17 seldepth 16 multipv 1 score cp 43 nodes 159456 nps 911177 hashfull 79 tbhits 0 time 175 pv b2e2 b9c7 b0c2 a9b9 a0b0 c6c5 b0b6 g6g5 b6c6 h9g7 h0g2 b7b2 h2i2
info depth 18 seldepth 23 multipv 1 score cp 29 nodes 323086 nps 939203 hashfull 151 tbhits 0 time 344 pv b2e2 b9c7 b0c2 a9b9 a0b0 c6c5 g3g4 g9e7 h0g2 h7h3 c3c4 c5c4 b0b6
info depth 19 seldepth 23 multipv 1 score cp 19 nodes 487252 nps 957273 hashfull 226 tbhits 0 time 509 pv b2e2 b7e7 b0c2 b9c7 a0b0 a9a8 h2i2 h7g7 h0g2 h9i7 i0h0 a8f8 c3c4 i9h9 h0h9 i7h9 b0b6 f8f3 b6c6 f3g3 c2e1
info depth 20 seldepth 25 multipv 1 score cp 27 nodes 790761 nps 958498 hashfull 363 tbhits 0 time 825 pv b2e2 b9c7 b0c2 a9b9 a0b0 h9g7 g3g4 c6c5 h0g2 i9i8 b0b6 b7a7 b6c6 b9b4 h2i2 b4g4
info depth 21 seldepth 24 multipv 1 score cp 23 nodes 910539 nps 961498 hashfull 405 tbhits 0 time 947 pv b2e2 b9c7 b0c2 a9b9 a0b0 h9g7 g3g4 c6c5 h0g2 b7b3 h2h4 g9e7 c3c4 g6g5 g4g5 c5c4 g5g6 c4c3 g6g7 i9g9 g7h7 g9g2
info depth 22 seldepth 28 multipv 1 score cp 19 nodes 1348750 nps 965461 hashfull 553 tbhits 0 time 1397 pv b2e2 b9c7 b0c2 a9b9 a0b0 c6c5 h0g2 b7b3 g3g4 g9e7 c2a1 b3b4 h2h4 b4h4 b0b9 c7b9
info depth 23 seldepth 26 multipv 1 score cp 26 nodes 1641335 nps 960968 hashfull 639 tbhits 0 time 1708 pv b2e2 b9c7 b0c2 a9b9 a0b0 h9g7 g3g4 c6c5 h0g2 i9i8 h2i2 h7h3 i0h0 h3g3 b0b4 b7a7 b4f4 g3c3 c0a2 c9e7
info depth 24 seldepth 28 multipv 1 score cp 27 nodes 2126771 nps 954993 hashfull 756 tbhits 0 time 2227 pv b2e2 b9c7 b0c2 a9b9 a0b0 h9g7 g3g4 c6c5 b0b6 c7d5 b6b4 c5c4 b4c4 b7d7 h0g2 h7h5 h2i2 g9e7 i0h0
info depth 25 seldepth 26 multipv 1 score cp 20 nodes 2694626 nps 959283 hashfull 841 tbhits 0 time 2809 pv b2e2 b9c7 b0c2 a9b9 a0b0 h9g7 g3g4 c6c5 h0g2 i9i8 h2i2 h7h3 i0h0 h3g3 b0b4 i8f8 e3e4 c9e7 c3c4 c5c4 b4c4 c7d5
bestmove b2e2 ponder b9c7
```
</details>
<details>
<summary>Example: go mate</summary>
```
> position fen 3k5/9/4P4/9/9/9/9/9/9/4K4 w
> go mate 1
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 158 nodes 5 nps 2500 hashfull 0 tbhits 0 time 2 pv e7d7
info depth 2 seldepth 2 multipv 1 score cp 158 nodes 10 nps 5000 hashfull 0 tbhits 0 time 2 pv e7d7
info depth 3 seldepth 2 multipv 1 score cp 158 nodes 21 nps 10500 hashfull 0 tbhits 0 time 2 pv e7d7
info depth 4 seldepth 2 multipv 1 score cp 158 nodes 28 nps 9333 hashfull 0 tbhits 0 time 3 pv e7d7
info depth 5 seldepth 2 multipv 1 score mate 1 nodes 34 nps 11333 hashfull 0 tbhits 0 time 3 pv e7d7
bestmove e7d7
```
</details>
<details>
<summary>Example: MultiPV</summary>
```
> setoption name MultiPV value 2
> position startpos
> go depth 5
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 20 nodes 101 nps 50500 hashfull 0 tbhits 0 time 2 pv b2e2
info depth 1 seldepth 1 multipv 2 score cp 8 nodes 101 nps 50500 hashfull 0 tbhits 0 time 2 pv h2e2
info depth 2 seldepth 2 multipv 1 score cp 20 nodes 199 nps 99500 hashfull 0 tbhits 0 time 2 pv b2e2 b9c7
info depth 2 seldepth 2 multipv 2 score cp 17 nodes 199 nps 99500 hashfull 0 tbhits 0 time 2 pv h2e2 h9g7
info depth 3 seldepth 3 multipv 1 score cp 20 nodes 321 nps 160500 hashfull 0 tbhits 0 time 2 pv b2e2 b9c7 b0c2
info depth 3 seldepth 3 multipv 2 score cp 17 nodes 321 nps 160500 hashfull 0 tbhits 0 time 2 pv h2e2 h9g7 h0g2
info depth 4 seldepth 4 multipv 1 score cp 20 nodes 464 nps 154666 hashfull 0 tbhits 0 time 3 pv b2e2 b9c7 b0c2 a9b9
info depth 4 seldepth 4 multipv 2 score cp 17 nodes 464 nps 154666 hashfull 0 tbhits 0 time 3 pv h2e2 h9g7 h0g2 i9h9
info depth 5 seldepth 5 multipv 1 score cp 20 nodes 623 nps 207666 hashfull 0 tbhits 0 time 3 pv b2e2 b9c7 b0c2 a9b9 a0b0
info depth 5 seldepth 5 multipv 2 score cp 17 nodes 623 nps 207666 hashfull 0 tbhits 0 time 3 pv h2e2 h9g7 h0g2 i9h9 i0h0
bestmove b2e2 ponder b9c7
```
</details>
<details>
<summary>Example: UCI_ShowWDL</summary>
```
> setoption name UCI_ShowWDL value true
> position startpos
> go depth 5
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 8 wdl 36 951 13 nodes 74 nps 74000 hashfull 0 tbhits 0 time 1 pv b2e2
info depth 2 seldepth 2 multipv 1 score cp 20 wdl 66 927 7 nodes 191 nps 95500 hashfull 0 tbhits 0 time 2 pv h2e2
info depth 3 seldepth 2 multipv 1 score cp 21 wdl 67 926 7 nodes 267 nps 133500 hashfull 0 tbhits 0 time 2 pv b2e2
info depth 4 seldepth 2 multipv 1 score cp 65 wdl 187 811 2 nodes 342 nps 171000 hashfull 0 tbhits 0 time 2 pv b2e2
info depth 5 seldepth 2 multipv 1 score cp 320 wdl 726 274 0 nodes 389 nps 129666 hashfull 0 tbhits 0 time 3 pv b2e2
bestmove b2e2
```
</details>
Parameters:
* `searchmoves <move1> .... <movei>`
Restrict search to these moves only.
Example: After `position startpos` and `go infinite searchmoves h2e2 h0g2` the engine will only search the two moves h2e2 and h0g2 in the initial position.
* `ponder`
Start searching in pondering mode. It won't exit the search in ponder mode, even if it's mate!
This means that the last move sent in in the position string is the ponder move.
The engine can do what it wants to do, but after a `ponderhit` command it will execute the suggested move to ponder on.
This means that the ponder move sent by the GUI can be interpreted as a recommendation about which move to ponder.
However, if the engine decides to ponder on a different move, it won't display any mainlines as they are likely to be misinterpreted by the GUI because the GUI expects the engine to ponder on the suggested move.
* `wtime <x>`
White has x ms left on the clock.
* `btime <x>`
Black has x ms left on the clock.
* `winc <x>`
White increment per move in ms if x > 0.
* `binc <x>`
Black increment per move in ms if x > 0.
* `movestogo <x>`
There are x moves to the next time control
_Note: this will only be sent if x > 0, if you don't get this and get the wtime and btime it's sudden death._
* `depth <x>`
Search x plies only.
* `nodes <x>`
Search x nodes only.
* `mate <x>`
Search for a mate in x moves.
* `movetime <x>`
Search exactly x ms.
* `infinite`
Search until the `stop` command. Stockfish won't exit the search without being told so in this mode!
* `perft <x>`
A debugging function to walk the move generation tree of strictly legal moves to count all the leaf nodes of a certain depth.
### `stop`
Stop calculating as soon as possible
<details>
<summary>Example</summary>
```
> position startpos
> go infinite
info string NNUE evaluation using nn-ad9b42354671.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 18 nodes 20 nps 4000 hashfull 0 tbhits 0 time 5 pv e2e4
info depth 2 seldepth 2 multipv 1 score cp 46 nodes 66 nps 11000 hashfull 0 tbhits 0 time 6 pv d2d4
info depth 3 seldepth 2 multipv 1 score cp 51 nodes 120 nps 20000 hashfull 0 tbhits 0 time 6 pv e2e4
info depth 4 seldepth 2 multipv 1 score cp 58 nodes 144 nps 18000 hashfull 0 tbhits 0 time 8 pv d2d4
info depth 5 seldepth 2 multipv 1 score cp 58 nodes 174 nps 15818 hashfull 0 tbhits 0 time 11 pv d2d4 a7a6
info depth 6 seldepth 7 multipv 1 score cp 34 nodes 1303 nps 81437 hashfull 0 tbhits 0 time 16 pv e2e4 c7c5 g1f3 b8c6 c2c3
info depth 7 seldepth 6 multipv 1 score cp 29 nodes 3126 nps 120230 hashfull 1 tbhits 0 time 26 pv d2d4 g8f6 e2e3 d7d5 c2c4 d5c4
info depth 8 seldepth 7 multipv 1 score cp 26 nodes 5791 nps 152394 hashfull 4 tbhits 0 time 38 pv g1f3 g8f6 d2d4 d7d5 e2e3
info depth 9 seldepth 9 multipv 1 score cp 31 nodes 8541 nps 174306 hashfull 5 tbhits 0 time 49 pv g1f3 c7c5 e2e4 e7e6 d2d4 c5d4 f3d4
info depth 10 seldepth 13 multipv 1 score cp 25 nodes 20978 nps 209780 hashfull 10 tbhits 0 time 100 pv e2e4 c7c5 g1f3 b8c6 f1c4 e7e6 e1g1 g8f6
info depth 11 seldepth 13 multipv 1 score cp 32 nodes 29040 nps 220000 hashfull 14 tbhits 0 time 132 pv e2e4 c7c5 c2c3 g8f6 e4e5 f6d5 d2d4
info depth 12 seldepth 14 multipv 1 score cp 38 nodes 41207 nps 242394 hashfull 18 tbhits 0 time 170 pv e2e4 e7e6 d2d4 d7d5 b1c3 d5e4 c3e4
> stop
info depth 13 seldepth 14 multipv 1 score cp 38 nodes 45531 nps 247451 hashfull 21 tbhits 0 time 184 pv e2e4 e7e6 d2d4 d7d5 b1c3 d5e4 c3e4
bestmove e2e4 ponder e7e6
```
</details>
### `ponderhit`
The user has played the expected move.
This will be sent if the engine was told to ponder on the same move the user has played.
The engine will continue searching but switch from pondering to normal search.
<details>
<summary>Example</summary>
```
> setoption name Ponder value true
> position startpos moves h2e2
> go movetime 1000
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp -9 nodes 124 nps 62000 hashfull 0 tbhits 0 time 2 pv h9g7
info depth 2 seldepth 2 multipv 1 score cp 0 nodes 203 nps 67666 hashfull 0 tbhits 0 time 3 pv b9c7
info depth 3 seldepth 2 multipv 1 score cp 0 nodes 253 nps 84333 hashfull 0 tbhits 0 time 3 pv b9c7
info depth 4 seldepth 2 multipv 1 score cp 0 nodes 298 nps 99333 hashfull 0 tbhits 0 time 3 pv b9c7
info depth 5 seldepth 2 multipv 1 score cp 11 nodes 346 nps 115333 hashfull 0 tbhits 0 time 3 pv b9c7
info depth 6 seldepth 4 multipv 1 score cp -9 nodes 1060 nps 265000 hashfull 0 tbhits 0 time 4 pv h9g7 h0g2 g6g5 i0h0
info depth 7 seldepth 7 multipv 1 score cp -23 nodes 2652 nps 442000 hashfull 1 tbhits 0 time 6 pv h9g7 h0g2 g6g5 c3c4
info depth 8 seldepth 7 multipv 1 score cp -32 nodes 4771 nps 596375 hashfull 2 tbhits 0 time 8 pv h9g7 h0g2 g6g5 i0h0 i9h9 b0c2
info depth 9 seldepth 8 multipv 1 score cp -23 nodes 7079 nps 643545 hashfull 3 tbhits 0 time 11 pv h9g7 h0g2 i9h9 i0h0 c6c5 b0c2 b9c7
info depth 10 seldepth 11 multipv 1 score cp -23 nodes 16758 nps 761727 hashfull 9 tbhits 0 time 22 pv b7e7 h0g2 b9c7 i0h0 h9g7 b2c2 i9h9 h0h6
info depth 11 seldepth 14 multipv 1 score cp -25 nodes 30146 nps 814756 hashfull 13 tbhits 0 time 37 pv h9g7 h0g2 i9h9 i0h0 h7h3 g3g4 b7e7 b2b6 b9c7 b0c2
info depth 12 seldepth 12 multipv 1 score cp -30 nodes 37352 nps 848909 hashfull 18 tbhits 0 time 44 pv h9g7 h0g2 i9h9 i0h0 h7h3 g3g4 b7e7 b0c2 b9c7 a0b0 c6c5
info depth 13 seldepth 13 multipv 1 score cp -23 nodes 42708 nps 837411 hashfull 19 tbhits 0 time 51 pv h9g7 h0g2 i9h9 i0h0 g6g5 h0h4 b9c7 b0c2 h7i7 h4h9 g7h9 c3c4
info depth 14 seldepth 14 multipv 1 score cp -21 nodes 51232 nps 868338 hashfull 22 tbhits 0 time 59 pv h9g7 h0g2 i9h9 i0h0 g6g5 c3c4 c9e7 h0h4 b9c7 g3g4 g5g4 h4g4
info depth 15 seldepth 15 multipv 1 score cp -26 nodes 79299 nps 881100 hashfull 38 tbhits 0 time 90 pv h9g7 h0g2 i9h9 i0h0 g6g5 c3c4 c9e7 b0c2 h7h3 b2a2 b7b3 a0b0 b3c3
info depth 16 seldepth 18 multipv 1 score cp -23 nodes 88252 nps 882520 hashfull 41 tbhits 0 time 100 pv h9g7 h0g2 i9h9 i0h0 g6g5 h0h4 c9e7 b0c2 h7i7 h4h9 g7h9 b2a2 b9c7 a0b0 a9b9
info depth 17 seldepth 18 multipv 1 score cp -23 nodes 106522 nps 895142 hashfull 44 tbhits 0 time 119 pv h9g7 h0g2 i9h9 i0h0 g6g5 c3c4 b7b3 g3g4 g5g4 h0h6 g7f5 h6h5 f5d4
info depth 18 seldepth 18 multipv 1 score cp -18 nodes 139004 nps 902623 hashfull 60 tbhits 0 time 154 pv h9g7 h0g2 i9h9 i0h0 g6g5 b0c2 h7h3 b2a2 b7e7 a0b0 b9c7 b0b6 a9b9 b6c6
info depth 19 seldepth 21 multipv 1 score cp -24 nodes 286049 nps 931755 hashfull 122 tbhits 0 time 307 pv h9g7 h0g2 i9h9 i0h0 g6g5 h0h6 c6c5 b2c2 b9c7 h6g6 b7a7 b0a2 a9b9 a0b0 b9b0 a2b0 h7i7 e3e4
info depth 20 seldepth 27 multipv 1 score cp -21 nodes 414461 nps 952783 hashfull 173 tbhits 0 time 435 pv h9g7 h0g2 i9h9 i0h0 g6g5 h0h6 c6c5 h6g6 b9c7 b2c2 a9b9 b0a2 h7h8 g6g5 c9a7 a0b0 h8g8
info depth 21 seldepth 26 multipv 1 score cp -21 nodes 530263 nps 948592 hashfull 226 tbhits 0 time 559 pv h9g7 h0g2 i9h9 i0h0 g6g5 h0h6 c6c5 b2c2 c9e7 b0a2 b9d8 h6h4 d9e8 a0b0 h7i7 h4d4 b7d7 c3c4 c5c4
info depth 22 seldepth 26 multipv 1 score cp -25 lowerbound nodes 969625 nps 968656 hashfull 385 tbhits 0 time 1001 pv h9g7
bestmove h9g7 ponder h0g2
```
Pikafish plays `1. ... h9g7` and expects `2. h0g2`
```
> position startpos moves h2e2 h9g7 h0g2
> go ponder movetime 1000
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp -8 nodes 47 nps 23500 hashfull 0 tbhits 0 time 2 pv i9h9
info depth 2 seldepth 2 multipv 1 score cp -12 nodes 102 nps 51000 hashfull 0 tbhits 0 time 2 pv i9h9 b0c2
info depth 3 seldepth 3 multipv 1 score cp -15 nodes 151 nps 75500 hashfull 0 tbhits 0 time 2 pv i9h9 b0c2 g6g5
info depth 4 seldepth 4 multipv 1 score cp -23 nodes 321 nps 107000 hashfull 0 tbhits 0 time 3 pv i9h9 g3g4 c6c5 i0h0
info depth 5 seldepth 5 multipv 1 score cp -24 nodes 415 nps 138333 hashfull 0 tbhits 0 time 3 pv i9h9 g3g4 b9c7 c3c4 h7i7 b0c2
info depth 6 seldepth 6 multipv 1 score cp -24 nodes 546 nps 136500 hashfull 0 tbhits 0 time 4 pv i9h9 g3g4 b9c7 c3c4 h7i7
info depth 7 seldepth 8 multipv 1 score cp -15 nodes 855 nps 213750 hashfull 0 tbhits 0 time 4 pv i9h9 g3g4 c6c5 i0h0 b9c7 b0a2
info depth 8 seldepth 9 multipv 1 score cp -17 nodes 1194 nps 238800 hashfull 0 tbhits 0 time 5 pv i9h9 g3g4 c6c5 i0h0 b9c7 b0a2 a9a8 a0a1 a8d8 a1c1
info depth 9 seldepth 9 multipv 1 score cp -17 nodes 1531 nps 306200 hashfull 0 tbhits 0 time 5 pv i9h9 g3g4 c6c5 i0h0 b9c7 b0a2 a9a8 a0a1 a8d8 a1c1
info depth 10 seldepth 10 multipv 1 score cp -17 nodes 2043 nps 340500 hashfull 0 tbhits 0 time 6 pv i9h9 g3g4 c6c5 i0h0 b9c7 b0a2 a9a8 a0a1 a8d8 a1c1
info depth 11 seldepth 12 multipv 1 score cp -16 nodes 3037 nps 433857 hashfull 0 tbhits 0 time 7 pv i9h9 g3g4 c6c5 b0a2 b9c7 i0h0 h7h3 g2f4 b7b3 e2e1 g9e7 a0a1
info depth 12 seldepth 15 multipv 1 score cp -15 nodes 11609 nps 773933 hashfull 3 tbhits 0 time 15 pv i9h9 b2d2 b9c7 b0c2 a9b9 a0b0 c6c5 i0h0 g6g5 h0h6 g9e7
info depth 13 seldepth 17 multipv 1 score cp -16 nodes 20497 nps 788346 hashfull 4 tbhits 0 time 26 pv i9h9 b2d2 b9c7 b0c2 a9b9 a0b0 c6c5 i0h0 g6g5 h0h4 h7i7 h4h9 g7h9
info depth 14 seldepth 18 multipv 1 score cp -15 nodes 30936 nps 736571 hashfull 8 tbhits 0 time 42 pv i9h9 b2d2 b9c7 b0c2 a9b9 a0b0 b7b3 c3c4 g6g5 c2d4 b9b4
info depth 15 seldepth 12 multipv 1 score cp -15 nodes 33116 nps 752636 hashfull 9 tbhits 0 time 44 pv i9h9 b2d2 b9c7 b0c2 a9b9 a0b0 b7b3 c3c4 g6g5 c2d4 b9b4
info depth 16 seldepth 20 multipv 1 score cp -16 nodes 77547 nps 842902 hashfull 34 tbhits 0 time 92 pv i9h9 g3g4 h7i7 b0c2 c6c5 b2a2 b9c7 a0b0 a9b9 b0b6 b7a7 b6b9 c7b9 a2a6 b9c7 a6g6
info depth 17 seldepth 25 multipv 1 score cp -40 nodes 319127 nps 961225 hashfull 156 tbhits 0 time 332 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 b7b6 b0c2 c6c5 h6h4 c5c4 h4c4 b6b8 c2d4 a9a7 d4c6 b8c8 a0a1 a7b7 c6b4 b7a7 c4h4 c8c0 d0e1
info depth 18 seldepth 25 multipv 1 score cp -26 nodes 414450 nps 959375 hashfull 197 tbhits 0 time 432 pv i9h9 i0h0 b9c7 c3c4 g6g5 b0c2 h7h3 b2b4 c9e7 g3g4 c6c5 c4c5 g5g4 c5c6 c7e8 g2i1 h3h6 c2d4 g4g3 e2e6
info depth 19 seldepth 24 multipv 1 score cp -22 nodes 525372 nps 956961 hashfull 245 tbhits 0 time 549 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 g7f5 b0c2 c9e7 h6h4 b7b3 h4f4 b3g3 g0i2 f5g7 a0b0 a9b9 b2b7
info depth 20 seldepth 24 multipv 1 score cp -23 nodes 709594 nps 964122 hashfull 315 tbhits 0 time 736 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 g7f5 b0c2 g9e7 a0a1 a9a8 a1f1 f5g3 f1f7
info depth 21 seldepth 25 multipv 1 score cp -19 nodes 835844 nps 970782 hashfull 369 tbhits 0 time 861 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 g7f5 b0c2 g9e7 h6h4 b7b3 e3e4 f5g3 g2e3 h7h5 e4e5 e6e5 e3d5 b3i3 d5c7
info depth 22 seldepth 34 multipv 1 score cp -24 nodes 1487777 nps 985935 hashfull 588 tbhits 0 time 1509 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 g7f5 b0c2 g9e7 h6h4 b7b3 e3e4 f5g3 g2e3 h7h5 e4e5 e6e5 a0a1 b3c3 e3d5 a9b9 d5c3 b9b3
```
The opponent plays the expected `2. h0g2`
```
> ponderhit
info depth 23 seldepth 27 multipv 1 score cp -23 nodes 1632161 nps 988589 hashfull 624 tbhits 0 time 1651 pv i9h9 i0h0 b9c7 c3c4 g6g5 h0h6 g7f5 b0c2 g9e7 h6h4 b7b3 e3e4 f5g3 a3a4 b3c3 e4e5 e6e5 a0a3 c3c0 d0e1
bestmove i9h9 ponder i0h0
```
Pikafish plays `2. ... i9h9` and expects `3. i0h0`
```
> position startpos moves h2e2 h9g7 h0g2 i9h9 i0h0
> go ponder movetime 1000
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp -31 nodes 54 nps 27000 hashfull 0 tbhits 0 time 2 pv h7h3
info depth 2 seldepth 2 multipv 1 score cp -31 nodes 106 nps 53000 hashfull 0 tbhits 0 time 2 pv h7h3 g3g4
info depth 3 seldepth 4 multipv 1 score cp -29 nodes 203 nps 67666 hashfull 0 tbhits 0 time 3 pv c6c5 h0h4 b9c7 c3c4
info depth 4 seldepth 4 multipv 1 score cp -29 nodes 259 nps 86333 hashfull 0 tbhits 0 time 3 pv c6c5 h0h4 b9c7 c3c4
...
```
</details>
---
## Non-standard commands
### `bench`
This runs a standard search benchmark on a pre-selected assortment of positions. It prints the total combined nodes searched, as well as time taken. This command serves two primary purposes:
* it can be used as a basic nodes-per-second speed benchmark
* the total number of nodes searched can be used as a "signature" or "fingerprint" of the exact search algorithm version in the binary
The main utility of the nodecount signature is to ensure that, when testing possible new patches on Fishtest, the author and workers are working on the exact same code. It also can be used to verify which version or release you have locally. Each functional commit in the Pikafish commit history includes a standardized nodecount signature. (For example, the nodecount signature of [Pikafish 2023-03-05](https://github.com/official-stockfish/Stockfish/commit/876afdd3b610eebc402b478327d0838a4495b3a2) is 1146720.)
There are several parameters which can be used to tweak exactly what sort of benchmark is run:
Usage: `bench [ttSize] [threads] [limit] [fenFile] [limitType]`
The standardized nodecount signature of a version is obtained using all default parameters.
_Note: All parameters are optional._
| Parameter | Type | Default | Values | Meaning |
|-------------|:------:|:---------:|--------------------------------------------------|----------------------------------|
| `ttSize` | number | `16` | | Hash value |
| `threads` | number | `1` | | Number of threads |
| `limit` | number | `13` | | The limit of `limitType` |
| `fenFile` | string | `default` | `default`, `current` or `[file path]` | The positions used for the bench |
| `limitType` | string | `depth` | `depth`, `perft`, `nodes`, `movetime` or `eval`. | The type of limit |
<details>
<summary>Example</summary>
```
> position startpos
> bench 16 1 1 current depth
Position: 1/1 (rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1)
info string NNUE evaluation using pikafish.nnue enabled
info depth 1 seldepth 1 multipv 1 score cp 8 nodes 74 nps 74000 hashfull 0 tbhits 0 time 1 pv b2e2
bestmove b2e2
===========================
Total time (ms) : 4
Nodes searched : 75
Nodes/second : 18750
```
</details>
> [!NOTE]
> * **String parameters are case-sensitive**. In case of invalid values of string parameters, the error is not given, and the behavior is undefined (the program does not fall back to a default value).
> * The `[file path]` may contain **one or more positions**, each on a separate line.
### `d`
Display the current position, with ASCII art and FEN.
<details>
<summary>Example</summary>
```
> d
+---+---+---+---+---+---+---+---+---+
| r | n | b | a | k | a | b | n | r | 9
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | 8
+---+---+---+---+---+---+---+---+---+
| | c | | | | | | c | | 7
+---+---+---+---+---+---+---+---+---+
| p | | p | | p | | p | | p | 6
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | 5
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | 4
+---+---+---+---+---+---+---+---+---+
| P | | P | | P | | P | | P | 3
+---+---+---+---+---+---+---+---+---+
| | C | | | | | | C | | 2
+---+---+---+---+---+---+---+---+---+
| | | | | | | | | | 1
+---+---+---+---+---+---+---+---+---+
| R | N | B | A | K | A | B | N | R | 0
+---+---+---+---+---+---+---+---+---+
a b c d e f g h i
Fen: rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w - - 0 1
Key: FDA3193C470C785C
Checkers:
```
</details>
### `eval`
Display the static evaluation of the current position.
<details>
<summary>Example</summary>
```
> eval
info string NNUE evaluation using pikafish.nnue enabled
NNUE derived piece values:
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| r | n | b | a | k | a | b | n | r |
| -2.49 | -1.05 | -0.34 | -0.31 | | -0.33 | -0.41 | -1.03 | -2.41 |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | | |
| | | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | c | | | | | | c | |
| | -1.48 | | | | | | -1.43 | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| p | | p | | p | | p | | p |
| +0.07 | | -0.07 | | -0.38 | | -0.12 | | -0.00 |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | | |
| | | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | | |
| | | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| P | | P | | P | | P | | P |
| -0.05 | | +0.07 | | +0.25 | | +0.11 | | +0.02 |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | C | | | | | | C | |
| | +1.39 | | | | | | +1.36 | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| | | | | | | | | |
| | | | | | | | | |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
| R | N | B | A | K | A | B | N | R |
| +2.61 | +1.00 | +0.37 | +0.32 | | +0.34 | +0.43 | +1.02 | +2.53 |
+-------+-------+-------+-------+-------+-------+-------+-------+-------+
NNUE network contributions (White to move)
+------------+------------+------------+------------+
| Bucket | Material | Positional | Total |
| | (PSQT) | (Layers) | |
+------------+------------+------------+------------+
| 0 | 0.00 | + 0.24 | + 0.24 |
| 1 | 0.00 | - 0.30 | - 0.30 |
| 2 | 0.00 | + 0.35 | + 0.35 |
| 3 | 0.00 | + 0.20 | + 0.20 |
| 4 | 0.00 | + 0.07 | + 0.07 |
| 5 | 0.00 | + 0.09 | + 0.09 |
| 6 | 0.00 | + 0.07 | + 0.07 |
| 7 | 0.00 | + 0.12 | + 0.12 | <-- this bucket is used
+------------+------------+------------+------------+
NNUE evaluation +0.12 (white side)
Final evaluation +0.20 (white side) [with scaled NNUE, optimism, ...]
```
</details>
### `compiler`
Give information about the compiler and environment used for building a binary.
### `export_net [filename]`
Exports the currently loaded network to a file.
If the currently loaded network is the embedded network and the filename is not specified then the network is saved to the file matching the name of the embedded network, as defined in `evaluate.h`.
If the currently loaded network is not the embedded network (some net set through the UCI `setoption`) then the filename parameter is required and the network is saved into that file.
### `flip`
Flips the side to move.
+1
View File
@@ -0,0 +1 @@
[pikafish.org](https://pikafish.org/)
Binary file not shown.