--- gnushogi-1.3.2.orig/doc/gnushogi.info +++ gnushogi-1.3.2/doc/gnushogi.info @@ -1,6 +1,11 @@ -This is gnushogi.info, produced by makeinfo version 4.3 from +This is gnushogi.info, produced by makeinfo version 4.13 from gnushogi.texinfo. +INFO-DIR-SECTION Games +START-INFO-DIR-ENTRY +* gnushogi: (gnushogi). Japan chess +END-INFO-DIR-ENTRY + This file describes how to use GNU shogi, a program which plays Shogi (Japanese chess). @@ -22,34 +27,2321 @@ translation approved by the Free Software Foundation.  -Indirect: -gnushogi.info-1: 926 -gnushogi.info-2: 49337 +File: gnushogi.info, Node: Top, Next: (dir), Prev: (dir), Up: (dir) + +GNU Shogi (Japanese chess) +************************** + +* Menu: + +* Introduction:: What is GNU shogi? +* License:: The GNU General Public License. +* About shogi:: General information, rules, etc. +* gnushogi:: How to play GNU shogi (gnushogi). +* xshogi:: The X interface to GNU shogi. +* References and links:: Where to go for more information. +* Acknowledgements:: +* Bugs:: Where and how to report bugs. +* Index:: + + +File: gnushogi.info, Node: Introduction, Next: License, Prev: Top, Up: Top + +1 Introduction +************** + +GNU shogi is a program that plays shogi, the Japanese version of chess, +against a human (or computer) opponent. This file describes how to use +GNU shogi and also gives background information about the game of shogi. + + This file describes GNU shogi version 1.3.2. It was written by me, +Mike Vanier, the current maintainer of GNU shogi. My email address is +. + + GNU shogi is actually two programs: + + +`gnushogi' + is the text-based program which also contains the game-playing + engine. + +`xshogi' + is the X-windows graphical interface to gnushogi. + + + + Since xshogi invokes gnushogi, most players will just type "xshogi" +and start playing. + + Disclaimer: I use the personal pronouns "him", "his" etc. to refer +to a shogi player regardless of gender. That's easier than writing +"his or her" all over the place. I don't mean to infer that women +don't play shogi; in fact shogi is very popular in Japan among women as +well as men. + + +File: gnushogi.info, Node: License, Next: About shogi, Prev: Introduction, Up: Top + +GNU GENERAL PUBLIC LICENSE +************************** + + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +Preamble +======== + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, +and (2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + 0. This License applies to any program or other work which contains a + notice placed by the copyright holder saying it may be distributed + under the terms of this General Public License. The "Program", + below, refers to any such program or work, and a "work based on + the Program" means either the Program or any derivative work under + copyright law: that is to say, a work containing the Program or a + portion of it, either verbatim or with modifications and/or + translated into another language. (Hereinafter, translation is + included without limitation in the term "modification".) Each + licensee is addressed as "you". + + Activities other than copying, distribution and modification are + not covered by this License; they are outside its scope. The act + of running the Program is not restricted, and the output from the + Program is covered only if its contents constitute a work based on + the Program (independent of having been made by running the + Program). Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's + source code as you receive it, in any medium, provided that you + conspicuously and appropriately publish on each copy an appropriate + copyright notice and disclaimer of warranty; keep intact all the + notices that refer to this License and to the absence of any + warranty; and give any other recipients of the Program a copy of + this License along with the Program. + + You may charge a fee for the physical act of transferring a copy, + and you may at your option offer warranty protection in exchange + for a fee. + + 2. You may modify your copy or copies of the Program or any portion + of it, thus forming a work based on the Program, and copy and + distribute such modifications or work under the terms of Section 1 + above, provided that you also meet all of these conditions: + + a. You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b. You must cause any work that you distribute or publish, that + in whole or in part contains or is derived from the Program + or any part thereof, to be licensed as a whole at no charge + to all third parties under the terms of this License. + + c. If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display + an announcement including an appropriate copyright notice and + a notice that there is no warranty (or else, saying that you + provide a warranty) and that users may redistribute the + program under these conditions, and telling the user how to + view a copy of this License. (Exception: if the Program + itself is interactive but does not normally print such an + announcement, your work based on the Program is not required + to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the + Program, and can be reasonably considered independent and separate + works in themselves, then this License, and its terms, do not + apply to those sections when you distribute them as separate + works. But when you distribute the same sections as part of a + whole which is a work based on the Program, the distribution of + the whole must be on the terms of this License, whose permissions + for other licensees extend to the entire whole, and thus to each + and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or + contest your rights to work written entirely by you; rather, the + intent is to exercise the right to control the distribution of + derivative or collective works based on the Program. + + In addition, mere aggregation of another work not based on the + Program with the Program (or with a work based on the Program) on + a volume of a storage or distribution medium does not bring the + other work under the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms + of Sections 1 and 2 above provided that you also do one of the + following: + + a. Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of + Sections 1 and 2 above on a medium customarily used for + software interchange; or, + + b. Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange; or, + + c. Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with + such an offer, in accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete + source code means all the source code for all modules it contains, + plus any associated interface definition files, plus the scripts + used to control compilation and installation of the executable. + However, as a special exception, the source code distributed need + not include anything that is normally distributed (in either + source or binary form) with the major components (compiler, + kernel, and so on) of the operating system on which the executable + runs, unless that component itself accompanies the executable. + + If distribution of executable or object code is made by offering + access to copy from a designated place, then offering equivalent + access to copy the source code from the same place counts as + distribution of the source code, even though third parties are not + compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt + otherwise to copy, modify, sublicense or distribute the Program is + void, and will automatically terminate your rights under this + License. However, parties who have received copies, or rights, + from you under this License will not have their licenses + terminated so long as such parties remain in full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify + or distribute the Program or its derivative works. These actions + are prohibited by law if you do not accept this License. + Therefore, by modifying or distributing the Program (or any work + based on the Program), you indicate your acceptance of this + License to do so, and all its terms and conditions for copying, + distributing or modifying the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program + subject to these terms and conditions. You may not impose any + further restrictions on the recipients' exercise of the rights + granted herein. You are not responsible for enforcing compliance + by third parties to this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent + issues), 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 distribute so as to satisfy simultaneously + your obligations under this License and any other pertinent + obligations, then as a consequence you may not distribute the + Program at all. For example, if a patent license would not permit + royalty-free redistribution of the Program by all those who + receive copies directly or indirectly through you, then the only + way you could satisfy both it and this License would be to refrain + entirely from distribution of the Program. + + If any portion of this section is held invalid or unenforceable + under any particular circumstance, the balance of the section is + intended to apply and the section as a whole is intended to apply + in other circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of + any such claims; this section has the sole purpose of protecting + the integrity of the free software distribution system, which is + implemented by public license practices. Many people have made + generous contributions to the wide range of software distributed + through that system in reliance on consistent application of that + system; it is up to the author/donor to decide if he or she is + willing to distribute software through any other system and a + licensee cannot impose that choice. + + This section is intended to make thoroughly clear what is believed + to be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, + the original copyright holder who places the Program under this + License may add an explicit geographical distribution limitation + excluding those countries, so that distribution is permitted only + in or among countries not thus excluded. In such case, this + License incorporates the limitation as if written in the body of + this License. + + 9. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such + new versions will be similar in spirit to the present version, but + may differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the + Program specifies a version number of this License which applies + to it and "any later version", you have the option of following + the terms and conditions either of that version or of any later + version published by the Free Software Foundation. If the Program + does not specify a version number of this License, you may choose + any version ever published by the Free Software Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the + author to ask for permission. For software which is copyrighted + by the Free Software Foundation, write to the Free Software + Foundation; we sometimes make exceptions for this. Our decision + will be guided by the two goals of preserving the free status of + all derivatives of our free software and of promoting the sharing + and reuse of software generally. + + NO WARRANTY + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE + LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT + HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT + WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT + NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE + QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE + PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY + SERVICING, REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY + MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE + LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, + INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR + INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF + DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU + OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY + OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN + ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS +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 +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + ONE LINE TO GIVE THE PROGRAM'S NAME AND A BRIEF IDEA OF WHAT IT DOES. + Copyright (C) 19YY NAME OF AUTHOR + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + Also add information on how to contact you by electronic and paper +mail. + + If the program is interactive, make it output a short notice like +this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19YY NAME OF AUTHOR + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details + type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the +appropriate parts of the General Public License. Of course, the +commands you use may be called something other than `show w' and `show +c'; they could even be mouse-clicks or menu items--whatever suits your +program. + + You should also get your employer (if you work as a programmer) or +your school, if any, to sign a "copyright disclaimer" for the program, +if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + SIGNATURE OF TY COON, 1 April 1989 + Ty Coon, President of Vice + + This 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 Library General Public License instead of this License. + + +File: gnushogi.info, Node: About shogi, Next: gnushogi, Prev: License, Up: Top + +2 About the game of shogi +************************* + + "Japanese chess cedes nothing in depth or beauty to the European + game... it is at least as interesting." + + -- Alexander Alekhine + (quoted in David Pritchard, `The Encyclopedia of Chess Variants') + + + "... shogi [is] by far the most complex form of chess that has ever + achieved widespread popularity." + + -- R. Wayne Schmittberger, `New Rules for Classic Games' + + + Shogi is the version of chess played in Japan. It is strikingly +different from standard chess (which I shall refer to henceforth as +"international chess") and also to all other regional variants, because +captured pieces can re-enter play on the side of the capturer. This +has several interesting effects on the play of the game: + + + 1. Shogi is much more complex than international chess, at least in + terms of the average number of possible moves per turn (estimated + at about 35 for chess and at about 80 for shogi). + + 2. There are almost no draws (about 1-2% of all games in professional + play). + + 3. Exchanges complicate the play rather than simplifying it. + + 4. There are no "endgames" in the standard chess sense; all pieces + remain in play throughout the game. Games typically end in a race + to checkmate the other player before being checkmated oneself. + + 5. Ownership of a piece is not indicated by the color of the piece; + instead, pieces are wedge-shaped and point towards the opponent. + The name of the piece is inscribed in Kanji characters on the + front of the piece. + + 6. Most importantly: it's more fun than other forms of chess :-) + + + + Shogi is extremely popular in Japan; it has been estimated that 20 +million Japanese can play shogi, of which perhaps 1 million are active +players. It is even more popular there than the game of go, Japan's +other favorite board game. There are a number of professional players +who make a considerable amount of money playing in shogi tournaments, +and the game receives extensive newpaper and television coverage. +Despite this, the game has yet to become popular outside of Japan. Part +of this is because the Kanji characters on the pieces scare away some +people, but mostly it's due, I think, to lack of exposure to the game +and to the difficulty of finding opponents. I hope that GNU shogi will +help introduce shogi to a wider audience. + +* Menu: + +* The rules of shogi:: +* Sample game:: +* Mating problems:: +* Shogi variants:: +* Differences between shogi and chess:: + + +File: gnushogi.info, Node: The rules of shogi, Next: Sample game, Prev: About shogi, Up: About shogi + +2.1 The rules of shogi +====================== + +Shogi is a two-person abstract strategy board game with full information +(i.e. all pieces and moves are visible to both players at all times). +It is in the chess family, being descended from the same ancestral game +as international chess: the Indian game of Chaturanga. The two players +are referred to as "Black" and "White", with Black moving first (unlike +in international chess, where White moves first), and with movement +alternating between the two players. Note that "Black" and "White" are +just names; the pieces are not colored. Instead, they are flat, +wedge-shaped pieces which point towards the opponent. The identity of +a given piece is indicated by two Japanese Kanji characters on each +piece. In fact, only the top character is needed to identify the piece +and thus only the top character is used in shogi diagrams. I will use +alphabetical equivalents in the diagrams here; to see what the Kanji +characters look like, start up xshogi (*note xshogi::) and compare the +starting setup there with the starting setup in this file (*note The +opening setup::). + + The object of the game is to capture the opponent's King. The board +is a grid of 9x9 uncolored squares, and pieces are placed on the +squares. Each player begins with 20 pieces, described in the next +section. Capture is by displacement, as in international chess. + +* Menu: + +* The moves of the pieces:: +* The opening setup:: +* Promotion of pieces:: +* Drops:: +* Winning the game:: +* Draws:: +* Handicaps:: +* Notes for chess players:: + + +File: gnushogi.info, Node: The moves of the pieces, Next: The opening setup, Prev: The rules of shogi, Up: The rules of shogi + +2.1.1 The moves of the pieces +----------------------------- + +Each player at the beginning of a shogi game has a total of 20 pieces of +eight different types. The moves of the shogi pieces can be divided +into three classes: "stepping" pieces, that only move one square at a +time; "ranging" pieces that move any number of unobstructed squares in +a line, and "jumping" pieces that can jump over obstructing pieces to +reach their destination squares. Most pieces can also promote to +different (usually stronger) pieces under certain circumstances (see the +next section). All pieces capture the same way that they move (even +pawns). The piece moves and promotions are as follows; each piece name +is followed by the standard piece abbreviation: + + 1. The king (K). The king can move one square in any horizontal, + vertical, or diagonal direction, just like the king in + international chess. The king does not promote. + + 2. The rook (R). The rook can move any number of squares in a + horizontal or vertical direction. The rook is the same as the + rook in international chess (except that it can promote). A rook + promotes to a "dragon king" or "dragon" for short (often just + referred to as a "promoted rook"), which can move as a rook or can + move one square in any diagonal direction. + + 3. The bishop (B). The bishop can move any number of squares in a + diagonal direction. The bishop is the same as the bishop in + international chess (except that it can promote). A bishop + promotes to a "dragon horse" or "horse" for short (often just + referred to as a "promoted bishop"), which can move as a bishop or + can move one square in any horizontal or vertical direction. + Note: the horse should not be confused with a knight (see below), + as they are two completely different pieces. + + 4. The gold general (G). A gold general can move one square in any + horizontal or vertical direction, or one square in a forward + diagonal direction. Gold generals do not promote. + + 5. The silver general (S). A silver general can move one square in + any diagonal direction, or one square straight forward. A silver + general promotes to a gold general. + + 6. The knight (N). A knight can move one square straight forward + followed by one square to either forward diagonal, jumping over + intervening pieces if any. In other words, a knight moves like + its international chess counterpart, but forward only. A knight + promotes to a gold general. The knight is the only jumping piece, + as in chess. + + 7. The lance (L). A lance can move any number of squares straight + forward. A lance promotes to a gold general. + + 8. The pawn (P). A pawn can move one square straight forward. The + pawn captures the same way that it moves, in contrast to + international chess. There is also no initial two-space move for + pawns and no _en-passant_ capture. A pawn promotes to a gold + general; a promoted pawn is usually known as a "Tokin". + + + +File: gnushogi.info, Node: The opening setup, Next: Promotion of pieces, Prev: The moves of the pieces, Up: The rules of shogi + +2.1.2 The opening setup +----------------------- + +The opening setup for shogi is as follows: + + 9 8 7 6 5 4 3 2 1 ++--------------------------------------------+ +| wL | wN | wS | wG | wK | wG | wS | wN | wL | a ++--------------------------------------------+ +| | wR | | | | | | wB | | b ++--------------------------------------------+ +| wP | wP | wP | wP | wP | wP | wP | wP | wP | c ++--------------------------------------------+ +| | | | | | | | | | d ++--------------------------------------------+ +| | | | | | | | | | e ++--------------------------------------------+ +| | | | | | | | | | f ++--------------------------------------------+ +| bP | bP | bP | bP | bP | bP | bP | bP | bP | g ++--------------------------------------------+ +| | bB | | | | | | bR | | h ++--------------------------------------------+ +| bL | bN | bS | bG | bK | bG | bS | bN | bL | i ++--------------------------------------------+ + + + Here, "b" stands for "black" and "w" stands for "white", so that, +for instance, "bL" means "black lance". The numbers above the files +and the letters to the right of the ranks represent the most common +notation system used for shogi by westerners (the Japanese also use +Arabic numerals for the files but use Japanese numerals for the ranks). + + +File: gnushogi.info, Node: Promotion of pieces, Next: Drops, Prev: The opening setup, Up: The rules of shogi + +2.1.3 Promotion of pieces +------------------------- + +In sharp contrast to international chess, where only pawns can promote +to higher-ranked pieces, most of the pieces in shogi can promote. The +promoted ranks are discussed in the section on piece moves (*note The +moves of the pieces::) but are repeated here for reference: + +Pawn + promotes to gold general (called a `tokin' in this case only). + +Lance + promotes to gold general. + +Knight + promotes to gold general. + +Silver general + promotes to gold general. + +Gold general + does not promote. + +Bishop + promotes to "dragon horse" or just "horse" for short. The horse + can move as a bishop or can move one square in any orthogonal + direction. + +Rook + promotes to "dragon king" or just "dragon" for short. The dragon + can move as a rook or can move one square in any diagonal + direction. + +King + does not promote. + + + + The three ranks furthest away from each player constitute his/her +"promotion zone". A player may, but is not required to, promote a +piece after making a move in which the piece begins and/or ends in the +promotion zone. Thus you can promote a piece when moving the piece into +the promotion zone, out of the promotion zone, or entirely within the +promotion zone. Promotion is mandatory in these cases: + + + 1. You must promote a pawn or a lance after moving it to the last + rank. + + 2. You must promote a knight after moving it to either of the last + two ranks. + + + + These forced promotions ensure that a piece cannot be moved to a +square from which it would have no further move. + + Pieces "dropped" onto the board (*note Drops::) always drop in the +unpromoted state, even if they drop into the promotion zone. + + +File: gnushogi.info, Node: Drops, Next: Winning the game, Prev: Promotion of pieces, Up: The rules of shogi + +2.1.4 Drops +----------- + +When a player captures a piece, that piece is not removed from play. +Instead, it becomes the property of the capturer and can re-enter play +by being placed on (almost) any vacant square during the player's move. +This is known as a "drop" and counts as a full move (in other words, +you can either move a piece on the board or drop a piece onto the board +during your move, but not both). All pieces drop in the unpromoted +state. Pieces may be legally dropped in their promotion zone, but they +do not promote on that turn. + + There are several restrictions on drops: + + 1. A pawn may not be dropped onto a file if there is already an + unpromoted pawn belonging to the same player on that file. It is + legal to drop a pawn on a file which contains a _promoted_ pawn + belonging to the same player, however. + + 2. A pawn may not be dropped to give immediate checkmate on the move. + A pawn is, however, permitted to be moved on the board to give + immediate checkmate. This is a curious rule, and if anyone knows + the reason for it I would appreciate it if they would contact me + and explain it to me :-) + + 3. A pawn or piece may not be dropped onto a square from which they + would have no legal move. This means that pawns and lances may + not be dropped onto the last rank, and the knight may not be + dropped onto the last or second-to-last rank. + + + It is entirely permissible (and often advisable) to drop a piece or +pawn between one's King and an attacking ranging piece. For this +reason, the final checkmating move is nearly always an attack on the +King from an adjacent square (except for an attack by a Knight). + + Captured pieces are said to be pieces "in hand". + + The drop is the primary distinguishing feature of Japanese chess, +shared with no other popular chess-type game. It gives shogi a very +aggressive quality, and dramatically increases the number of possible +moves once a few pieces have been captured. Another interesting +feature of shogi is that exchanges complicate play rather than +simplifying it (as in international chess), because of the drop rule. + + +File: gnushogi.info, Node: Winning the game, Next: Draws, Prev: Drops, Up: The rules of shogi + +2.1.5 Winning the game +---------------------- + +A game of shogi is won by capturing the opponent's king. In general, +this is done by checkmating the king: attacking the king in such a way +that the king cannot be defended no matter what the defending player +moves. Note, though, that there is no rule that requires a player to +defend a king which is being attacked. However, if he does not defend +his king, the opponent is entirely free to capture it on the next move, +thus winning the game. As in international chess, in practice most +games end by resignation when one player realizes that he cannot escape +checkmate. + + +File: gnushogi.info, Node: Draws, Next: Handicaps, Prev: Winning the game, Up: The rules of shogi + +2.1.6 Draws +----------- + +There are very few draws in shogi; only about 1-2% of professional games +end in a draw. One reason for this is that material can never be +depleted as in chess, because captured pieces are constantly re-entering +play as a consequence of the drop rule. In fact, most of the ways a +game can be drawn in chess are not allowed in shogi: + + + * Draws cannot be offered. + + * There is no fifty-move rule. + + * A stalemate counts as a win for the stalemater. Stated otherwise: + if you can't move, you lose. + + * Perpetual check is illegal (see below). + + + + There are only two legal ways in which a draw can occur: + + + 1. A position (including the pieces in hand) occurs 4 times with the + same player to move (called "Sennichite"). However, if this is + caused by consecutive checks (direct attacks on the King, + threatening to capture it on the next move) by one side, the + player giving these checks loses the game. In other words, + perpetual check results in a loss for the attacker who recreates + the same position the 4th time. + + 2. Both players have moved their King into the the promotion zone (or + they cannot be prevented from doing so) and the Kings cannot be + checkmated. A King who has entered the promotion zone is known as + an "entering King"; due to the forward orientation of most shogi + pieces, it is very hard to mate such a King. In that case the + players may decide to count their pieces as follows: the King does + not count, the Rook and Bishop count as 5 points, and all other + pieces as one point. Promotion is disregarded. If both players + have at least 24 points the game is a draw (called "Jishogi"). If + a player has less, he loses the game. + + Of course, a player can refuse to count pieces when he still has + mating chances or chances to gain material which would affect the + outcome of the counting. There is no strict rule about what to do + if this is not the case, but nonetheless a player refuses to count + up (e.g. because he does not have enough points for a draw). It + has been generally accepted that in such a case the game ends and + the pieces are counted after one player has managed to get all his + pieces protected in the promotion zone. + + + + +File: gnushogi.info, Node: Handicaps, Next: Notes for chess players, Prev: Draws, Up: The rules of shogi + +2.1.7 Handicaps +--------------- + +Unlike international chess, shogi has a well-established handicap system +which is used when players of different strengths play against each +other. Handicaps range from small to huge, which makes it possible for +weak players to play against even very strong players and have an even +chance of winning. + + Shogi players are ranked as follows: the weakest rank is around 15 +"kyu", which represents a beginner. 14 kyu is higher than 15 kyu, 13 +kyu is higher still, and so on until you get to 1 kyu. The next highest +rank is 1 "dan", followed by 2 dan, 3 dan and so forth. The highest +amateur rank is 6 dan; professionals go up to 9 dan. However, +professional ranks are not the same as amateur ranks; a professional 1 +dan is _much_ stronger than an amateur 1 dan. This system is similar +to that used by go players (and also other Japanese sports such as +karate). + + A handicap consists of the stronger player playing White and removing +one or more pieces from his side of the board at the start of the game. +These pieces are permanently removed from play; they are not in hand. + + The following is a list of the accepted handicaps, from weakest to +strongest. The degree of the handicap, represented by the position in +the list, represents the difference in rank between the two players for +which the handicap is appropriate. These rules are taken from the books +"Shogi for Beginners" by John Fairbairn and "The Art of Shogi" by Tony +Hoskings (*note References and links::) and, I believe, represent +current Japanese practice. + + + 1. The stronger player removes his left lance (on 1a). + + 2. The players play a two-game match; in the first game the stronger + player removes his left lance (on 1a), while in the second game he + removes his bishop. + + 3. The stronger player removes his bishop. + + 4. The stronger player removes his rook. + + 5. The stronger player removes his rook and left lance. + + 6. The players play a two-game match; in the first game the stronger + player removes his rook and left lance (on 1a), while in the + second game he removes his rook and bishop. + + 7. The stronger player removes his rook and bishop. This is usually + called a "two-piece" handicap. + + 8. The stronger player removes his rook, bishop, and both lances. + This is called a "four-piece" handicap. + + 9. The stronger player removes his rook, bishop, both lances, and both + knights. This is called a "six-piece" handicap. + + 10. The stronger player removes his rook, bishop, both lances, both + knights, and both silvers. This is called an "eight-piece" + handicap. + + + + Another advantage of playing handicap games is that the handicaps +alter the optimal strategy for both players. For instance, handicaps +all have their own opening lines which may bear little or no +resemblance to those used in non-handicap shogi. This means that when +learning handicap shogi, you are essentially learning completely new +games which use the same equipment! + + The reader may wonder how on earth a player giving an eight-piece +handicap, say, could possibly hope to win. Don't forget, though, that +in shogi the opponent's pieces can be captured and then become part of +one's own army. Thus, if the opponent plays badly enough, the number of +pieces will soon even out. + + +File: gnushogi.info, Node: Notes for chess players, Prev: Handicaps, Up: The rules of shogi + +2.1.8 Notes for chess players +----------------------------- + +Here are a few miscellaneous things that may confuse chess players. +Some of these have been mentioned elsewhere, but they bear repeating. + + + 1. There is no queen. + + 2. Pawns capture the same way they move. There is no initial + two-space pawn move and no _en-passant_ move. + + 3. There is no special castling move. There _are_ a large number of + possible defensive formations referred to as "castles" (*note + Sample game::) but there is no need for special moves to create + them. + + 4. A given piece can only promote to _one_ other kind of piece. + + + + +File: gnushogi.info, Node: Sample game, Next: Mating problems, Prev: The rules of shogi, Up: About shogi + +2.2 Sample game +=============== + +This game was annotated by Pieter Stouten (*note References and +links::). I have made some minor corrections. Note that captures are +denoted by the "x" symbol e.g. Rx3f and drops are denoted by the "*" +symbol e.g. R*3f. Check is indicated by a "+" after the move, e.g. +R3f+. I recommend you use gnushogi/xshogi to play along with this +game. In xshogi simply hit the "Force Moves" button after starting up, +while in gnushogi enter the word "force" at the prompt. This will +allow you to enter moves for both sides. + + Note also that the move numbering system used here is the chess-type +system where one move means one move by each player. The Japanese count +one move made by each player as two moves. + +-------------------------------------------------------------------------- + + Below you will find (the English translation of) an annotated game +which was published in the Dutch Shogi magazine "81" and in the Dutch +beginners booklet. It has proven to be a very useful game to explain +some basic principles of Shogi. Also, it is a rather straightforward +game compared to professional games where in most cases very diffuse +middle game fights take place. + + Pieter Stouten, 14th May 1990. + +-------------------------------------------------------------------------- + + Black: Michael Trent (1-dan). White: David Murphy (2-dan). + + 1. P2f P3d 2. P2e B3c +[ This move is necessary, as otherwise white can exchange pawns: 3. P2d +Px2d 4. Rx2d. He would thus get a pawn in hand and open up his rook +file. ] + + 3. P7f P4d +[ White closes the bishop diagonal again. He plans to play ranging rook +(the rook goes to 5b, 4b, 3 or 2b; a defensive strategy) and in that +case he'd better avoid an exchange of bishops. One of the reasons is +that he will have problems developing his pieces without leaving holes +for bishop drops. ] + + 4. S4h R3b 5. P3f S4b 6. K6h K6b +[ In general the rook plays an important role in the attacks. It is +wise to move the king away from the area where the initial fights will +be and both players act according to the Shogi proverb "keep the rook +and king apart". ] + + 7. K7h K7b 8. P5f P5d 9. G4i-5h G4a-5b +[ Both players use their second gold general to build their castle. ] + + 10. S6h +[ In itself this move is not bad. However, it will become clear that +black plans a quick attack and in that case it is wiser to omit this +move. ] + + 10... S5c 11. P1f P1d +[ The advance of the edge pawns must be timed very well. The remark at +black's tenth move applies here too: this move is good if black wants to +play a slow game, because it eliminates a future B1e. ] + + 12. P4f K8b 13. N3g S7b +[ Black develops his knight in order to start an attack over the second, +third and fourth files. White strengthens his king's position and +awaits the attack. He aims at a counterattack as soon as black has +broken through into the white camp. Probably white's breakthrough will +take place later, but he has good compensation in the form of a stronger +castle. This theme occurs very often in static rook versus ranging rook +games. ] + + 14. P4e R4b +[ Black starts his attack and white puts up a very passive defence. His +rook has a hard task now to penetrate the black position. Moreover, he +blocks his own bishop. It seems much better to start a counterattack +with 14... P3e, later to be followed by B2b, B5a or Bx4d in order to use +his rook more actively. ] + + 15. Px4d Sx4d 16. P*4e S5c +[ 16... Sx4e is more active. A silver general is normally more valuable +than a knight, but white gets two pawns in hand and black none, while +the knight might come in handy for white too. ] + + 17. Bx3c+ Nx3c 18. P2d Px2d +[ Black threatens to break through and white has to consider taking the +pawn on 2d or starting a counterattack with Nx4e. If he chooses the +latter, black can play Px2c+ followed by +P3c. The disadvantage is the +black "tokin" (=promoted pawn) that white will get in his camp; the +advantage is that it will cost black two more moves to promote his rook. +Because white did not trust that the result after engaging in a +"semeai" (=mutual attack) with 18...Nx4e would give a positive result, +he captured the pawn on 2d. Making the right decision in moments like +this often makes the difference between a win and a loss: miss one +attacking chance and you will be forced to defend the whole game until +the unavoidable defeat; on the other hand, an unsound attack can destroy +all "aji" (=potential, meaning possibilities, threats) without getting +anything in return. ] + + 19. Rx2d Nx4e 20. Nx4e Rx4e 21. R2a+ P*4g +[ Now it becomes clear why black's 10. S6h was not good. Had this move +been omitted, then white would not have had the time to play 13... S7b +and after R2a+ the gold on 6a would hang. Thus black would have kept +"sente" (=initiative). Instead of 21... P*4g, B*6d is a very good +move, because after 22. P*2h black does not have a pawn in hand anymore +and he is being threatened with the annoying 22... N*4f 23. G5g N3h+ +24. S4g +N4h also. Black can also counter 21... B*6d with 22. N*3g. +White would then reply with 22... R4b 23. B*3c P*4g 24. Bx4b+ Sx4b. The +white rook has played its role and instead of spending moves on saving +it white starts to scatter black's defences by successive pawn drops on +the fourth file: 25. Gx4g P*4f 26. G5g N*6e 27. G5h P4g+ 28. Gx4g P*4f. +This analysis was provided by Kato Hifumi, 9-dan professional (the +highest regular grade). Destroying the coherence of the enemy pieces +(their shape) by dropping pawns is one of the most important Shogi +techniques. With the actual move 21... P*4g white missed a good +chance. ] + + 22. Sx4g P*4f 23. B*3g Px4g+ 24. +Rx6a +Px3g +[ 23. B*3g seems pointless, but a closer look reveals that it is +actually quite mean. On move 24 white cannot capture black's "Ryu" +(=dragon =promoted rook) with his silver: 24... Sx6a 25. N*7d K7b 26. +G*8b mate. By attacking the front of the white castle and threatening +to mate him there, black has the chance to break down the white +defences from the side. ] + + 25. +Rx5b S*6b +[ Here 25... B*4d would be much better, because it is defensive and +attacking at the same time. After e.g. 26. G*4c Bx9i+ 27. Gx5c black +threatens 28. +Rx7b Kx7b 29. S*6a K8b 30. S*7a Kx7a 31. G*7b mate. +White is one move quicker, however. He has the following beautiful +"tsume" (mating sequence where every move is check): 27... N*8f 28. Px8f +S*8g 29. Kx8g B*9h 30. K7h Bx8i+ 31. K8g +B8i-8h 32. K9f L*9e mate. +This illustrates the sharpness of Shogi: one move can make the +difference between winning and losing. ] + + 26. P*4f Rx4f +[ This move eliminates white's last chances. 26... R4b 27. +Rx4b Sx4b +28. R*4a seems annoying, but after 28... B*3c 29. S7g B*3b white wins +the rook and with his "tokin" on 3g there still is some hope. ] + + 27. N*6e +P4g +[ White cannot defend anymore, so he starts a desperate attack. Black +does not lose the right track, however. ] + + 28. Nx5c+ +Px5h 29. +Nx6b +Px6h 30. Gx6h N*8f 31. Px8f B*6i 32. +Gx6i R4h+ 33. N*6h +Rx6h 34. Gx6h S*8g 35. Kx8g N*9e 36. K7h +Resigns +[ White resigns here, because after 36... B*8g 27. K7g his attack has +petered out. ] + + +File: gnushogi.info, Node: Mating problems, Next: Shogi variants, Prev: Sample game, Up: About shogi + +2.3 Mating problems +=================== + +One good way to improve at shogi is to solve mating problems. There are +several types of these problems, but the most common is called a +"tsume-shogi" problem, or "tsume" problem for short. In a tsume +problem, all pieces that are not on the board are assumed to be in the +opponent's hand (except for your King, which is usually not shown). +Every move you make must be check until the final checkmate. Your +opponent may play any piece on the board or drop any of his pieces in +hand in order to prevent the mate. In a properly constructed tsume +problem, all of your pieces on the board and in hand must be essential +to the solution. One consequence of this is that all of your pieces in +hand must be played during the solution. There should only be one +correct solution for the given number of moves. Tsume problems use +Japanese-style move numbering; thus, a problem where you move (and give +check), your opponent moves, and you move to give checkmate is called a +three-mover. Here is a really trivial three-mover: + + + 3 2 1 +---------------+ +| | | | a +---------------+ +| | | wK | b +---------------+ +| | | | c +---------------+ +| bN | | | d +---------------+ +| | | | e +---------------+ +| | bN | | f +---------------+ + +Black in hand: S, G + + + Here, Black plays G*2b, White plays K1c, and Black plays G*1d mate. +More typical tsume problems range from 5 moves to arbitrarily high +numbers of moves, and they can be quite brain-busting. Tsume problems +may seem artificial, but in the closing stages of the game where both +players have a lot of pieces in hand, it is often necessary to give +check at every move, or else your opponent will start a counterattack +and will mate you before you mate him. A tsume problem is a worst-case +scenario for the attacker: you have to mate your opponent even though he +has every piece not on the board in hand, which means you have to +develop sharp attacking skills. Many more tsume problems can be found +on the internet; I particularly recommend Patrick Davin's "Shogi Nexus" +(*note References and links::). + + +File: gnushogi.info, Node: Shogi variants, Next: Differences between shogi and chess, Prev: Mating problems, Up: About shogi + +2.4 Shogi variants +================== + +Several historical variants of shogi exist. Most of these were invented +before modern shogi (in some cases hundreds of years before), are much +larger than modern shogi and are not played with drops. Thus, in many +ways they are really more like giant chess games than like modern shogi. +The only one of these games to have survived in Japan is Chu (middle) +shogi, which is still played a little bit. Thanks to the efforts of +George Hodges and John Fairbairn of the Shogi Association (two British +shogi enthusiasts), these games were resurrected and rules and sets for +them can still be purchased from George Hodges (*note References and +links::). I hope to eventually extend GNU shogi so that it can play at +least some of these games. There are also several non-historical +variants of shogi; I don't know much about them but you can find +information about them on the internet (*note References and links::). + + The historical variants include: + + + 1. Tori (bird) shogi, played on a 7x7 board with 32 pieces in all; + this is the only variant that is known to have been played with + drops. + + 2. Wa shogi, played on an 11x11 board with 54 pieces. This game can + be played with or without drops but the historical evidence favors + the view that it was played without drops. However, most people + who have tried it claim it is a much better game with drops, being + even more intricate than standard shogi. + + 3. Chu (middle) shogi, played on a 12x12 board with 92 pieces. This + was (and is) by far the most popular of the variants, and has 21 + different kinds of pieces in the starting line-up alone (along + with several others that appear upon promotion). Unlike modern + shogi, there are a tremendous number of ranging pieces and the + game is definitely not played with drops. There is also an + amazing piece called the Lion which has a double king move and can + capture two pieces at once! Chu shogi has a small but fanatical + following, some of whom consider it better than modern shogi. + + 4. Dai (great) shogi, played on a 15x15 board with 130 pieces. Other + than the larger board, this game is very similar to Chu shogi. + + 5. Tenjiku (exotic) shogi, played on a 16x16 board with 176 pieces. + This game is possibly the most complex tactical game in existence. + There are many astoundingly powerful pieces, including one (the + Fire Demon) that can capture up to eight opposing pieces in a + single move! Despite the size of the game, checkmates can occur + very suddenly (and often very early on) if one player makes a + wrong move. Tenjiku also has a small but fanatical following, one + of whom (Colin Adams) has written a book on the game which is + available for download at + `http://www.colina.demon.co.uk/tenjiku.html'. + + 6. Dai-dai (great-great) shogi, played on a 17x17 board with 192 + pieces. The opening setup alone has 64 different kinds of pieces! + This game and the larger ones that follow sound pretty outlandish, + but they have actually been played; a game of Dai-dai can + supposedly be played in about 12 hours. + + 7. Maka-dai-dai (great-great-great) shogi, played on a 19x19 board + with 192 pieces. For those for whom Dai-dai shogi is just too + small :-) + + 8. Tai (grand) shogi, played on a 25x25 board with 354 pieces! Until + recently, this was thought to be the biggest chess game ever + devised, but now there is... + + 9. Kyoku tai (extremely grand?) shogi, played on a 36x36 board with + 402 pieces. The rules for this have just been unearthed in an old + Japanese book. Hopefully someone will soon organize a postal + Kyoku tai shogi championship; maybe their distant ancestors could + finish it :-) + + It is thought that the really huge games (Dai-dai and up) were + never really played to any significant extent (gee, wonder why?) + and were devised merely so that the creators could have the fun of + inventing enormous games, amazing their friends and confounding + their enemies. However, the games up to Tenjiku shogi at least + appear to be quite playable, assuming one has the time. + + + + +File: gnushogi.info, Node: Differences between shogi and chess, Prev: Shogi variants, Up: About shogi + +2.5 Differences between shogi and chess +======================================= + +Some differences between shogi and international chess have been +mentioned elsewhere in this document; I summarize them here for people +who are interested in game comparisons. I won't try to deal with the +thorny question of which game is "better" although my bias may have +already come through :-) In fact, the drop rule makes the two games so +different in character that arguing over which game is better is like +comparing apples to oranges (you'd be better off comparing chess to Chu +shogi (*note Shogi variants::). However, I believe that if you are a +chess fan you'll really like shogi as well, and shogi is also popular +with many people who don't particularly like chess. + + Here are the significant differences between chess and shogi: + + + 1. In shogi, captured pieces become the property of the capturer and + can re-enter play by being dropped onto almost any vacant square. + In chess, captured pieces are out of the game. Thus, in shogi, + piece exchanges complicate the play significantly while in chess + they simplify it. + + 2. The shogi board is 9x9; the chess board is 8x8. + + 3. Shogi has five pieces with no counterpart in chess: the gold and + silver generals, the lance, the promoted rook and the promoted + bishop. Chess has one piece with no counterpart in shogi: the + queen. The knight's move in shogi is much more restrictive than + in chess. Pieces in shogi generally have a much smaller range of + movement than in chess (unless they are in hand). + + 4. In shogi, all pieces except the gold general and the king can + promote, but only to one kind of piece. Promotion is easier in + shogi because the promotion zone is closer to the starting + position of the pieces (especially pawns). In chess, only the + pawn can promote, but it can promote to any other piece except the + king. + + 5. In shogi, pawns capture the same way they move. There is no + initial two-space pawn move and hence no _en-passant_ captures. + In chess, pawns capture diagonally which means that opposing pawns + can block each other. + + 6. In shogi, you only have one rook and one bishop. Note that the + bishop is not restricted to only one "color" square (squares in + shogi aren't colored, but never mind) because promoted bishops can + also move one square orthogonally. + + 7. There is no special castling move in shogi. The term "castle" is + used in shogi to denote a defensive formation consisting of + (usually) three generals which protect the king. There are many + such castles (about 40 or so have names). *Note Sample game::. + + 8. Draws are much rarer in shogi than in chess. Perpetual check is + not allowed. Stalemate is a virtual impossibility, and is a loss + for the stalematee. + + 9. Since pieces are never out of play in shogi, chess-type endgames + involving only a few pieces do not occur. + + 10. Shogi games are generally longer than chess games (about 60-70 + moves is typical). + + 11. Shogi has a well-developed handicap system which is in general use; + chess does not. + + + + The effects of all these differences on play include (in my opinion): + + + 1. Piece/pawn structures in chess are more rigid than in shogi. Pawns + block each other and pawns, once advanced, cannot ever retreat. In + shogi, you can repair the hole caused by a pawn advance by + exchanging the pawn and dropping it back where you want it. Thus + shogi is more fluid than chess and less "structural". + + 2. Counterattack is MUCH more common in shogi than in chess. Games + typically end in mutual mating attacks, where each player is + trying to checkmate the other player before being checkmated + himself. This makes tempo incredibly important and also makes + sacrificial play quite common. + + 3. Attacks involving only ranging pieces are more a feature of chess + than of shogi. A shogi attack typically uses a ranging piece or + pieces to support an attack by short-range pieces (especially + generals). It is very rare to mate a king with a non-adjacent + ranging piece in shogi since the player whose king is threatened + can almost always interpose by dropping a piece. + + + + +File: gnushogi.info, Node: gnushogi, Next: xshogi, Prev: About shogi, Up: Top + +3 gnushogi +********** + +This section describes how to run the "gnushogi" program. + + + SYNOPSIS + + + gnushogi [ [[-]a] [-b bookfile] [-B binbookfile] [-C] [-h langfile] +[-L langfile] [-r length] [-R] [-s pathname] [-l pathname] [-S +binbooksize] [-t] [-c size] [-T size] [-v] [-x] [-X] arg1 arg2 ] + + + DESCRIPTION + + + GNU shogi (gnushogi) plays a game of japanese chess (shogi) against +the user or it plays against itself. + + At startup gnushogi reads the binbook file if it is present. It then +looks for a book file. If it is present it adds its contents to the +binbook data. If the binbook file is writable a new combined binbook +file is written. + + Gnushogi is a modified version of the gnuchess program. It has a +simple alphanumeric board display, or it can be used with the xshogi +program under X windows. The program gets its opening moves from the +file gnushogi.bbk which is located in a directory specified in the +Makefile. To invoke the program type: + + +`gnushogi -C' + simple curses based version + +`gnushogi -X (or just gnushogi)' + xshogi compatible version + +`gnushogi -R' + raw test display version + + + TIME CONTROLS + + + If one argument is given, it is the search time per move in +[minutes:]seconds. So gnushogi 30 will generate one move every 30 +seconds, while gnushogi 5:00 will generate one move every 5 minutes. + + If two or more arguments are given, they will be used to set +tournament time controls with the first argument of each pair being the +number of moves and the second being the total clock time in +minutes[:seconds]. Thus, entering gnushogi 60 5 will set the clocks +for 5 minutes (300 seconds) for the first 60 moves, and gnushogi 30 +3:30 will allow 3 minutes and 30 seconds for 30 moves. + + gnushogi 30 5 1 :30 will allow 5 minutes for the first 30 moves and +30 seconds for each move after that. Up to 4 pairs of controls may be +specified. + + If no argument is given the program will prompt the user for level of +play. + + For use with xshogi see the documentation on that program. *Note +xshogi::. + + + BOOK + + + The book gnushogi.tbk consists of a sequence of openings. An opening +begins with a line starting with a # (the rest of the line is a +comment). Following this is a series of moves in algebraic notation +alternating between black and white separated by whitespace. A move +may have a ? after it indicating this move should never be made in +this position. Moves are stored as position:move so transpositions +between openings can take place. + + + HASHFILE + + + The hashfile if created should be on the order of 4 megabytes; you +can create such a hashfile by typing "gnushogi -c 22" (see below). This +file contains positions and moves learned from previous games. If a +hashfile is used the computer makes use of the experience it gained in +past games. Tests run so far show that it plays no worse with the +hashfile than without, but it is not clear yet whether it provides a +real advantage. + + + LEGAL MOVES + + + Note: Piece letters are determined by the language file. What is +specified here is the default (English). + + Once gnushogi is invoked, the program will display the board and +prompt the user for a move. To enter a move, use the notation 7g7f +where the first letter-number pair indicates the origin square and the +second letter-number pair indicates the destination square. An +alternative is to use the notation P7f where the first letter indicates +the piece type (P,L,N,S,G,B,R,K). To promote append a + the type of +the new piece to the move, as in 2d2c+ or P2c+. Note that you must use +capital letters for the pieces by default. + + + COMMAND-LINE OPTIONS + + +`-a' + Do not search on opponent's time. + +`a' + Do search on opponent's time. + +`-b BOOKFILE' + Use bookfile for opening book. + +`-B BINBOOKFILE' + Use binbookfile for binary opening book. + +`-c SIZE' + Create a new HASHFILE. File size is 2^size entries of + approximately 65+? bytes. + +`-C' + Use curses-based display mode. + +`-h' + Do not use hashfile. + +`h' + Do use hashfile. + +`-l PATHNAME' + Pathname of the loadfile used with get or xget. + +`-L LANG' + Use language lang from the file gnushogi.lang. If -L is not + specified it uses the first language in the file. + +`-P PLYLEVELS' + Number of plys to include in the binbookfile. For generating a + binbookfile. + +`-r LENGTH' + Rehash _length_ times in searching entries for position in + transposition table. + +`-R' + Use raw text display mode. This can be used for dumb terminals or + for systems that don't have curses. + +`-s PATHNAME' + Pathname of the save file to use with the save command. + +`-S SIZE' + Size of binbookfile for memory based books. For creating a + binbookfile. + +`-t' + Show statistics for HASHFILE. + +`-T SIZE' + Set the transposition table size to 2^size entries. + +`-v' + Show version and patchlevel. + +`-x VALUE' + Use value as the evaluation window xwndw. + +`-X' + Use xshogi display mode (the default). + + + + COMMANDS + + + In addition to legal moves, the following commands can be entered at +the gnushogi prompt. Note: command names are determined by the language +file and may vary with the implementation. The default language is +English. + +`alg' + allow algebraic input (not implemented). + +`Awindow' + change Alpha window (default score + 90). + +`Bwindow' + change Beta window (default score - 90). + +`beep' + toggles beeping after each move (default: on). + +`bd' + updates the current board position on the display. + +`book' + turns off use of the opening library. + +`both' + causes the computer to play both sides of a shogi game. + +`black' + causes the computer to play as White, if the computer was to move + first. + +`bsave' + saves a game to disk as a book textfile. The program will prompt + the user for a file name. + +`gamein' + toggles game mode time control. Assumes the time specified for + time control is the time for a complete game. Input with the + level command should be the game time and the expected number of + moves in a game. go command must be given. + +`coords' + show coordinates on the display (visual only). + +`contempt' + allows the value of _contempt_ to be modified. + +`debug' + asks for a piece as color piece, as wb or bn, and shows its + calculated value on each square. + +`debuglevel' + sets level of debugging output if compiled with debug options. + +`depth' + allows the user to change the search depth of the program. The + maximum depth is 29 ply. Normally the depth is set to 29 and the + computer terminates its search based on elapsed time rather than + depth. If depth is set to (say) 4 ply, the program will search + until all moves have been examined to a depth of 4 ply (with + extensions up to 11 additional ply for sequences of checks and + captures). If you set a maximum time per move and also use the + depth command, the search will stop at the specified time or the + specified depth, whichever comes first. + +`easy' + toggles easy mode (thinking on opponents time) on and off. The + default is easy mode ON. If easy mode is disabled, the keyboard + is polled for input every so often and when input is seen the + search is terminated. It may also be terminated with a sigint. + +`edit' + allows the user to set up a board position. + - # clear the board. + + - c toggle piece color. + + - . command will exit setup mode. + + - p3b place a pawn on 3b + + - p3b+ place a promoted pawn on 3b + + - p* place a pawn in hand (among the captured pieces) + + + Pieces are entered by typing a letter (p,l,n,s,g,b,r,k) for the + piece followed by the coordinate. Here, letter case is ignored. + + The usual warning about the language file applies. + +`exit' + exits gnushogi. + +`first' + tells the computer to move first. Computer begins searching for a + move. (same as "go"). + +`force' + allows the user to enter moves for both sides. To get the program + to play after a sequence of moves has been entered use the "black" + or "white" commands. + +`get' + retrieves a game from disk. The program will prompt the user for + a file name. + +`go' + tells the computer to move first. Computer begins searching for a + move. (same as "first"). + +`hash' + use/don't use hashfile. + +`hashdepth' + allows the user to change the minimum depth for using the hashfile + and the number of moves from the beginning of the game to use it. + +`help' + displays a short description of the commands and the current + status of options. + +`hint' + causes the program to supply the user with its predicted move. + +`level' + allows the user to set time controls such as 60 moves in 5 minutes + etc. In tournament mode, the program will vary the time it takes + for each move depending on the situation. If easy mode is + disabled (using the "easy" command), the program will often + respond with its move immediately, saving time on its clock for + use later on. + +`list' + writes the game moves and some statistics on search depth, nodes, + and time to the file "shogi.lst". + +`material' + toggle material flag - draws on no pawns and both sides < rook. + +`new' + starts a new game. + +`p' + evaluates the board and shows the point score for each piece. The + total score for a position is the sum of these individual piece + scores. + +`post' + causes the program to display the principal variation and the score + during the search. A score of 100 is equivalent to a 1 pawn + advantage for the computer. + +`quit' + exits the game. + +`random' + causes the program to randomize its move selection slightly. + +`rcptr' + set recapture mode. + +`remove' + backout the last level for both sides. Equal to 2 undo's. + +`reverse' + causes the board display to be reversed. That is, the Black's + pieces will now appear at the top of the board. + +`rv' + reverse board display. + +`save' + saves a game to disk. The program will prompt the user for a file + name. + +`switch' + causes the program to switch places with the opponent and begin + searching. + +`test' + performs some speed tests for MoveList and CaptureList generation, + and ScorePosition position scoring for the current board. + +`time' + set computer's time remaining, intended for synchronizing clocks + among multiple players. + +`tsume' + toggle tsume mode. In tsume mode, not all possible moves will be + generated. If a king is in check, only moves that get the king out + of check are generated. If the king is not in check, only moves + that give check to the opponent's king are generated. + +`undo' + undoes the last move whether it was the computer's or the human's. + You may also type "remove". This is equivalent to two "undo"'s + (e.g. retract one move for each side). + +`white' + causes the computer to play as Black; if the computer is to move + first the go command must be given. + +`xget' + read an xshogi position file. + +`xsave' + save as an xshogi position file. + +`xwndw' + change X window. The window around alpha/beta used to determine + whether the position should be scored or just estimated. Note: + this has _nothing_ to do with xshogi or X windows; the terms are + completely separate. + + + + +File: gnushogi.info, Node: xshogi, Next: References and links, Prev: gnushogi, Up: Top + +4 xshogi +******** + +This section describes how to run the "xshogi" program. + + + SYNOPSIS + + + xshogi [ options ] + + + DESCRIPTION + + + xshogi provides an X11/Xt/Athena Widgets user interface for gnushogi. +With xshogi you can play gnushogi, set up arbitrary positions, force +variations, or watch xshogi manage a game between two shogi programs. +Furthermore, it can be used as an interface between two players on +different displays. + + xshogi can also be used as a shogi board to play out games. It will +read through a game file or allow a player to play through a variation +manually (force mode). This is useful for keeping track of email postal +games or browsing games off the net. + + After starting xshogi, you can make moves by pressing mouse button 1 +while the cursor is over a square with your piece on it and dragging the +mouse to another square. If the move is illegal, gnushogi will not +allow it. xshogi will then retract the move. + + + COMMAND-LINE OPTIONS + + + The following command line options also correspond to X resources +that you can set in your .Xdefaults file. + + +`[standard Xt options]' + xshogi accepts standard Xt options like -display, -geometry, and + -iconic. + +`-tc or -timeControl minutes[:seconds]' + Amount of time for a set of moves determined by movesPerSession. + If this number of moves is played within the time control period, + xshogi resets the time clocks. Default: 5 minutes. + +`-mps or -movesPerSession moves' + Number of moves in a time control period. Default: 40 moves. + +`-st or -searchTime minutes[:seconds]' + Tell gnushogi to spend at most the given amount of time searching + for each of its moves. Without this option, gnushogi chooses its + search time based on the number of moves and amount of time + remaining until the next time control. Setting this option also + sets -clockMode to False. + +`-sd or -searchDepth number' + Tell gnushogi to look ahead at most the given number of moves when + searching for a move to make. Without this option, gnushogi + chooses its search depth based on the number of moves and amount + of time remaining until the next time control. Setting this + option also sets -clockMode to False. + +`-clock or -clockMode (True | False)' + Determines whether or not to use the clock. If clockMode is + False, the clock does not run, but the side that is to play next + is still highlighted. + +`-td or -timeDelay seconds' + Time delay between moves during "Load Game". This doesn't have to + be a round number. Try -td 0.4. Default: 1 second. + +`-nsp or -noShogiProgram (True | False)' + If this option is True, xshogi acts as a passive shogi board; it + does not try to start a shogi program, not even to check whether + moves made in Force mode are legal. It also sets -clockMode to + False. Default: False. + +`-fsp or -firstShogiProgram program' + Name of first shogi program. In matches between two machines, this + program plays white. Default: "gnushogi". + +`-ssp or -secondShogiProgram program' + Name of second shogi program, if needed. In matches between two + machines, this program plays black; otherwise it is not started. + Default: "gnushogi". + +`-fh or -firstHost host' + Name of host the first shogi program plays on. Default: + "localhost". + +`-sh or -secondHost host' + Name of host the second shogi program plays on. Default: + "localhost". + +`-rsh or -remoteShell shell_name' + Some systems do not use rsh as the remote shell. This option + allows a user to name the remote shell command. This should be + done in the resource file. + +`-mm or -matchMode (False | Init | Position | Opening)' + Automatically run a game between firstShogiProgram and + secondShogiProgram. If matchMode is set to Init, xshogi will + start the game with the initial shogi position. If matchMode is + set to Position, xshogi will start the game with the position + specified by the loadPositionFile resource. If matchMode is set + to Opening, xshogi will play out the opening moves specified by + the -loadGameFile resource. If the -saveGameFile resource is set, + a move record for the match will be saved in the specified file. + Default: "False". + +`-lgf or -loadGameFile file' + Name of file to read a game record from. Game files are found in + the directory named by the SHOGIDIR environment variable. If this + variable is not set, the current directory is used unless the file + name starts with a /. + +`-lpf or -loadPositionFile file' + Name of file to read a game position from. Position files are + found in the directory named by the SHOGIDIR environment variable. + If this variable is not set, the current directory is used unless + the file name starts with a /. + +`-sgf or -saveGameFile file' + Name of file to save a game record to. Game files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not set, the current directory is used unless the file + name starts with a /. + +`-spf or -savePositionFile file' + Name of file to save a game position to. Position files are saved + in the directory named by the SHOGIDIR environment variable. If + this variable is not set, the current directory is used unless the + file name starts with a /. + +`-coords or -showCoords (True | False)' + If this option is True, xshogi displays algebraic coordinates + along the board's left and bottom edges. The default is False. + The coordFont resource specifies what font to use. + +`-mono or -monoMode (True | False)' + Determines whether xshogi displays its pieces and squares with two + colors or four. You shouldn't have to specify monochrome. xshogi + will determine if this is necessary. + +`-pc or -pieceColor color' + Color specification for pieces suitable for XParseColor(). + Default: #FFFFD7. + +`-sc or -squareColor color' + Same for squares. Default: #EBDFB0. + +`-wps or -westernPieceSet (True | False)' + Choose the Western style piece set. + +`-npb or -normalPawnBitmap file' + +`-nnb or -normalKnightBitmap file' + +`-nbb or -normalBishopBitmap file' + +`-nrb or -normalRookBitmap file' + +`-nkb or -normalKingBitmap file' + Names of the bitmap files for the bitmap piece icons. + +`-rpb or -reversePawnBitmap file' + +`-rnb or -reverseKnightBitmap file' + +`-rbb or -reverseBishopBitmap file' + +`-rrb or -reverseRookBitmap file' + +`-rkb or -reverseKingBitmap file' + Names of the bitmap files for the outline piece icons. + +`-debug or -debugMode (True | False)' + Turns on debugging printout. + + + + OTHER X RESOURCES + + +`initString' + The actual string that is sent to initialize the shogi program can + be set from .Xdefaults. It can't be set from the command line + because of syntax problems. The default value is + "new\nbeep\nrandom\neasy\n". The "new" and "beep" commands are + required. You can remove the "random" command if you like; + including it causes gnushogi to randomize its move selection + slightly so that it doesn't play the same moves in every game. + Even without "random", gnushogi randomizes its choice of moves + from its opening book. You can also remove "easy" if you like; + including it toggles easy mode off, causing gnushogi to think on + your time. That is, if "easy" is included in the initString, GNU + Shogi thinks on your time; if not, it does not. (Yes, this does + seem backwards, doesn't it.) You can also try adding other + commands to the initString; see the gnushogi documentation (*note + gnushogi::) for details. + +`blackString and whiteString' + These resources control what is sent when the Machine Black and + Machine White buttons are selected. This is mostly for + compatibility with obsolete versions of gnushogi. + + Alternate bitmaps for piece icons can be specified either by + choosing one of the built-in sets or with the file name resources + described above. There are three built-in sets of piece bitmaps + available, large (the default), medium, or small. It is easiest + to select the set you prefer in the .Xdefaults file: + + XShogi*boardSize: Medium + + The font used for button labels and comments can be changed in the + .Xdefaults file. You may want to choose a smaller font if you are + using the small pieces: + + XShogi*font: helvetica_oblique12 + + The font used for coordinates (when the showCoords option is True) + can be set similarly: + + XShogi*coordFont: helvetica_10 + + If you are using a grayscale monitor, try setting the colors to: + + XShogi*pieceColor: gray100 + XShogi*squareColor: gray60 + + + COMMAND BUTTONS AND KEYS + + +`Quit' + Quits xshogi. Q or q is a keyboard equivalent. + +`Reset' + Resets xshogi to the beginning of a shogi game. It also deselects + any game or position files. + +`Flip View' + inverts the view of the shogi board. + +`Hint' + displays a move hint from gnushogi. + +`Load Game' + plays a game from a record file. If no file is specified a popup + dialog asks for a filename. Game files are found in the directory + named by the SHOGIDIR environment variable. If this variable is + not declared then the current directory is used unless the file + name starts with a /. G or g is a keyboard equivalent. The game + file parser will accept almost any file that contains moves in + algebraic notation. If the first line begins with `#', it is + assumed to be a title and is displayed. Text enclosed in + parentheses or square brackets is assumed to be commentary and is + displayed in a pop-up window. Any other text in the file is + ignored. + +`Load Position' + sets up a position from a position file. If no file is specified a + popup dialog asks for a filename. Position files are found in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Position files must be in the + format that the Save Position command writes. + +`Save Game' + saves a game to a record file. If no file is specified a popup + dialog asks for a filename. If the filename exists, the user is + asked whether the current game record is be appended to this file + or if the file should be replaced. Game files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Game files are human-readable, and + can also be read back by the Load Game command. Furthermore, they + are accepted as gnushogi text bookfiles. + +`Save Position' + saves a position to a position file. If no file is specified a + popup dialog asks for a filename. Position files are saved in the + directory named by the SHOGIDIR environment variable. If this + variable is not declared then the current directory is used unless + the file name starts with a /. Position files are human-readable, + and can also be read back by the Load Position command. + +`Machine White' + forces gnushogi to play white. + +`Machine Black' + forces gnushogi to play black. + +`Force Moves' + forces a series of moves. That is, gnushogi stops playing and + xshogi allows you to make moves for both white and black. + +`Two Machines' + plays a game between two computer programs. + +`Forward' + moves forward through a series of remembered moves. F or f is a + keyboard equivalent. + +`Backward' + moves backward through a series of remembered moves. As a side + effect, puts xshogi into Force Moves mode. B or b is a keyboard + equivalent. + +`Pause' + pauses the clocks or (in Load Game mode) pauses the game being + loaded. Press Pause again to continue. P or p is a keyboard + equivalent. + +`Edit Position' + lets you set up an arbitrary board position. Use mouse button 1 + to drag pieces to new squares, or to delete a piece by dragging it + off the board or dragging an empty square on top of it. To drop a + new piece on a square, press mouse button 2 or 3 over the square. + This brings up a menu of black pieces (button 2) or white pieces + (button 3). Additional menu choices let you empty the square or + clear the board. You can set the side to play next by clicking on + the Black or White indicator at the top of the screen. + +`Challenge' + allows you to make a two display game between two human players. + Enter the display you want to connect to. If you are allowed to + connect, a new board is displayed at the remote display. + Challenge mode can only be stopped by pressing "quit". + +`Select Level' + allows you to reset the clocks for both players. Enter the number + of moves and the number of minutes in which the moves should be + done. + +`Move NOW' + force computer to stop thinking and to make the current best move. + +`Iconify I, i, C or c' + iconifies xshogi. + + + + LIMITATIONS + + + If you press the Pause button during GNU Shogi's turn, xshogi +will stop the clocks, but gnushogi will still make a move. + + After a mate or draw when playing against gnushogi, if you back up +with the Backward button, the clocks are reset (because gnushogi +has exited and must be restarted). + + The game parser recognizes only algebraic notation. + + + AUTHORS + + + Original authors of XBoard: Chris Sears and Dan Sears. + + Enhancements for XBoard (Version 2.0): Tim Mann. + + Conversion to XShogi (Version 1.1): Matthias Mutz. + + Current maintainer: Mike Vanier. + + + COPYRIGHT INFORMATION + + + XShogi borrows its piece bitmaps from CRANES Shogi. + + Copyright 1991 by Digital Equipment Corporation, Maynard, +Massachusetts. Enhancements Copyright 1992 Free Software Foundation, +Inc. Enhancements Copyright 1993 Matthias Mutz. Further enhancements +copyright 1999 by Michael Vanier and the Free Software Foundation, Inc. + + The following terms apply to Digital Equipment Corporation's +copyright interest in XBoard: + + All Rights Reserved + + Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Digital not be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, +INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO +EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR +CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF +USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. + + The following terms apply to the enhanced version of XShogi +distributed by the Free Software Foundation: + + This file is part of XSHOGI. + + XSHOGI is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY. No author or distributor accepts responsibility to anyone +for the consequences of using it or for whether it serves any particular +purpose or works at all, unless he says so in writing. Refer to the +XSHOGI General Public License for full details. + + Everyone is granted permission to copy, modify and redistribute +XSHOGI, but only under the conditions described in the XSHOGI General +Public License. A copy of this license is supposed to have been given +to you along with XSHOGI so you can know your rights and +responsibilities. It should be in a file named COPYING. Among other +things, the copyright notice and this notice must be preserved on all +copies. + + +File: gnushogi.info, Node: References and links, Next: Acknowledgements, Prev: xshogi, Up: Top + +5 References and links +********************** + +There are very few English-language books for people learning shogi. +The two I recommend are: + + + 1. `Shogi for Beginners, 2nd. Edition', by John Fairbairn. This is a + superb beginner's book in every way, covering all phases of the + game. It was out of print for a long time, but has now been + reprinted and is available either from Kiseido + (`http://www.labnet.or.jp/~kiseido') or from George Hodges (see + below). + + 2. `The Art of Shogi', by Tony Hoskings. This is one step up from the + Fairbairn book. It covers a lot of ground, and is especially + noteworthy for its detailed treatment of opening lines. You can + order this book from Amazon.com's UK branch + (`http://www.amazon.co.uk'). + + + + Another book you may find is `Shogi: Japan's Game of Strategy' by +Trevor Leggett. This book is very elementary and is somewhat outdated, +having been published first in 1966. However, it does feature a paper +shogi board and punch-out pieces, so if you want a really cheap shogi +set you might pick this book up. It is still in print. + + Two books that are no longer in print but are definitely worth +getting if you find them are `Guide to Shogi Openings' and `Better +Moves for Better Shogi', both by Aono Teriuchi. They are published in a +bilingual edition (English/Japanese) and are the only books on shogi in +English written by a Japanese professional shogi player. John Fairbairn +did the translation from Japanese to English. + + Shogi sets are available from: + + + George F. Hodges + P.O. Box 77 + Bromley, Kent + United Kingdom BR1 2WT + + + George also sells equipment for all the historical shogi variants +(*note Shogi variants::) (except for Kyoku tai shogi) and also sells +back issues of the magazine "Shogi" which he published for 70 issues in +the late 70's to late 80's. This magazine is STRONGLY recommended; it +contains more information about shogi in English than you will ever +find anywhere else. + + Here are some useful URLs: + + +Pieter Stouten's shogi page: `http://www.shogi.net' + This is the main shogi-related site on the internet, with links to + almost all the other sites. + +Roger Hare's shogi page: `http://www.ed.ac.uk/~rjhare/shogi' + This has lots of information, including full rules to most of the + shogi variants. + +Patrick Davin's Shogi Nexus: `http://www.vega.or.jp/~patrick/shogi/' + There's lots of cool stuff on this site; my favorite is the + extensive collection of Tsume-shogi (mating) problems, both for + beginners and more advanced players. + +Steve Evans' shogi page: `http://www.netspace.net.au/~trout/index.html' + Steve has written a program that plays almost all of the shogi + variants, unfortunately it only runs on Windows :-( + +Hans Bodlaender's chess variant pages: `http://www.cs.ruu.nl/~hansb/d.chessvar' + This page has an almost unimaginable variety of rules for different + chess variants, including many shogi variants (historical and + non-historical). + + + + +File: gnushogi.info, Node: Acknowledgements, Next: Bugs, Prev: References and links, Up: Top + +6 Acknowledgements +****************** + +I would like to thank the following people: + + + * Matthias Mutz, who originally developed GNU shogi as a spin-off of + GNU chess and who very kindly let me take over the maintenance of + this very interesting project. + + * Richard Stallman and the Free Software Foundation, for creating an + organization where anyone can contribute software for the common + good of all, for making GNU/Linux possible, and especially for + writing emacs and gcc, without which my working life would be + intolerable. + + * Georges Hodges, for starting the Shogi Association in England, + without which I would probably never have heard of shogi, for + supplying shogi equipment, for publishing the excellent magazine + "Shogi" (now sadly defunct), for personally answering all my silly + questions by mail, and for being the ambassador of shogi to the + West. + + * Pieter Stouten, for having the most comprehensive shogi site on the + World Wide Web (`http://www.shogi.net'), and for maintaining the + shogi-l mailing list. Go to Pieter's web site for more + information on subscribing to the list. Also thanks to everyone + who contributes and has contributed to that list. + + * Matt Casters, for testing GNU shogi. Matt and I will be working + together on improving the solution engine in future versions of + this program. + + + + +File: gnushogi.info, Node: Bugs, Next: Index, Prev: Acknowledgements, Up: Top + +7 Bugs +****** + +The motto of GNU shogi is "100% bug-free or you don't pay!" :-) In the +extremely unlikely case (*ahem*) that you do find a bug, please send me +(Mike Vanier) an email at . Also, feel free to +send me comments, complaints, out-and-out raves, suggestions, plane +tickets to Hawaii, and/or large suitcases filled with unmarked, +untraceable hundred-dollar bills. + + +File: gnushogi.info, Node: Index, Prev: Bugs, Up: Top + +8 Index +******* + +[index] +* Menu: + +* Acknowledgements: Acknowledgements. (line 7) +* Books: References and links. (line 6) +* Chu Shogi: Shogi variants. (line 6) +* Dai Shogi: Shogi variants. (line 6) +* Dai-dai Shogi: Shogi variants. (line 6) +* Draws: Draws. (line 6) +* Drops: Drops. (line 6) +* gnushogi: gnushogi. (line 7) +* GPL: License. (line 6) +* Handicaps: Handicaps. (line 7) +* Introduction: Introduction. (line 6) +* Kyoku Tai Shogi: Shogi variants. (line 6) +* License: License. (line 6) +* Mailing lists: References and links. (line 6) +* Maka-dai-dai Shogi: Shogi variants. (line 6) +* Opening setup: The opening setup. (line 6) +* Piece moves: The moves of the pieces. + (line 6) +* Piece promotion: Promotion of pieces. (line 6) +* References: References and links. (line 6) +* Rules: The rules of shogi. (line 6) +* Sample game: Sample game. (line 7) +* Shogi variants: Shogi variants. (line 6) +* Shogi vs. Chess: Differences between shogi and chess. + (line 7) +* Tai Shogi: Shogi variants. (line 6) +* Tenjiku Shogi: Shogi variants. (line 6) +* Tori Shogi: Shogi variants. (line 6) +* Variants: Shogi variants. (line 6) +* Wa Shogi: Shogi variants. (line 6) +* Web sites: References and links. (line 6) +* Winning the game: Winning the game. (line 6) +* xshogi: xshogi. (line 7) + +  Tag Table: -(Indirect) -Node: Top926 -Node: Introduction1484 -Node: License2565 -Node: About shogi21724 -Node: The rules of shogi24319 -Node: The moves of the pieces25979 -Node: The opening setup29145 -Node: Promotion of pieces30677 -Node: Drops32518 -Node: Winning the game34770 -Node: Draws35484 -Node: Handicaps37889 -Node: Notes for chess players41315 -Node: Sample game42033 -Node: Mating problems49337 -Node: Shogi variants51585 -Node: Differences between shogi and chess55943 -Node: gnushogi60351 -Node: xshogi71829 -Node: References and links87937 -Node: Acknowledgements91081 -Node: Bugs92590 -Node: Index93073 +Node: Top1029 +Node: Introduction1587 +Node: License2670 +Node: About shogi21797 +Node: The rules of shogi24396 +Node: The moves of the pieces26062 +Node: The opening setup29237 +Node: Promotion of pieces30778 +Node: Drops32629 +Node: Winning the game34890 +Node: Draws35613 +Node: Handicaps38027 +Node: Notes for chess players41462 +Node: Sample game42189 +Node: Mating problems49498 +Node: Shogi variants51751 +Node: Differences between shogi and chess56113 +Node: gnushogi60526 +Node: xshogi72007 +Node: References and links88119 +Node: Acknowledgements91265 +Node: Bugs92775 +Node: Index93259  End Tag Table --- gnushogi-1.3.2.orig/debian/control +++ gnushogi-1.3.2/debian/control @@ -0,0 +1,43 @@ +Source: gnushogi +Section: games +Priority: optional +Maintainer: Yann Dirson +Build-Depends: + debhelper (>= 7), cdbs, autotools-dev, bison, flex, libncurses-dev, + libxaw7-dev, texinfo, x11-utils +Standards-Version: 3.9.2 +Homepage: http://www.cs.caltech.edu/~mvanier/hacking/gnushogi/gnushogi.html + +Package: gnushogi +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends} +Suggests: xshogi, tagua +Description: program to play shogi, the Japanese version of chess + Gnushogi is a computer player for Shogi (Japanese chess). + . + Gnushogi is a modified version of the gnuchess program. It can be + used through xshogi, tagua, kaya, or other graphical frontends, but + also has a simple alpha-numeric board display. + +Package: gnuminishogi +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends} +Suggests: tagua +Description: program to play minishogi, a shogi variant on a 5x5 board + Gnuminishogi is a computer player for the MiniShogi variant of shogi + (Japanese chess). + . + Gnuminishogi is a modified version of the gnushogi program. It can be + used through tagua, kaya, or other graphical frontends, but also has a + simple alpha-numeric board display. + +Package: xshogi +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends} +Recommends: gnushogi +Description: X11 frontend to gnushogi + Gnushogi is a computer player for Shogi (Japanese chess). + . + XShogi provides an X Window interface to play Shogi against gnushogi, + and can also be used as an interface for a game between two humans on + the same computer. --- gnushogi-1.3.2.orig/debian/gnushogi.menu +++ gnushogi-1.3.2/debian/gnushogi.menu @@ -0,0 +1,4 @@ +?package(gnushogi):needs="text" section="Games/Board"\ + title="GNU Shogi" longtitle="A program to play shogi, the Japanese version of chess."\ + description="Gnushogi plays a game of Shogi (Japanese chess) against the user or it plays against itself."\ + command="/usr/games/gnushogi" --- gnushogi-1.3.2.orig/debian/gnuminishogi.menu +++ gnushogi-1.3.2/debian/gnuminishogi.menu @@ -0,0 +1,4 @@ +?package(gnuminishogi):needs="text" section="Games/Board"\ + title="GNU MiniShogi" longtitle="A program to play minishogi, a variant of shogi on a 5x5 board."\ + description="Gnuminishogi plays a game of MiniShogi against the user or it plays against itself."\ + command="/usr/games/gnuminishogi" --- gnushogi-1.3.2.orig/debian/watch +++ gnushogi-1.3.2/debian/watch @@ -0,0 +1,2 @@ +version=2 +http://ftp.gnu.org/pub/gnu/gnushogi/gnushogi-([0-9].*).tar.bz2 --- gnushogi-1.3.2.orig/debian/xshogi.docs +++ gnushogi-1.3.2/debian/xshogi.docs @@ -0,0 +1,2 @@ +NEWS +README --- gnushogi-1.3.2.orig/debian/xshogi.menu +++ gnushogi-1.3.2/debian/xshogi.menu @@ -0,0 +1,4 @@ +?package(xshogi):needs="x11" section="Games/Board"\ + title="XShogi" longtitle="An X Window System Japanese Chess (Shogi) Board."\ + description="Gnushogi plays a game of Japanese chess (shogi) against the user or it plays against itself."\ + command="/usr/games/xshogi" --- gnushogi-1.3.2.orig/debian/copyright +++ gnushogi-1.3.2/debian/copyright @@ -0,0 +1,117 @@ +Author: Mike Vanier +Download: http://ftp.gnu.org/pub/gnu/gnushogi/ + +Files: * +Copyright: + (C) 1992 Free Software Foundation + (C) 1988-1990 John Stanback +License: GPL-1+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 1 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL file. + +Files: gnushogi/* +Copyright: + (C) 2008-2009 Yann Dirson + (C) 1999 Michael Vanier + (C) 1999 Free Software Foundation + (C) 1993-1995 Matthias Mutz +License: GPL-1+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 1 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL file. + +Files: xshogi/* +Copyright: + (C) Dan Sears + (C) Chris Sears + (C) Tim Mann + (C) Matthias Mutz +License: GPL-1+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 1 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL file. + +Files: xshogi/*bitmaps/* +Copyright: + (C) 1999 Michael Vanier + (C) 1992-1999 Free Software Foundation + (C) 1993-1995 Matthias Mutz + (C) 1991 Digital Equipment Corporation, Maynard, Massachusetts +License: MIT + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, + provided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in + supporting documentation, and that the name of Digital not be + used in advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING + ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL + DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR + ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + SOFTWARE. + +Files: debian/* +Copyright: (C) 2006-2009 Daniel Baumann + (C) 2009 Yann Dirson +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. --- gnushogi-1.3.2.orig/debian/gnuminishogi.copyright +++ gnushogi-1.3.2/debian/gnuminishogi.copyright @@ -0,0 +1,72 @@ +Authors: + Mike Vanier + Yann Dirson +Download: http://ftp.gnu.org/pub/gnu/gnushogi/ + +Files: * +Copyright: + (C) 1992 Free Software Foundation + (C) 1988-1990 John Stanback +License: GPL-1+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 1 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL file. + +Files: gnushogi/* +Copyright: + (C) 2008-2009 Yann Dirson + (C) 1999 Michael Vanier + (C) 1999 Free Software Foundation + (C) 1993-1995 Matthias Mutz +License: GPL-1+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 1 + 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, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL file. + +Files: debian/* +Copyright: (C) 2006-2009 Daniel Baumann + (C) 2009 Yann Dirson +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. --- gnushogi-1.3.2.orig/debian/gnushogi.install +++ gnushogi-1.3.2/debian/gnushogi.install @@ -0,0 +1 @@ +doc/*.html /usr/share/doc/gnushogi/html --- gnushogi-1.3.2.orig/debian/compat +++ gnushogi-1.3.2/debian/compat @@ -0,0 +1 @@ +7 --- gnushogi-1.3.2.orig/debian/changelog +++ gnushogi-1.3.2/debian/changelog @@ -0,0 +1,292 @@ +gnushogi (1.3.2-9) unstable; urgency=low + + * Add the single new patch of interest to us that 1.4.0 brings upstream, + fixing a buffer overflow in InputCommand. + * Fix command for building info file (Closes: #645864) + * Add a debian/watch to prevent the "-latest" symlink from hiding the real + latest version. + + -- Yann Dirson Tue, 15 May 2012 23:16:13 +0200 + +gnushogi (1.3.2-8) unstable; urgency=low + + * Fixed Homepage field in debian/control, to point to the caltech site + which appears to be more reliable. + * Improve package short descriptions (lintian). + * New patch to deal with -Wformat-security (Closes: #643572): + 22-format-string.patch. + * New set of patches to improve MiniShogi player and fix it with + some (read) buffer overflows which surely did not make it stronger. + Buffer overflow detected by hardening flags and induced all this work. + * Explicitly declare source format 1.0. + * Bumped Standards-Version to 3.9.2, no change. + + -- Yann Dirson Thu, 29 Sep 2011 00:15:34 +0200 + +gnushogi (1.3.2-7) unstable; urgency=low + + * Reworked extended descriptions. + * Wrapped long lines in debian/rules for clarity. + * Build gnushogi in its own BUILD-std subdir. + * Activate build of the gnuminishogi binary, ship it in its own package. + * Added myself to the debian/copyright*. + * Dropped leftover .pc/ from source package. + * Bumped Standards-Version to 3.8.3, no change. + + -- Yann Dirson Sat, 05 Sep 2009 17:52:17 +0200 + +gnushogi (1.3.2-6) unstable; urgency=low + + * New maintainer. + * Switch packaging to cdbs + simple-patchsys. + * Dropped special handling of config.*, now handled by cdbs. + * Factorize common install options. + * Include my fixes+minishogi patch series (do not activate minishogi + build yet): + * 04-errno-fix.patch - Errno mis-redifinition. + * 03-proto-fix.patch - Fix a function prototype. + * 05-ai-overflow.patch - Integer overflow possibly handicaping the AI. + * 06-fix-runnaway.patch - Avoid eating 100% CPU on Ctrl-C. + * 10-out-of-tree.patch - Allow building out of source tree + * 11-refactor-enums.patch - Use enums. + * 12-refactor-constants.patch - Parametrize more hardcoded contants. + * 13-refactor-statify.patch - Statify functions when possible. + * 14-internals-doc.patch - Document some internal APIs. + * 20-minishogi.patch - Initial minishogi support. + * 21-gen-patterns.patch - Generate patterns.inc at build time. + * Adjust 21-gen-patterns.patch not to cause removal of patterns.inc, + since that confuses the patch system at clean-time. + * Save patterns.inc before building and resture it on clean, to avoid + spurious diffs. + * Build-depend on x11-utils instead of the obsolete xutils (lintian). + * Fixed "X Windows" typo in xshogi extended description. + * Make gnushogi suggest tagua as an alternative frontend. + * Reword gnushogi extended description to emphasize that the preferred + way to use it is through a graphical frontend. + * Remove mention to the Internet Shogi Server in xshogi description, + since that support was removed long ago upstream. + + -- Yann Dirson Thu, 20 Aug 2009 01:52:26 +0200 + +gnushogi (1.3.2-5) unstable; urgency=low + + * Removing vcs fields. + * Orphaning package. + + -- Daniel Baumann Sun, 09 Aug 2009 01:21:52 +0200 + +gnushogi (1.3.2-4) unstable; urgency=low + + * Reverting config.guess and config.sub to upstream. + * Upgrading package to debhelper 7. + * Upgrading package to standards 3.8.0. + * Adding vcs fields in control file. + * Removing watch file. + * Updating vcs fields in control file. + * Using patch-stamp rather than patch in rules file. + * Replacing obsolete dh_clean -k with dh_prep. + * Using correct rfc-2822 date formats in changelog. + * Updating package to standards 3.8.2. + * Sorting depends. + * Rewriting copyright file in machine-interpretable format. + * Adding longtitle and description fields in menu files. + * Using quilt rather than dpatch. + * Minimizing rules file. + * Wrapping build-depends. + + -- Daniel Baumann Mon, 03 Aug 2009 08:34:18 +0200 + +gnushogi (1.3.2-3) unstable; urgency=low + + * Bumped policy version. + * Using new homepage field in control. + * Fixed typo in abstract of doc-base. + * Don't hide make errors in clean target of rules. + * Added patch from Stijn van Drongelen to fix + segfault in gnushogi when asking for help (Closes: #434139). + + -- Daniel Baumann Sun, 23 Dec 2007 15:34:00 +0100 + +gnushogi (1.3.2-2) unstable; urgency=medium + + * Added patch from Rene Mayorga to add missing + header entries to the info file (Closes: #422032). + + -- Daniel Baumann Thu, 05 Jul 2007 14:50:00 +0200 + +gnushogi (1.3.2-1) unstable; urgency=low + + * New upstream release. + * Minor cleanups. + * Bumped package to debhelper 5. + + -- Daniel Baumann Tue, 01 May 2007 12:46:00 +0200 + +gnushogi (1.3-9) unstable; urgency=medium + + * really using -O0 on alpha to workaround FTBFS (Closes: #393075). + + -- Daniel Baumann Sun, 29 Oct 2006 14:31:00 +0200 + +gnushogi (1.3-8) unstable; urgency=medium + + * using -O0 on alpha to workaround FTBFS (Closes: #393075). + + -- Daniel Baumann Sat, 28 Oct 2006 19:58:00 +0200 + +gnushogi (1.3-7) unstable; urgency=low + + * New maintainer (Closes: #321334). + * Redone debian directory based on current debhelper templates. + * Using dpatch for upstream modifications now. + * Added .desktop from ubuntu. + + -- Daniel Baumann Mon, 11 Sep 2006 09:41:00 +0200 + +gnushogi (1.3-6) unstable; urgency=low + + * QA upload + * Change build-depends on libxaw8 to 7 to comply with XSF plans + + -- David Nusinow Sun, 26 Mar 2006 19:48:09 -0500 + +gnushogi (1.3-5) unstable; urgency=low + + * QA upload. + * Versions 1.3-3.1 and earlier used non-standard code for the /usr/doc + transition that didn't remove the symlink on upgrades; remove it in + the preinst. Closes: #338060. + * debian/copyright: Update FSF address. + + -- Matej Vela Mon, 23 Jan 2006 08:42:16 +0100 + +gnushogi (1.3-4) unstable; urgency=high + + * QA upload. + * Package is orphaned (see #321334); set maintainer to Debian QA Group. + * gnushogi/genmove.c: Fix conflicting declarations for gcc 4.0; thanks to + Andreas Jochens for the patch. Closes: #286876. + * Update X11 build dependencies. + * Switch to debhelper. + * doc/gnushogi.texinfo: Add directory entry for dh_installinfo. + * gnushogi/Makefile.in, xshogi/Makefile.in: Leave stripping to dh_strip + (which honors DEB_BUILD_OPTIONS=nostrip). + * debian/rules: + - Add support for DEB_BUILD_OPTIONS=noopt. + - Remove support for DEB_BUILD_OPTIONS=debug. + - Leave HTML files uncompressed. + * debian/copyright: Update upstream URL. + * debian/doc-base: Add. + * debian/watch: Add. + * Conforms to Standards version 3.6.2. + + -- Matej Vela Mon, 22 Aug 2005 10:16:33 +0200 + +gnushogi (1.3-3.1) unstable; urgency=low + + * NMU + - Minimal testing done and looks quite OK (even if I don't know + how to play the game...) + - Build-Depends move from libxaw-dev to libxaw6-dev (Closes: #169975) + - Included errno.h in gnushogi which makes the binary build properly + now (and is usable with xshogi) (Closes: #226319) + + -- Javier Fernandez-Sanguino Pen~a Fri, 09 Jan 2004 16:06:59 +0100 + +gnushogi (1.3-3) unstable; urgency=high + + * Added build dependency on xutils, flex, and bison. + (Closes: Bug#147134) + + -- Brian Mays Thu, 16 May 2002 06:16:58 -0400 + +gnushogi (1.3-1) unstable; urgency=high + + * New upstream version. (Closes: Bug#139722) + + -- Brian Mays Wed, 15 May 2002 15:12:32 -0400 + +gnushogi (1.2p03-14) unstable; urgency=medium + + * Modified postinst to ignore an existing /usr/doc/$package directory. + + -- Brian Mays Wed, 20 Mar 2002 11:16:42 -0500 + +gnushogi (1.2p03-13) unstable; urgency=low + + * Fixed symlink /usr/doc -> ../share/doc. + * Fixed reference to GPL. + * Improved stripping of binaries. + * Removed icon="none" from menu file. + * Improved the package description. + + -- Brian Mays Sun, 03 Feb 2002 13:23:19 -0500 + +gnushogi (1.2p03-12) unstable; urgency=low + + * Removed "-g" gcc option as per policy. + + -- Brian Mays Mon, 16 Jul 2001 19:38:15 -0400 + +gnushogi (1.2p03-11) unstable; urgency=low + + * Fixed typo in the debian/rules file causing the changelog file to + be suid root. (Closes: Bug#74461) + + -- Brian Mays Tue, 17 Oct 2000 13:07:48 -0400 + +gnushogi (1.2p03-10) frozen unstable; urgency=low + + * Added build-time dependencies. + + -- Brian Mays Mon, 17 Jan 2000 13:42:43 -0500 + +gnushogi (1.2p03-9) unstable; urgency=low + + * Fixed FHS /usr/doc -> /usr/share/doc transition scheme. + + -- Brian Mays Fri, 01 Oct 1999 13:06:12 -0400 + +gnushogi (1.2p03-8) unstable; urgency=low + + * Moved the doc and man data directories to under /usr/share as per + the FHS. + + -- Brian Mays Thu, 16 Sep 1999 15:53:03 -0400 + +gnushogi (1.2p03-7) unstable; urgency=low + + * Rebuilt to account for name change in package libncurses4. + + -- Brian Mays Sun, 01 Nov 1998 13:53:58 -0500 + +gnushogi (1.2p03-6) unstable; urgency=low + + * Libc6 release. + + -- Brian Mays Tue, 05 Aug 1997 17:05:18 -0400 + +gnushogi (1.2p03-5) frozen unstable; urgency=low + + * Fixed Debian menu support. + + -- Brian Mays Wed, 28 May 1997 15:36:13 -0400 + +gnushogi (1.2p03-4) unstable; urgency=low + + * Added Debian menu support. + + -- Brian Mays Sat, 19 Apr 1997 19:24:09 -0400 + +gnushogi (1.2p03-3) unstable; urgency=low + + * Renamed /usr/doc/gnushogi/CHANGES to changelog. + * Slightly modified the package description (Bug #6883). + + -- Brian Mays Tue, 28 Jan 1997 10:58:55 -0500 + +gnushogi (1.2p03-2) unstable; urgency=low + + * First release with the new source format. + + -- Brian Mays Fri, 23 Aug 1996 23:28:22 -0400 --- gnushogi-1.3.2.orig/debian/rules +++ gnushogi-1.3.2/debian/rules @@ -0,0 +1,109 @@ +#!/usr/bin/make -f + +# WARNING: +# This debian/rules uses black magic to warp cdbs into building 2 binaries +# from the same autotools-style source package. This was done with cdbs 0.4.61 +# and may need updating as the cdbs internals evolve. Hopefully their +# evolution will in the end allow to wipe the magic :) + + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk +include /usr/share/cdbs/1/class/autotools.mk + +## configure stage + +DEB_BUILD_ARCH ?= $(shell dpkg-architecture -qDEB_BUILD_ARCH) + +ifeq ($(DEB_BUILD_ARCH),alpha) + CFLAGS += -O0 +endif + +DEB_BUILDDIR_gnushogi=BUILD-std +DEB_BUILDDIR_gnuminishogi=BUILD-mini + +# counter-magic to avoid --srcdir=. +DEB_BUILDDIR=BUILD-dummy + +# ignore standard configure invocation ... +DEB_CONFIGURE_INVOKE= + +# ... instead we cause tow runs in two subdirs +.PHONY: $(DEB_BUILDDIR)/config.status +$(DEB_BUILDDIR)/config.status: \ + $(DEB_BUILDDIR_gnushogi)/config.status \ + $(DEB_BUILDDIR_gnuminishogi)/config.status + +# we have to change slightly how configure is called: +#DEB_CONFIGURE_SCRIPT=../configure +GS_CONFIGURE_INVOKE=$(DEB_CONFIGURE_SCRIPT) $(DEB_CONFIGURE_SCRIPT_ENV) $(DEB_CONFIGURE_NORMAL_ARGS) + +$(DEB_BUILDDIR_gnushogi)/config.status:: + mkdir -p $(DEB_BUILDDIR_gnushogi) + cd $(DEB_BUILDDIR_gnushogi) && $(GS_CONFIGURE_INVOKE) + +$(DEB_BUILDDIR_gnuminishogi)/config.status:: CFLAGS+=-DMINISHOGI +$(DEB_BUILDDIR_gnuminishogi)/config.status:: + mkdir -p $(DEB_BUILDDIR_gnuminishogi) + cd $(DEB_BUILDDIR_gnuminishogi) && $(GS_CONFIGURE_INVOKE) + + +## build stage + +# standard rule does not support multi-dir +debian/stamp-makefile-build: + true + touch $@ + +GS_MAKE_INVOKE=$(DEB_MAKE_ENVVARS) $(MAKE) -C $(DEB_BUILDDIR) $(DEB_MAKE_EXTRA_ARGS) + +build/gnushogi build/xshogi:: DEB_BUILDDIR=$(DEB_BUILDDIR_gnushogi) +build/gnushogi build/xshogi:: $(DEB_BUILDDIR_gnushogi)/config.status + $(GS_MAKE_INVOKE) PATTERNFILE=../../misc/gnushogi.pat + +build/gnuminishogi:: DEB_BUILDDIR=$(DEB_BUILDDIR_gnuminishogi)/gnushogi +build/gnuminishogi:: $(DEB_BUILDDIR_gnuminishogi)/config.status + $(GS_MAKE_INVOKE) gnushogi \ + BINBOOK='-DBINBOOK=\"$$(LIBDIR)/gnuminishogi.bbk\"' \ + TEXTBOOK='-DBOOK=\"$$(LIBDIR)/gnuminishogi.tbk\"' \ + HASH='-DHASHFILE=\"$$(LIBDIR)/gnuminishogi.hsh\"' \ + PATTERNFILE=../../misc/gnuminishogi.pat + +binary-arch/gnushogi:: + $(MAKE) -C doc + +clean:: + rm -rf $(DEB_BUILDDIR_gnushogi) $(DEB_BUILDDIR_gnuminishogi) + +## install stage + +# do not out-guess debian/*.docs +DEB_INSTALL_DOCS_ALL= + +# ignore standard "make install", we do it per-package +DEB_MAKE_INSTALL_TARGET= + +COMMON_INSTALL_OPTS= \ + BINDIR=\$${prefix}/games \ + LIBDIR=\$${prefix}/lib/games \ + MANDIR=\$${prefix}/share/man/man6 \ + INFODIR=\$${prefix}/share/info + +install/gnushogi:: + $(MAKE) $(COMMON_INSTALL_OPTS) -C BUILD-std/gnushogi prefix=$(CURDIR)/debian/gnushogi/usr install +install/xshogi:: + $(MAKE) $(COMMON_INSTALL_OPTS) -C BUILD-std/xshogi prefix=$(CURDIR)/debian/xshogi/usr install +install/gnushogi:: + install -d debian/gnuminishogi/usr/games + install -m755 BUILD-mini/gnushogi/gnushogi debian/gnuminishogi/usr/games/gnuminishogi + + +## general build hacks + +# make sure patterns are rebuilt +configure/gnushogi:: + test -r gnushogi/pattern.inc.cdbs-orig || \ + mv gnushogi/pattern.inc gnushogi/pattern.inc.cdbs-orig +clean:: + test ! -r gnushogi/pattern.inc.cdbs-orig || \ + mv gnushogi/pattern.inc.cdbs-orig gnushogi/pattern.inc --- gnushogi-1.3.2.orig/debian/gnushogi.docs +++ gnushogi-1.3.2/debian/gnushogi.docs @@ -0,0 +1,6 @@ +NEWS +README +doc/BOOKFILES +doc/shogi.rules +doc/tutorial*.gam +TODO --- gnushogi-1.3.2.orig/debian/xshogi.install +++ gnushogi-1.3.2/debian/xshogi.install @@ -0,0 +1 @@ +debian/desktop/* /usr/share/applications --- gnushogi-1.3.2.orig/debian/gnushogi.info +++ gnushogi-1.3.2/debian/gnushogi.info @@ -0,0 +1 @@ +doc/gnushogi.info* --- gnushogi-1.3.2.orig/debian/gnushogi.doc-base +++ gnushogi-1.3.2/debian/gnushogi.doc-base @@ -0,0 +1,14 @@ +Document: gnushogi +Title: GNU Shogi manual +Author: Michael C. Vanier +Abstract: This document describes GNU Shogi, a program which plays Japanese + chess (shogi) against a human opponent. +Section: Games/Board + +Format: info +Index: /usr/share/info/gnushogi.info.gz +Files: /usr/share/info/gnushogi.info*.gz + +Format: HTML +Index: /usr/share/doc/gnushogi/html/gnushogi_toc.html +Files: /usr/share/doc/gnushogi/html/*.html --- gnushogi-1.3.2.orig/debian/source/format +++ gnushogi-1.3.2/debian/source/format @@ -0,0 +1 @@ +1.0 --- gnushogi-1.3.2.orig/debian/desktop/xshogi.desktop +++ gnushogi-1.3.2/debian/desktop/xshogi.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Application +Name=Xshogi +Comment=Play Shogi Game +Exec=xshogi +Icon=grisbi.png +Terminal=false +Categories=Application;Game; --- gnushogi-1.3.2.orig/debian/patches/13-refactor-statify.patch +++ gnushogi-1.3.2/debian/patches/13-refactor-statify.patch @@ -0,0 +1,33 @@ +commit f34b02ba06e8b28ce251529179d20e819a16b9e8 +Author: Yann Dirson +Date: Mon Feb 11 01:47:00 2008 +0100 + + Statify functions not used outside their compilation unit. + +diff --git a/gnushogi/pattern.c b/gnushogi/pattern.c +index 10a02f8..84f4f08 100644 +--- a/gnushogi/pattern.c ++++ b/gnushogi/pattern.c +@@ -89,7 +89,7 @@ ValueOfOpeningName (char *name) + } + + +-void ++static void + NameOfOpeningValue (short i, char *name) + { + if (i < 100) +diff --git a/gnushogi/pattern.h b/gnushogi/pattern.h +index 63509f6..73f2a0e 100644 +--- a/gnushogi/pattern.h ++++ b/gnushogi/pattern.h +@@ -106,9 +106,6 @@ ShowOpeningPatterns(short max_opening_sequence); + extern short + ValueOfOpeningName(char *name); + +-extern void +-NameOfOpeningValue(short i, char *name); +- + extern small_short pattern_data[]; + + --- gnushogi-1.3.2.orig/debian/patches/21-gen-patterns.patch +++ gnushogi-1.3.2/debian/patches/21-gen-patterns.patch @@ -0,0 +1,1388 @@ +commit 7e9f410917ae2de3f20f0595c156e205c69569dd +Author: Yann Dirson +Date: Mon Feb 11 01:47:01 2008 +0100 + + Generate patterns.inc at build time. + +diff --git a/TODO b/TODO +index 12b25b5..9489313 100644 +--- a/TODO ++++ b/TODO +@@ -4,7 +4,6 @@ Generic cleanups + - position of captured pieces in curses mode + - compile with bound-checker + - add autosave mode to ease hunt for segfaults ? +-- generate patterns.inc at build-time + - use 2D array for the board, get rid of the (i)nunmap stuff + - fixup build procedure to support parallel make runs + - investigate those preexisting "overflow in implicit constant +@@ -20,9 +19,3 @@ Minishogi-related stuff + * OPENING_HINT + - add minishogi stuff to the doc + - use valid minishogi moves in online help +- +-- segfault (on level 1) following 2e1d 1d4a +- => field.piece can reach 14 in pattern.c::update_advance_bonus +- => probably related to using patterns for standard shogi +- => must break the circular pattern.o <-> pattern.inc dep to +- be able to generated pattern.inc as needed +diff --git a/gnushogi/Makefile.in b/gnushogi/Makefile.in +index 584da68..c1e2094 100644 +--- a/gnushogi/Makefile.in ++++ b/gnushogi/Makefile.in +@@ -70,7 +70,7 @@ LCURSES = -lcurses -ltermcap + CC = @CC@ + CWARNINGS = @WARNINGS@ + CEXTRAFLAGS = @CEXTRAFLAGS@ +-CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I$(ROOT) -I@top_builddir@ ++CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I$(ROOT) -I@top_builddir@ -I. + + + # The hashfile is a record of positions seen. It is used by +@@ -97,7 +97,8 @@ LANGF = -DLANGFILE=\"../misc/gnushogi.lng\" + # obtain such a pattern in the opening stage. Sequences of opening + # patterns may be described in order to support the correct order of moves. + +-PATTERN = -DPATTERNFILE=\"../misc/gnushogi.pat\" ++PATTERNFILE=../misc/gnushogi.pat ++PATTERN = -DPATTERNFILE=\"$(PATTERNFILE)\" + + + all: +@@ -109,6 +110,12 @@ all: + # + + COMMONFILES = \ ++ globals.o \ ++ init-common.o \ ++ pattern-common.o \ ++ lang.o ++ ++NOTCOMMONFILES = \ + attacks.o \ + book.o \ + commondsp.o \ +@@ -116,7 +123,6 @@ COMMONFILES = \ + dspwrappers.o \ + eval.o \ + genmove.o \ +- globals.o \ + init.o \ + pattern.o \ + rawdsp.o \ +@@ -125,7 +131,7 @@ COMMONFILES = \ + tcontrl.o \ + util.o + +-GNUSHOGI_FILES = $(COMMONFILES) main.o ++GNUSHOGI_FILES = $(COMMONFILES) $(NOTCOMMONFILES) main.o + + + PAT2INCFILES = $(COMMONFILES) makepattern.o pat2inc.o +@@ -177,9 +183,15 @@ globals.o: globals.c + eval.o: eval.c + $(CC) $(CFLAGS) -c $< + ++lang.o: lang.c ++ $(CC) $(CFLAGS) $(LANGF) -c $< ++ + init.o: init.c + $(CC) $(CFLAGS) $(LANGF) -c $< + ++init-common.o: init-common.c ++ $(CC) $(CFLAGS) $(LANGF) -c $< ++ + main.o: main.c + $(CC) $(CFLAGS) $(BINBOOK) -c $< + +@@ -192,6 +204,9 @@ makepattern.o: makepattern.c + pattern.o: pattern.c + $(CC) $(CFLAGS) -c $< + ++pattern-common.o: pattern-common.c ++ $(CC) $(CFLAGS) -c $< ++ + rawdsp.o: rawdsp.c + $(CC) $(CFLAGS) -c $< + +@@ -216,6 +231,8 @@ pat2inc.o: pat2inc.c + sizetest.o: sizetest.c + $(CC) $(CFLAGS) -c $< + ++pattern.inc: $(PATTERNFILE) pat2inc ++ ./pat2inc + + # + # Other targets. +@@ -276,7 +293,7 @@ eval.o: eval.c eval.h gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h + init.o: init.c gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h + main.o: main.c gnushogi.h $(ROOT)/version.h + makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h +-pattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h $(SRCDIR)/pattern.inc ++pattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h pattern.inc + rawdsp.o: rawdsp.c gnushogi.h $(ROOT)/version.h + search.o: search.c gnushogi.h $(ROOT)/version.h + sysdeps.o: sysdeps.c gnushogi.h $(ROOT)/version.h +diff --git a/gnushogi/init-common.c b/gnushogi/init-common.c +new file mode 100644 +index 0000000..3a7b8a0 +--- /dev/null ++++ b/gnushogi/init-common.c +@@ -0,0 +1,490 @@ ++#include "gnushogi.h" ++#include "pattern.h" ++ ++unsigned int ttbllimit; ++ ++/* ++ * ptype is used to separate black and white pawns, like this; ptyp = ++ * ptype[side][piece] piece can be used directly in nextpos/nextdir when ++ * generating moves for pieces that are not white pawns. ++ */ ++ ++const small_short ptype[2][NO_PIECES] = ++{ ++ { ++ ptype_no_piece, ptype_pawn, ++#ifndef MINISHOGI ++ ptype_lance, ptype_knight, ++#endif ++ ptype_silver, ptype_gold, ptype_bishop, ptype_rook, ++ ptype_gold, ++#ifndef MINISHOGI ++ ptype_gold, ptype_gold, ++#endif ++ ptype_gold, ++ ptype_pbishop, ptype_prook, ptype_king ++ }, ++ { ++ ptype_no_piece, ptype_wpawn, ++#ifndef MINISHOGI ++ ptype_wlance, ptype_wknight, ++#endif ++ ptype_wsilver, ptype_wgold, ptype_bishop, ptype_rook, ++ ptype_wgold, ++#ifndef MINISHOGI ++ ptype_wgold, ptype_wgold, ++#endif ++ ptype_wgold, ++ ptype_pbishop, ptype_prook, ptype_king ++ }, ++}; ++ ++const small_short promoted[NO_PIECES] = ++{ ++ no_piece, ppawn, ++#ifndef MINISHOGI ++ plance, pknight, ++#endif ++ psilver, gold, pbishop, prook, ++ ppawn, ++#ifndef MINISHOGI ++ plance, pknight, ++#endif ++ psilver, pbishop, prook, king ++}; ++ ++const small_short unpromoted[NO_PIECES] = ++{ ++ no_piece, pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold, bishop, rook, ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, bishop, rook, king ++}; ++ ++ ++/* .... MOVE GENERATION VARIABLES AND INITIALIZATIONS .... */ ++ ++#define max(a, b) (((a) < (b))?(b):(a)) ++#define odd(a) ((a) & 1) ++ ++const small_short piece_of_ptype[NO_PTYPE_PIECES] = ++{ ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold, bishop, rook, pbishop, prook, king, ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold ++}; ++ ++ ++/* FIXME: all bishops and rooks are black ? */ ++const small_short side_of_ptype[NO_PTYPE_PIECES] = ++{ ++ black, ++#ifndef MINISHOGI ++ black, black, ++#endif ++ black, black, black, black, black, black, black, ++ white, ++#ifndef MINISHOGI ++ white, white, ++#endif ++ white, white ++}; ++ ++ ++int ++Initialize_data(void) ++{ ++ size_t n; ++ int i; ++ char buffer[60]; ++ int doit = true; ++ ++ { ++ small_short x = -1; ++ ++ if (x >= 0) ++ { ++ ShowMessage("datatype 'small_short' is unsigned; " ++ "check gnushogi.h\n"); ++ return 1; ++ } ++ } ++ ++ n = sizeof(struct leaf) * (size_t)TREE; ++ Tree = malloc(n); ++ ++ if (!Tree) ++ { ++ sprintf(buffer, "Cannot allocate %ld bytes for search tree", ++ (long)n); ++ ShowMessage(buffer); ++ return 1; ++ } ++ ++ n = sizeof(hashcode_array); ++ hashcode = malloc(n); ++ ++ if (!hashcode) ++ { ++ sprintf(buffer, "Cannot allocate %ld bytes for hashcode", (long)n); ++ ShowMessage(buffer); ++ return 1; ++ } ++ ++ n = sizeof(drop_hashcode_array); ++ drop_hashcode = malloc(n); ++ ++ if (!drop_hashcode) ++ { ++ sprintf(buffer, ++ "Cannot allocate %ld bytes for drop_hashcode", ++ (long)n); ++ ShowMessage(buffer); ++ return 1; ++ } ++ ++ n = sizeof(struct GameRec) * (size_t)(MAXMOVES + MAXDEPTH); ++ GameList = malloc(n); ++ ++ if (!GameList) ++ { ++ sprintf(buffer, ++ "Cannot allocate %ld bytes for game record", ++ (long)n); ++ ShowMessage(buffer); ++ return 1; ++ } ++ ++#if !defined SAVE_NEXTPOS ++ n = sizeof(next_array); ++ ++ for (i = 0; i < NO_PTYPE_PIECES; i++) ++ { ++ nextdir[i] = use_nextpos ? malloc(n) : NULL; ++ ++ if (!nextdir[i]) ++ { ++ if (use_nextpos) ++ { ++ sprintf(buffer, "cannot allocate %ld space for nextdir %d", ++ (long)(n), i); ++ ShowMessage(buffer); ++ } ++ ++ nextdir[i] = NULL; ++ use_nextpos = false; ++ } ++ ++ nextpos[i] = use_nextpos ? malloc(n) : NULL; ++ ++ if (!nextpos[i]) ++ { ++ if (use_nextpos) ++ { ++ sprintf(buffer, "cannot allocate %ld space for nextpos %d", ++ (long)(n), i); ++ ShowMessage(buffer); ++ } ++ ++ use_nextpos = false; ++ } ++ } ++ ++ if (!use_nextpos) ++ { ++ return 1; ++ } ++#endif ++ ++ n = sizeof(value_array); ++ value = malloc(n); ++ ++ if (!value) ++ { ++ ShowMessage("cannot allocate value space"); ++ return 1; ++ } ++ ++ n = sizeof(fscore_array); ++ fscore = malloc(n); ++ ++ if (!fscore) ++ { ++ ShowMessage("cannot allocate fscore space"); ++ return 1; ++ } ++ ++#if defined HISTORY ++ n = sizeof_history; ++ history = malloc(n); ++ ++ if (!history) ++ { ++ sprintf(buffer, "Cannot allocate %ld bytes for history table", ++ (long)sizeof_history); ++ ShowMessage(buffer); ++ use_history = false; ++ } ++#endif ++ ++#if defined CACHE ++ n = sizeof(struct etable) * (size_t)ETABLE; ++ ++ for (i = 0; i < 2; i++) ++ { ++ etab[i] = use_etable ? malloc(n) : 0; ++ ++ if (!etab[i]) ++ { ++ sprintf(buffer, "Cannot allocate %ld bytes for cache table %ld", ++ (long)n, (long)i); ++ ShowMessage(buffer); ++ use_etable = false; ++ } ++ } ++#endif ++ ++#if ttblsz ++ ++ if (rehash < 0) ++ rehash = MAXrehash; ++ ++ n = sizeof(struct hashentry)*(ttblsize + rehash); ++ ++ while (doit && ttblsize > MINTTABLE) ++ { ++ ttable[0] = malloc(n); /* FIXME: cast to the correct type. */ ++ ttable[1] = ttable[0] ? malloc(n) : NULL; ++ ++ if (!ttable[0] || !ttable[1]) ++ { ++ if (!ttable[0]) ++ free(ttable[0]); ++ ++ if (!ttable[1]) ++ free(ttable[1]); ++ ++ ttblsize = ttblsize >> 1; ++ n = sizeof(struct hashentry) * (ttblsize + rehash); ++ } ++ else ++ { ++ doit = false; ++ } ++ } ++ ++ if (ttblsize <= MINTTABLE) ++ { ++ use_ttable = false; ++ } ++ ++ if (use_ttable) ++ { ++ /* CHECKME: is the precedence here correct? */ ++ /* ttbllimit = ttblsize << 1 - ttblsize >> 2; */ ++ ttbllimit = (ttblsize << 1) - (ttblsize >> 2); ++ } ++ else ++ { ++ sprintf(buffer, "Cannot allocate %ld bytes for transposition table", ++ (long)(2 * n)); ++ ShowMessage(buffer); ++ ttable[0] = ttable[1] = NULL; ++ } ++#endif /* ttblsz */ ++ ++#if !defined SAVE_DISTDATA ++ n = sizeof(distdata_array); ++ distdata = malloc(n); ++ ++ if (!distdata) ++ { ++ ShowMessage("cannot allocate distdata space..."); ++ use_distdata = false; ++ } ++#endif ++ ++#if !defined SAVE_PTYPE_DISTDATA ++ n = sizeof(distdata_array); ++ ++ for (i = 0; i < NO_PTYPE_PIECES; i++) ++ { ++ ptype_distdata[i] = use_ptype_distdata ? malloc(n) : 0; ++ ++ if (!ptype_distdata[i]) ++ { ++ sprintf(buffer, ++ "cannot allocate %ld bytes for ptype_distdata %d...", ++ (long)n, i); ++ use_ptype_distdata = false; ++ } ++ } ++#endif ++ ++ return 0; ++} ++ ++ ++#ifdef SAVE_PTYPE_DISTDATA ++short ++piece_distance(short side, short piece, short f, short t) ++{ ++ return ((f > NO_SQUARES) ++ ? (short)1 ++ : (short)ptype_distance(ptype[side][piece], f, t)); ++} ++#else ++short ++piece_distance(short side, short piece, short f, short t) ++{ ++ return ((f > NO_SQUARES) ++ ? (short)1 ++ : (use_ptype_distdata ++ ? (short)(*ptype_distdata[ptype[side][piece]])[f][t] ++ : (short)ptype_distance(ptype[side][piece], f, t))); ++} ++#endif ++ ++ ++/* ++ * Determine the minimum number of moves for a piece from ++ * square "f" to square "t". If the piece cannot reach "t", ++ * the count is set to CANNOT_REACH. ++ */ ++ ++#define csquare(sq) ((side == black) ? sq : (NO_SQUARES - 1 - sq)) ++#define crow(sq) row(csquare(sq)) ++#define ccol(sq) column(csquare(sq)) ++ ++short ++ptype_distance(short ptyp, short f, short t) ++{ ++ short side, piece; ++ short colf, colt, rowf, rowt, dcol, drow; ++ ++ if (f == t) ++ return 0; ++ ++ piece = piece_of_ptype[ptyp]; ++ side = side_of_ptype[ptyp]; ++ ++ dcol = (colt = ccol(t)) - (colf = ccol(f)); ++ drow = (rowt = crow(t)) - (rowf = crow(f)); ++ ++ switch (piece) ++ { ++ case pawn: ++ if ((dcol != 0) || (drow < 1)) ++ return CANNOT_REACH; ++ else ++ return drow; ++ ++#ifndef MINISHOGI ++ case lance: ++ if ((dcol != 0) || (drow < 1)) ++ return CANNOT_REACH; ++ else ++ return 1; ++ ++ case knight: ++ if (odd(drow) || (odd(drow / 2) != odd(dcol))) ++ return CANNOT_REACH; ++ else if ((drow == 0) || ((drow / 2) < abs(dcol))) ++ return CANNOT_REACH; ++ else ++ return (drow / 2); ++#endif ++ ++ case silver: ++ if (drow > 0) ++ { ++ if (odd(drow) == odd(dcol)) ++ { ++ return max(abs(drow), abs(dcol)); ++ } ++ else ++ { ++ if (abs(dcol) <= drow) ++ return drow; ++ else ++ return (max(abs(drow), abs(dcol)) + 1); ++ } ++ } ++ else ++ { ++ if (odd(drow) == odd(dcol)) ++ return (max(abs(drow), abs(dcol))); ++ else ++ return (max(abs(drow) + 1, abs(dcol)) + 1); ++ }; ++ ++ case gold: ++ case ppawn: ++#ifndef MINISHOGI ++ case pknight: ++ case plance: ++#endif ++ case psilver: ++ if (abs(dcol) == 0) ++ return (abs(drow)); ++ else if (drow >= 0) ++ return max(drow, abs(dcol)); ++ else ++ return (abs(dcol) - drow); ++ ++ case bishop: ++ if (odd(dcol) != odd(drow)) ++ return CANNOT_REACH; ++ else ++ return ((abs(dcol) == abs(drow)) ? 1 : 2); ++ ++ case pbishop: ++ if (odd(dcol) != odd(drow)) ++ { ++ if ((abs(dcol) <= 1) && (abs(drow) <= 1)) ++ return 1; ++ else if (abs(abs(dcol) - abs(drow)) == 1) ++ return 2; ++ else ++ return 3; ++ } ++ else ++ { ++ return ((abs(dcol) == abs(drow)) ? 1 : 2); ++ } ++ ++ case rook: ++ if ((dcol == 0) || (drow == 0)) ++ return 1; ++ else ++ return 2; ++ ++ case prook: ++ if ((dcol == 0) || (drow == 0)) ++ return 1; ++ else if ((abs(dcol) == 1) && (abs(drow) == 1)) ++ return 1; ++ else ++ return 2; ++ ++ case king: ++ return max(abs(drow), abs(dcol)); ++ ++ default: ++ /* should never occur */ ++ return (CANNOT_REACH); ++ } ++} +diff --git a/gnushogi/init.c b/gnushogi/init.c +index 4306972..fb368e2 100644 +--- a/gnushogi/init.c ++++ b/gnushogi/init.c +@@ -64,45 +64,8 @@ short nolist = 1; /* Don't list the game after exit. */ + + display_t display_type = DISPLAY_X; + +-unsigned int ttbllimit; +- + /* .... MOVE GENERATION VARIABLES AND INITIALIZATIONS .... */ + +- +-#define max(a, b) (((a) < (b))?(b):(a)) +-#define odd(a) ((a) & 1) +- +- +-const small_short piece_of_ptype[NO_PTYPE_PIECES] = +-{ +- pawn, +-#ifndef MINISHOGI +- lance, knight, +-#endif +- silver, gold, bishop, rook, pbishop, prook, king, +- pawn, +-#ifndef MINISHOGI +- lance, knight, +-#endif +- silver, gold +-}; +- +- +-/* FIXME: all bishops and rooks are black ? */ +-const small_short side_of_ptype[NO_PTYPE_PIECES] = +-{ +- black, +-#ifndef MINISHOGI +- black, black, +-#endif +- black, black, black, black, black, black, black, +- white, +-#ifndef MINISHOGI +- white, white, +-#endif +- white, white +-}; +- + #ifdef SAVE_NEXTPOS + const small_short psweep[NO_PTYPE_PIECES] = + { +@@ -126,157 +89,6 @@ const small_short sweep[NO_PIECES] = + }; + + +-#if !defined EXTLANGFILE +- +-char *CP[CPSIZE] = +- +-{ +-/* 000: eng: */ "", +-#ifdef LANGFILE +-#include LANGFILE +-#else +-#include "gnushogi.lng" +-#endif +-}; +- +-#else +- +-char *CP[CPSIZE]; +- +-#endif +- +- +-/* +- * Determine the minimum number of moves for a piece from +- * square "f" to square "t". If the piece cannot reach "t", +- * the count is set to CANNOT_REACH. +- */ +- +-#define csquare(sq) ((side == black) ? sq : (NO_SQUARES - 1 - sq)) +-#define crow(sq) row(csquare(sq)) +-#define ccol(sq) column(csquare(sq)) +- +-short +-ptype_distance(short ptyp, short f, short t) +-{ +- short side, piece; +- short colf, colt, rowf, rowt, dcol, drow; +- +- if (f == t) +- return 0; +- +- piece = piece_of_ptype[ptyp]; +- side = side_of_ptype[ptyp]; +- +- dcol = (colt = ccol(t)) - (colf = ccol(f)); +- drow = (rowt = crow(t)) - (rowf = crow(f)); +- +- switch (piece) +- { +- case pawn: +- if ((dcol != 0) || (drow < 1)) +- return CANNOT_REACH; +- else +- return drow; +- +-#ifndef MINISHOGI +- case lance: +- if ((dcol != 0) || (drow < 1)) +- return CANNOT_REACH; +- else +- return 1; +- +- case knight: +- if (odd(drow) || (odd(drow / 2) != odd(dcol))) +- return CANNOT_REACH; +- else if ((drow == 0) || ((drow / 2) < abs(dcol))) +- return CANNOT_REACH; +- else +- return (drow / 2); +-#endif +- +- case silver: +- if (drow > 0) +- { +- if (odd(drow) == odd(dcol)) +- { +- return max(abs(drow), abs(dcol)); +- } +- else +- { +- if (abs(dcol) <= drow) +- return drow; +- else +- return (max(abs(drow), abs(dcol)) + 1); +- } +- } +- else +- { +- if (odd(drow) == odd(dcol)) +- return (max(abs(drow), abs(dcol))); +- else +- return (max(abs(drow) + 1, abs(dcol)) + 1); +- }; +- +- case gold: +- case ppawn: +-#ifndef MINISHOGI +- case pknight: +- case plance: +-#endif +- case psilver: +- if (abs(dcol) == 0) +- return (abs(drow)); +- else if (drow >= 0) +- return max(drow, abs(dcol)); +- else +- return (abs(dcol) - drow); +- +- case bishop: +- if (odd(dcol) != odd(drow)) +- return CANNOT_REACH; +- else +- return ((abs(dcol) == abs(drow)) ? 1 : 2); +- +- case pbishop: +- if (odd(dcol) != odd(drow)) +- { +- if ((abs(dcol) <= 1) && (abs(drow) <= 1)) +- return 1; +- else if (abs(abs(dcol) - abs(drow)) == 1) +- return 2; +- else +- return 3; +- } +- else +- { +- return ((abs(dcol) == abs(drow)) ? 1 : 2); +- } +- +- case rook: +- if ((dcol == 0) || (drow == 0)) +- return 1; +- else +- return 2; +- +- case prook: +- if ((dcol == 0) || (drow == 0)) +- return 1; +- else if ((abs(dcol) == 1) && (abs(drow) == 1)) +- return 1; +- else +- return 2; +- +- case king: +- return max(abs(drow), abs(dcol)); +- +- default: +- /* should never occur */ +- return (CANNOT_REACH); +- } +-} +- +- + #ifdef SAVE_DISTDATA + short + distance(short a, short b) +@@ -294,27 +106,6 @@ distance(short a, short b) + #endif + + +-#ifdef SAVE_PTYPE_DISTDATA +-short +-piece_distance(short side, short piece, short f, short t) +-{ +- return ((f > NO_SQUARES) +- ? (short)1 +- : (short)ptype_distance(ptype[side][piece], f, t)); +-} +-#else +-short +-piece_distance(short side, short piece, short f, short t) +-{ +- return ((f > NO_SQUARES) +- ? (short)1 +- : (use_ptype_distdata +- ? (short)(*ptype_distdata[ptype[side][piece]])[f][t] +- : (short)ptype_distance(ptype[side][piece], f, t))); +-} +-#endif +- +- + void + Initialize_dist(void) + { +@@ -366,70 +157,6 @@ Initialize_dist(void) + */ + + +-/* +- * ptype is used to separate black and white pawns, like this; ptyp = +- * ptype[side][piece] piece can be used directly in nextpos/nextdir when +- * generating moves for pieces that are not white pawns. +- */ +- +-const small_short ptype[2][NO_PIECES] = +-{ +- { +- ptype_no_piece, ptype_pawn, +-#ifndef MINISHOGI +- ptype_lance, ptype_knight, +-#endif +- ptype_silver, ptype_gold, ptype_bishop, ptype_rook, +- ptype_gold, +-#ifndef MINISHOGI +- ptype_gold, ptype_gold, +-#endif +- ptype_gold, +- ptype_pbishop, ptype_prook, ptype_king +- }, +- { +- ptype_no_piece, ptype_wpawn, +-#ifndef MINISHOGI +- ptype_wlance, ptype_wknight, +-#endif +- ptype_wsilver, ptype_wgold, ptype_bishop, ptype_rook, +- ptype_wgold, +-#ifndef MINISHOGI +- ptype_wgold, ptype_wgold, +-#endif +- ptype_wgold, +- ptype_pbishop, ptype_prook, ptype_king +- }, +-}; +- +-const small_short promoted[NO_PIECES] = +-{ +- no_piece, ppawn, +-#ifndef MINISHOGI +- plance, pknight, +-#endif +- psilver, gold, pbishop, prook, +- ppawn, +-#ifndef MINISHOGI +- plance, pknight, +-#endif +- psilver, pbishop, prook, king +-}; +- +-const small_short unpromoted[NO_PIECES] = +-{ +- no_piece, pawn, +-#ifndef MINISHOGI +- lance, knight, +-#endif +- silver, gold, bishop, rook, +- pawn, +-#ifndef MINISHOGI +- lance, knight, +-#endif +- silver, bishop, rook, king +-}; +- + const small_short is_promoted[NO_PIECES] = + { + false, false, +@@ -910,239 +637,6 @@ NewGame(void) + + + +-int +-Initialize_data(void) +-{ +- size_t n; +- int i; +- char buffer[60]; +- int doit = true; +- +- { +- small_short x = -1; +- +- if (x >= 0) +- { +- ShowMessage("datatype 'small_short' is unsigned; " +- "check gnushogi.h\n"); +- return 1; +- } +- } +- +- n = sizeof(struct leaf) * (size_t)TREE; +- Tree = malloc(n); +- +- if (!Tree) +- { +- sprintf(buffer, "Cannot allocate %ld bytes for search tree", +- (long)n); +- ShowMessage(buffer); +- return 1; +- } +- +- n = sizeof(hashcode_array); +- hashcode = malloc(n); +- +- if (!hashcode) +- { +- sprintf(buffer, "Cannot allocate %ld bytes for hashcode", (long)n); +- ShowMessage(buffer); +- return 1; +- } +- +- n = sizeof(drop_hashcode_array); +- drop_hashcode = malloc(n); +- +- if (!drop_hashcode) +- { +- sprintf(buffer, +- "Cannot allocate %ld bytes for drop_hashcode", +- (long)n); +- ShowMessage(buffer); +- return 1; +- } +- +- n = sizeof(struct GameRec) * (size_t)(MAXMOVES + MAXDEPTH); +- GameList = malloc(n); +- +- if (!GameList) +- { +- sprintf(buffer, +- "Cannot allocate %ld bytes for game record", +- (long)n); +- ShowMessage(buffer); +- return 1; +- } +- +-#if !defined SAVE_NEXTPOS +- n = sizeof(next_array); +- +- for (i = 0; i < NO_PTYPE_PIECES; i++) +- { +- nextdir[i] = use_nextpos ? malloc(n) : NULL; +- +- if (!nextdir[i]) +- { +- if (use_nextpos) +- { +- sprintf(buffer, "cannot allocate %ld space for nextdir %d", +- (long)(n), i); +- ShowMessage(buffer); +- } +- +- nextdir[i] = NULL; +- use_nextpos = false; +- } +- +- nextpos[i] = use_nextpos ? malloc(n) : NULL; +- +- if (!nextpos[i]) +- { +- if (use_nextpos) +- { +- sprintf(buffer, "cannot allocate %ld space for nextpos %d", +- (long)(n), i); +- ShowMessage(buffer); +- } +- +- use_nextpos = false; +- } +- } +- +- if (!use_nextpos) +- { +- return 1; +- } +-#endif +- +- n = sizeof(value_array); +- value = malloc(n); +- +- if (!value) +- { +- ShowMessage("cannot allocate value space"); +- return 1; +- } +- +- n = sizeof(fscore_array); +- fscore = malloc(n); +- +- if (!fscore) +- { +- ShowMessage("cannot allocate fscore space"); +- return 1; +- } +- +-#if defined HISTORY +- n = sizeof_history; +- history = malloc(n); +- +- if (!history) +- { +- sprintf(buffer, "Cannot allocate %ld bytes for history table", +- (long)sizeof_history); +- ShowMessage(buffer); +- use_history = false; +- } +-#endif +- +-#if defined CACHE +- n = sizeof(struct etable) * (size_t)ETABLE; +- +- for (i = 0; i < 2; i++) +- { +- etab[i] = use_etable ? malloc(n) : 0; +- +- if (!etab[i]) +- { +- sprintf(buffer, "Cannot allocate %ld bytes for cache table %ld", +- (long)n, (long)i); +- ShowMessage(buffer); +- use_etable = false; +- } +- } +-#endif +- +-#if ttblsz +- +- if (rehash < 0) +- rehash = MAXrehash; +- +- n = sizeof(struct hashentry)*(ttblsize + rehash); +- +- while (doit && ttblsize > MINTTABLE) +- { +- ttable[0] = malloc(n); /* FIXME: cast to the correct type. */ +- ttable[1] = ttable[0] ? malloc(n) : NULL; +- +- if (!ttable[0] || !ttable[1]) +- { +- if (!ttable[0]) +- free(ttable[0]); +- +- if (!ttable[1]) +- free(ttable[1]); +- +- ttblsize = ttblsize >> 1; +- n = sizeof(struct hashentry) * (ttblsize + rehash); +- } +- else +- { +- doit = false; +- } +- } +- +- if (ttblsize <= MINTTABLE) +- { +- use_ttable = false; +- } +- +- if (use_ttable) +- { +- /* CHECKME: is the precedence here correct? */ +- /* ttbllimit = ttblsize << 1 - ttblsize >> 2; */ +- ttbllimit = (ttblsize << 1) - (ttblsize >> 2); +- } +- else +- { +- sprintf(buffer, "Cannot allocate %ld bytes for transposition table", +- (long)(2 * n)); +- ShowMessage(buffer); +- ttable[0] = ttable[1] = NULL; +- } +-#endif /* ttblsz */ +- +-#if !defined SAVE_DISTDATA +- n = sizeof(distdata_array); +- distdata = malloc(n); +- +- if (!distdata) +- { +- ShowMessage("cannot allocate distdata space..."); +- use_distdata = false; +- } +-#endif +- +-#if !defined SAVE_PTYPE_DISTDATA +- n = sizeof(distdata_array); +- +- for (i = 0; i < NO_PTYPE_PIECES; i++) +- { +- ptype_distdata[i] = use_ptype_distdata ? malloc(n) : 0; +- +- if (!ptype_distdata[i]) +- { +- sprintf(buffer, +- "cannot allocate %ld bytes for ptype_distdata %d...", +- (long)n, i); +- use_ptype_distdata = false; +- } +- } +-#endif +- +- return 0; +-} +- + + #if defined EXTLANGFILE + +diff --git a/gnushogi/lang.c b/gnushogi/lang.c +new file mode 100644 +index 0000000..c5081bb +--- /dev/null ++++ b/gnushogi/lang.c +@@ -0,0 +1,20 @@ ++#include "gnushogi.h" ++ ++#if !defined EXTLANGFILE ++ ++char *CP[CPSIZE] = ++ ++{ ++/* 000: eng: */ "", ++#ifdef LANGFILE ++#include LANGFILE ++#else ++#include "gnushogi.lng" ++#endif ++}; ++ ++#else ++ ++char *CP[CPSIZE]; ++ ++#endif +diff --git a/gnushogi/makepattern.c b/gnushogi/makepattern.c +index b2e618a..5960ae9 100644 +--- a/gnushogi/makepattern.c ++++ b/gnushogi/makepattern.c +@@ -37,6 +37,14 @@ + #define MAX_PATTERN 200 + + char *patternfile = PATTERNFILE; ++small_short pattern_data[MAX_PATTERN_DATA]; ++ ++/* minimal ShowMessage to avoid dependency on extraneous display code */ ++void ++ShowMessage(char *s) ++{ ++ printf("%s\n", s); ++} + + #define is_digit(c) (((c) >= '0') && ((c) <= '9')) + #define is_alpha(c) ((((c) >= 'a') && ((c) <= 'z')) \ +@@ -226,16 +234,14 @@ ReadOpeningSequences (short *pindex) + pattern_data[(*pindex)++] = END_OF_PATTERNS; + pattern_data[(*pindex)++] = END_OF_SEQUENCES; + +- if (NOT_CURSES) +- { +- sprintf(s, +- "Pattern: %d bytes for %d sequences with %d patterns.\n", +- *pindex, max_opening_sequence, max_pattern); +- ShowMessage(s); +- } ++ sprintf(s, ++ "Pattern: %d bytes for %d sequences with %d patterns.\n", ++ *pindex, max_opening_sequence, max_pattern); ++ ShowMessage(s); ++ + fclose(fd); + } +- else if (NOT_CURSES) ++ else + { + sprintf(s, "no pattern file '%s'", patternfile); + ShowMessage(s); +diff --git a/gnushogi/pat2inc.c b/gnushogi/pat2inc.c +index a9fd562..80a388a 100644 +--- a/gnushogi/pat2inc.c ++++ b/gnushogi/pat2inc.c +@@ -44,12 +44,11 @@ extern void WriteOpeningSequences(short pindex); + small_short PieceCnt[2]; + small_short PieceList[2][NO_SQUARES]; + small_short PieceIndex[NO_SQUARES]; ++*/ + + small_short board[NO_SQUARES]; + small_short color[NO_SQUARES]; + +-*/ +- + void + test_distance(void) + { +@@ -100,8 +99,6 @@ main(int argc, char **argv) + char s[80]; + #endif + +- display_type = DISPLAY_RAW; +- + #if defined(EXTLANGFILE) + InitConst(Lang); + #endif +diff --git a/gnushogi/pattern-common.c b/gnushogi/pattern-common.c +new file mode 100644 +index 0000000..4cf1a12 +--- /dev/null ++++ b/gnushogi/pattern-common.c +@@ -0,0 +1,49 @@ ++#include "gnushogi.h" ++#include "pattern.h" ++ ++short ++ValueOfOpeningName (char *name) ++{ ++ short i; ++ i = (name[0] == 'C') ? 0 : 100; ++ ++ switch (name[7]) ++ { ++ case 'S': ++ i += 10; ++ break; ++ ++ case 'R': ++ i += 20; ++ break; ++ ++ case 'U': ++ i += 30; ++ break; ++ ++ default: ++ i += 40; ++ break; ++ } ++ ++ switch (name[9]) ++ { ++ case 'S': ++ i += 1; ++ break; ++ ++ case 'R': ++ i += 2; ++ break; ++ ++ case 'U': ++ i += 3; ++ break; ++ ++ default: ++ i += 4; ++ break; ++ } ++ ++ return i; ++} +diff --git a/gnushogi/pattern.c b/gnushogi/pattern.c +index 84f4f08..63496bd 100644 +--- a/gnushogi/pattern.c ++++ b/gnushogi/pattern.c +@@ -41,54 +41,6 @@ struct OpeningSequence_rec OpeningSequence[MAX_OPENING_SEQUENCE]; + small_short pattern_data[MAX_PATTERN_DATA]; + + +-short +-ValueOfOpeningName (char *name) +-{ +- short i; +- i = (name[0] == 'C') ? 0 : 100; +- +- switch (name[7]) +- { +- case 'S': +- i += 10; +- break; +- +- case 'R': +- i += 20; +- break; +- +- case 'U': +- i += 30; +- break; +- +- default: +- i += 40; +- break; +- } +- +- switch (name[9]) +- { +- case 'S': +- i += 1; +- break; +- +- case 'R': +- i += 2; +- break; +- +- case 'U': +- i += 3; +- break; +- +- default: +- i += 4; +- break; +- } +- +- return i; +-} +- +- + static void + NameOfOpeningValue (short i, char *name) + { +diff --git a/misc/gnuminishogi.pat b/misc/gnuminishogi.pat +new file mode 100644 +index 0000000..946febc +--- /dev/null ++++ b/misc/gnuminishogi.pat +@@ -0,0 +1,5 @@ ++# This is a dummy file for lack of documentation. The single entry is ++# just here to keep the code happy, it is even not guaranted to be ++# smart,or even to be in a section with the right name. ++ATTACK_U_U ++[0] b1d --- gnushogi-1.3.2.orig/debian/patches/04-errno-fix.patch +++ gnushogi-1.3.2/debian/patches/04-errno-fix.patch @@ -0,0 +1,36 @@ +commit 15c08f418cbc6c5dd6d84e90efef566be4087130 +Author: Yann Dirson +Date: Fri Jan 18 00:18:35 2008 +0100 + + Do not attempt to outguess system headers by (re)defining errno. + + Recent glibc define error as a cpp macro expanding to a function + call. Thus, "extern int errno" should cause a link-time undefined + symbol when errno.h is not included. Here it is, and gcc complains + with the following cryptic warning: + + ../../gnushogi/sysdeps.c: In function 'ElapsedTime_FIONREAD': + ../../gnushogi/sysdeps.c:97: warning: function declaration isn't a prototype + +diff --git a/gnushogi/sysdeps.c b/gnushogi/sysdeps.c +index 9752e96..fa7ef87 100644 +--- a/gnushogi/sysdeps.c ++++ b/gnushogi/sysdeps.c +@@ -94,7 +94,6 @@ ElapsedTime_FIONREAD(ElapsedTime_mode iop) + int nchar; + + struct timeval tv; +- extern int errno; + + if ((i = ioctl((int) 0, FIONREAD, &nchar))) + { +@@ -230,9 +229,6 @@ ElapsedTime_FIONREAD(ElapsedTime_mode iop) + int nchar; + int i; + +- extern int errno; +- +- + if ((i = ioctl((int) 0, FIONREAD, &nchar))) + { + perror("FIONREAD"); --- gnushogi-1.3.2.orig/debian/patches/03-proto-fix.patch +++ gnushogi-1.3.2/debian/patches/03-proto-fix.patch @@ -0,0 +1,19 @@ +commit df594029ceb253e6e7eb4bef11a4d3ce7b846bfe +Author: Yann Dirson +Date: Fri Jan 18 00:18:35 2008 +0100 + + Fix a function prototype. + +diff --git a/gnushogi/pat2inc.c b/gnushogi/pat2inc.c +index 01e56f2..a9fd562 100644 +--- a/gnushogi/pat2inc.c ++++ b/gnushogi/pat2inc.c +@@ -51,7 +51,7 @@ small_short color[NO_SQUARES]; + */ + + void +-test_distance() ++test_distance(void) + { + short side, piece, f, t, d; + --- gnushogi-1.3.2.orig/debian/patches/05-ai-overflow.patch +++ gnushogi-1.3.2/debian/patches/05-ai-overflow.patch @@ -0,0 +1,44 @@ +commit 2b191bf4b58cae1e4a8da7f6e24954438fae8fc5 +Author: Yann Dirson +Date: Fri Jan 18 00:19:24 2008 +0100 + + Fix integer overflow caused by bad use of binary operator. + + Guess this may make the AI more accurate :) + + Problem caught by gcc: + + ../../gnushogi/search.c: In function 'search': + ../../gnushogi/search.c:887: warning: overflow in implicit constant conversion + + + A quick audit only revealed a place where another logical AND was + tested using a curious idiom, so let's make it consistent at the same + time. + +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index 15509e2..a8a54c7 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -1005,7 +1005,7 @@ BRLscan(short sq, short *mob) + { \ + if (color[u] != c2) \ + { \ +- if ((atk1[u] == 0) || ((atk2[u] & CNT_MASK) > 1)) \ ++ if ((atk1[u] == 0) || ((atk2[u] & CNT_MASK) != 0)) \ + { \ + ++cnt; \ + } \ +diff --git a/gnushogi/search.c b/gnushogi/search.c +index 3d49b8b..72d3219 100644 +--- a/gnushogi/search.c ++++ b/gnushogi/search.c +@@ -884,7 +884,7 @@ search(short side, + + MakeMove(side, node, &tempb, &tempc, &tempsf, + &tempst, &INCscore); +- CptrFlag[ply] = (node->flags & capture); ++ CptrFlag[ply] = ((node->flags & capture) != 0); + TesujiFlag[ply] = (node->flags & tesuji) + && (node->flags & dropmask); + Tscore[ply] = node->score; --- gnushogi-1.3.2.orig/debian/patches/06-fix-runnaway.patch +++ gnushogi-1.3.2/debian/patches/06-fix-runnaway.patch @@ -0,0 +1,88 @@ +commit a03fee09f9ec4afc263818667d015d8288fe2a31 +Author: Yann Dirson +Date: Mon Feb 11 01:46:38 2008 +0100 + + Don't intercept INT and QUIT signals, and use USR1 instead of QUIT for + communication. + + This braindead use of SIGINT causes problem when a frontend is + interrupted with Ctrl-C: if gnushogi is waiting for input, it would + enter a tight loop trying to read stdin, eating 100% CPU. + +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index b5b59d7..69b4257 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -2151,7 +2151,7 @@ InputCommand(char *command) + #endif + } + +- signal(SIGINT, TerminateSearch); ++ signal(SIGUSR1, TerminateSearch); + } + + +diff --git a/gnushogi/init.c b/gnushogi/init.c +index e6df8cf..5486617 100644 +--- a/gnushogi/init.c ++++ b/gnushogi/init.c +@@ -1274,7 +1274,7 @@ InitMain(void) + + if (XSHOGI) + { +- signal(SIGINT, TerminateSearch); ++ signal(SIGUSR1, TerminateSearch); + + TCmoves = 40; + TCminutes = 5; +diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c +index bfbc7d2..6e2a235 100644 +--- a/gnushogi/rawdsp.c ++++ b/gnushogi/rawdsp.c +@@ -314,8 +314,7 @@ Raw_help(void) + TimeControl.moves[black], TimeControl.clock[black] / 100, + TCadd/100, MaxSearchDepth); + +- signal(SIGINT, Raw_TerminateSearch); +- signal(SIGQUIT, Raw_TerminateSearch); ++ signal(SIGUSR1, Raw_TerminateSearch); + } + + +@@ -487,8 +486,7 @@ SetupBoard(void) + void + Raw_SearchStartStuff(short side) + { +- signal(SIGINT, Raw_TerminateSearch); +- signal(SIGQUIT, Raw_TerminateSearch); ++ signal(SIGUSR1, Raw_TerminateSearch); + + if (flag.post) + { +diff --git a/xshogi/xshogi.c b/xshogi/xshogi.c +index 1d998d6..f6317dd 100644 +--- a/xshogi/xshogi.c ++++ b/xshogi/xshogi.c +@@ -7131,7 +7131,7 @@ void DisplayTitle(char *title) + + + /* CHECKME: does this work? +- * This routine sends a SIGINT (^C interrupt) to gnushogi to awaken it ++ * This routine sends a SIGUSR1 to gnushogi to awaken it + * if it might be busy thinking on our time. This normally isn't needed, + * but is useful on systems where the FIONREAD ioctl doesn't work since + * on those systems the gnushogi feature that lets you interrupt its thinking +@@ -7159,11 +7159,11 @@ Attention(int pid) + { + if (xshogiDebug || localPlayer.appData.debugMode) + { +- fprintf(stderr, "Sending SIGINT to %s\n", ++ fprintf(stderr, "Sending SIGUSR1 to %s\n", + ((pid == firstProgramPID) ? "first" : "second")); + } + +- (void)kill(pid, SIGINT); /* stop it thinking */ ++ (void)kill(pid, SIGUSR1); /* stop it thinking */ + } + break; + --- gnushogi-1.3.2.orig/debian/patches/02-segfault.patch +++ gnushogi-1.3.2/debian/patches/02-segfault.patch @@ -0,0 +1,15 @@ +Author: Stijn van Drongelen +Description: Fixes segfault in gnushogi when asking for help (Closes: #434139). + +diff -Naurp gnushogi.orig/gnushogi/rawdsp.c gnushogi/gnushogi/rawdsp.c +--- gnushogi.orig/gnushogi/rawdsp.c 2009-08-03 06:01:40.000000000 +0000 ++++ gnushogi/gnushogi/rawdsp.c 2009-08-03 06:20:28.000000000 +0000 +@@ -241,7 +241,7 @@ Raw_help(void) + { + Raw_ClearScreen(); + /* printf("SHOGI command summary\n"); */ +- printf(CP[40]); ++ printf(CP[40], version, patchlevel); + printf("----------------------------------" + "------------------------------\n"); + /* printf("7g7f move from 7g to 7f quit --- gnushogi-1.3.2.orig/debian/patches/12-refactor-constants.patch +++ gnushogi-1.3.2/debian/patches/12-refactor-constants.patch @@ -0,0 +1,334 @@ +commit e9e8ad2c518358f6ec92a93015aec1cf59873d52 +Author: Yann Dirson +Date: Mon Feb 11 01:47:00 2008 +0100 + + Parametrize more hardcoded contants. + +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index 69b4257..5251649 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -389,17 +389,17 @@ parser(char *f, int side, short *fpiece) + + if (f[1] == '*' || f[1] == '\'') + { +- c2 = '9' - f[2]; +- r2 = 'i' - f[3]; ++ c2 = COL_NAME(f[2]); ++ r2 = ROW_NAME(f[3]); + + return ((NO_SQUARES + *fpiece) << 8) | locn(r2, c2); + } + else + { +- c1 = '9' - f[1]; +- r1 = 'i' - f[2]; +- c2 = '9' - f[3]; +- r2 = 'i' - f[4]; ++ c1 = COL_NAME(f[1]); ++ r1 = ROW_NAME(f[2]); ++ c2 = COL_NAME(f[3]); ++ r2 = ROW_NAME(f[4]); + p = (f[5] == '+') ? 0x80 : 0; + + return (locn(r1, c1) << 8) | locn(r2, c2) | p; +@@ -719,7 +719,7 @@ SaveGame(void) + + for (i = NO_ROWS - 1; i > -1; i--) + { +- fprintf(fd, "%c ", 'i' - i); ++ fprintf(fd, "%c ", ROW_NAME(i)); + + for (c = 0; c < NO_COLS; c++) + { +@@ -754,7 +754,7 @@ SaveGame(void) + } + + fprintf(fd, empty); +- fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); ++ fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); /* FIXME */ + fprintf(fd, empty); + fprintf(fd, " p l n s g b r k\n"); + +diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c +index 692ffa8..78feaa0 100644 +--- a/gnushogi/cursesdsp.c ++++ b/gnushogi/cursesdsp.c +@@ -47,8 +47,8 @@ int mycnt1, mycnt2; + + #define TAB (58) + +-#define VIR_C(s) ((flag.reverse) ? (8 - column(s)) : column(s)) +-#define VIR_R(s) ((flag.reverse) ? (8 - row(s)) : row(s)) ++#define VIR_C(s) ((flag.reverse) ? (NO_COLS - 1 - column(s)) : column(s)) ++#define VIR_R(s) ((flag.reverse) ? (NO_ROWS - 1 - row(s)) : row(s)) + + unsigned short MV[MAXDEPTH]; + int MSCORE; +@@ -164,7 +164,7 @@ Curses_ShowPatternCount(short side, short n) + { + if (flag.post) + { +- gotoXY(TAB + 10 + 3 * side, 20); ++ gotoXY(TAB + 10 + 3 * side, 20); /* CHECKME */ + + if (n >= 0) + printw("%3d", n); +@@ -177,9 +177,9 @@ Curses_ShowPatternCount(short side, short n) + void + ShowPlayers(void) + { +- gotoXY(5, ((flag.reverse) ? 23 : 2)); ++ gotoXY(5, ((flag.reverse) ? (5 + 2*NO_ROWS) : 2)); + printw("%s", (computer == white) ? CP[218] : CP[74]); +- gotoXY(5, ((flag.reverse) ? 2 : 23)); ++ gotoXY(5, ((flag.reverse) ? 2 : (5 + 2*NO_ROWS))); + printw("%s", (computer == black) ? CP[218] : CP[74]); + } + +@@ -500,8 +500,8 @@ Curses_EditBoard(void) + } + else + { +- c = '9' - s[1]; +- r = 'i' - s[2]; ++ c = COL_NAME(s[1]); ++ r = ROW_NAME(s[2]); + } + + if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) +@@ -600,7 +600,7 @@ Curses_SearchStartStuff(short side) + signal(SIGINT, Curses_TerminateSearch); + signal(SIGQUIT, Curses_TerminateSearch); + +- for (i = 4; i < 14; i++) ++ for (i = 4; i < 14; i++) /* CHECKME */ + { + gotoXY(TAB, i); + ClearEoln(); +@@ -747,7 +747,7 @@ DrawPiece(short sq) + y = pxx[(int)piece]; + } + +- gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * (8 - VIR_R(sq))); ++ gotoXY(8 + 5 * VIR_C(sq), 4 + 2 * ((NO_ROWS - 1) - VIR_R(sq))); + printw("%c%c%c%c", l, p, y, r); + } + +@@ -763,7 +763,7 @@ Curses_ShowPostnValue(short sq) + { + short score; + +- gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); ++ gotoXY(4 + 5 * VIR_C(sq), 5 + 2 * (7 - VIR_R(sq))); /* CHECKME */ + score = ScorePosition(color[sq]); + + if (color[sq] != neutral) +@@ -809,6 +809,7 @@ void + Curses_UpdateDisplay(short f, short t, short redraw, short isspec) + { + short i, sq, z; ++ int j; + + if (redraw) + { +@@ -818,31 +819,38 @@ Curses_UpdateDisplay(short f, short t, short redraw, short isspec) + i = 2; + gotoXY(3, ++i); + +- printw(" +----+----+----+----+----+----+----+----+----+"); ++ printw(" +"); ++ for (j=0; j 26) && (t > 26)) ++ if ((!InBlackCamp(f)) && (!InBlackCamp(t))) + return false; + } + +@@ -1110,7 +1110,7 @@ LinkPreventCheckDrops(short side, short xside, short ply) + if (board[square = PieceList[side][0]] != king) + return; + +- for (piece = lance; piece <= rook; piece++) ++ for (piece = lance; piece <= rook; piece++) /* FIXME */ + { + if (piece == lance || piece == bishop || piece == rook) + { +diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h +index f0082a9..c05a7b9 100644 +--- a/gnushogi/gnushogi.h ++++ b/gnushogi/gnushogi.h +@@ -163,10 +163,12 @@ extern void movealgbr(short m, char *s); + #define NO_PIECES 15 + #define MAX_CAPTURED 19 + #define NO_PTYPE_PIECES 15 +-#define NO_SQUARES 81 +-#define NO_SQUARES_1 80 + #define NO_COLS 9 + #define NO_ROWS 9 ++#define NO_SQUARES (NO_COLS*NO_ROWS) ++ ++#define ROW_NAME(n) ('a' + NO_ROWS - 1 - n) ++#define COL_NAME(n) ('1' + NO_COLS - 1 - n) + + #if defined HASHFILE || defined CACHE + # define PTBLBDSIZE (NO_SQUARES + NO_PIECES) +@@ -859,14 +861,9 @@ extern struct hashentry *ttable[2]; + extern short rpthash[2][256]; + extern char *DRAW; + +-/* +- * FIXME: these should be more generic instead of using the +- * magic number 9. +- */ +- +-#define row(a) ((a) / 9) +-#define column(a) ((a) % 9) +-#define locn(a, b) (((a) * 9) + b) ++#define row(a) ((a) / NO_COLS) ++#define column(a) ((a) % NO_COLS) ++#define locn(a, b) (((a) * NO_COLS) + b) + + /* init external functions */ + extern void InitConst(char *lang); /* init.c */ +diff --git a/gnushogi/init.c b/gnushogi/init.c +index 5486617..ff28830 100644 +--- a/gnushogi/init.c ++++ b/gnushogi/init.c +@@ -403,7 +403,7 @@ const small_short direc[NO_PTYPE_PIECES][8] = + + small_short diagonal(short d) + { +- return (abs(d) == 10 || abs(d) == 12); ++ return (abs(d) == (NO_COLS+1) || abs(d) == (NO_COLS+3)); + } + + +@@ -515,7 +515,7 @@ Initialize_moves(void) + short dest[8][9]; + short sorted[9]; + short steps[8]; +- short fpo = 23, tpo = 120; ++ short fpo = inunmap[0], tpo = 1 + inunmap[NO_SQUARES-1]; + + for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++) + { +diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c +index 6e2a235..bfa5ac1 100644 +--- a/gnushogi/rawdsp.c ++++ b/gnushogi/rawdsp.c +@@ -381,8 +381,8 @@ Raw_EditBoard(void) + } + else + { +- c = '9' - s[1]; +- r = 'i' - s[2]; ++ c = COL_NAME(s[1]); ++ r = ROW_NAME(s[2]); + } + + if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) +diff --git a/gnushogi/util.c b/gnushogi/util.c +index 85a2182..eee9264 100644 +--- a/gnushogi/util.c ++++ b/gnushogi/util.c +@@ -84,10 +84,10 @@ parse(FILE * fd, unsigned short *mv, short side, char *opening) + return 0; + } + +- c1 = '9' - s[0]; +- r1 = 'i' - s[1]; +- c2 = '9' - s[2]; +- r2 = 'i' - s[3]; ++ c1 = COL_NAME(s[0]); ++ r1 = ROW_NAME(s[1]); ++ c2 = COL_NAME(s[2]); ++ r2 = ROW_NAME(s[3]); + *mv = (locn(r1, c1) << 8) | locn(r2, c2); + + if (c == '?') --- gnushogi-1.3.2.orig/debian/patches/31-MiniShogi-Disable-GuessGameType.patch +++ gnushogi-1.3.2/debian/patches/31-MiniShogi-Disable-GuessGameType.patch @@ -0,0 +1,49 @@ +From 354cd6189dff4fdd000b7012c905d6518fb4a10b Mon Sep 17 00:00:00 2001 +From: Yann Dirson +Date: Wed, 28 Sep 2011 23:27:03 +0200 +Subject: [PATCH 2/4] Disable GuessGameType() for MiniShogi. + +Game types for MiniShogi are surely different from the ones in Shogi, so +this would require serious thought to get it right. Just pretend we don't +know. +--- + gnushogi/eval.c | 8 ++++++++ + 1 files changed, 8 insertions(+), 0 deletions(-) + +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index 0192569..caa0b27 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -2324,6 +2324,7 @@ ScorePosition(short side) + * Try to determine the game type of "side". + */ + ++#ifndef MINISHOGI + inline static void + GuessGameType(short side_to_move) + { +@@ -2457,6 +2458,7 @@ GuessGameType(short side_to_move) + } + } + } ++#endif + + + +@@ -2466,7 +2468,13 @@ DetermineGameType(short side_to_move) + { + short side; + ++#ifndef MINISHOGI ++ /* FIXME: calculations below are wrong for minishogi, all done for 9x9 */ + GuessGameType(side_to_move); ++#else ++ GameType[black] = UNKNOWN; ++ GameType[white] = UNKNOWN; ++#endif + + array_zero(Mpawn, sizeof(Mpawn)); + #ifndef MINISHOGI +-- +1.7.6.3 + --- gnushogi-1.3.2.orig/debian/patches/32-fix-hardcoded.patch +++ gnushogi-1.3.2/debian/patches/32-fix-hardcoded.patch @@ -0,0 +1,26 @@ +From 0450b2be849d7c32157829b2aea038cc266c0c75 Mon Sep 17 00:00:00 2001 +From: Yann Dirson +Date: Thu, 29 Sep 2011 00:03:51 +0200 +Subject: [PATCH 3/4] Fix another hardcored 9x9-board hardcoded value. + +--- + gnushogi/eval.c | 3 ++- + 1 files changed, 2 insertions(+), 1 deletions(-) + +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index caa0b27..81b472e 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -1356,7 +1356,8 @@ PawnValue(short sq, short side) + { + if (crow(c1, sq) == 2) /* pawn on 3d rank */ + { +- if (board[(c1 == black) ? (sq + 27) : (sq - 27)] == pawn) ++ if (board[(c1 == black) ? ++ (sq + 3*NO_COLS) : (sq - 3*NO_COLS)] == pawn) + { + /* opposing pawn has been moved (even column == (sq & 1)) */ + +-- +1.7.6.3 + --- gnushogi-1.3.2.orig/debian/patches/11-refactor-enums.patch +++ gnushogi-1.3.2/debian/patches/11-refactor-enums.patch @@ -0,0 +1,86 @@ +commit c69d5536643c2a75e2ccf1eb0b49de8a6e5d3503 +Author: Yann Dirson +Date: Mon Feb 11 01:46:59 2008 +0100 + + Use enums. + +diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h +index e14f528..f0082a9 100644 +--- a/gnushogi/gnushogi.h ++++ b/gnushogi/gnushogi.h +@@ -238,39 +238,42 @@ extern void movealgbr(short m, char *s); + #define neutral 2 + + /* piece code defines */ +-/* CHECKME: Replace with an enum? */ +-#define no_piece 0 +-#define pawn 1 +-#define lance 2 +-#define knight 3 +-#define silver 4 +-#define gold 5 +-#define bishop 6 +-#define rook 7 +-#define ppawn 8 +-#define plance 9 +-#define pknight 10 +-#define psilver 11 +-#define pbishop 12 +-#define prook 13 +-#define king 14 +- +-#define ptype_no_piece 0 +-#define ptype_pawn 0 +-#define ptype_lance 1 +-#define ptype_knight 2 +-#define ptype_silver 3 +-#define ptype_gold 4 +-#define ptype_bishop 5 +-#define ptype_rook 6 +-#define ptype_pbishop 7 +-#define ptype_prook 8 +-#define ptype_king 9 +-#define ptype_wpawn 10 +-#define ptype_wlance 11 +-#define ptype_wknight 12 +-#define ptype_wsilver 13 +-#define ptype_wgold 14 ++enum { ++ no_piece = 0, ++ pawn, ++ lance, ++ knight, ++ silver, ++ gold, ++ bishop, ++ rook, ++ ppawn, ++ plance, ++ pknight, ++ psilver, ++ pbishop, ++ prook, ++ king ++}; ++ ++enum { ++ ptype_no_piece = 0, ++ ptype_pawn = 0, ++ ptype_lance, ++ ptype_knight, ++ ptype_silver, ++ ptype_gold, ++ ptype_bishop, ++ ptype_rook, ++ ptype_pbishop, ++ ptype_prook, ++ ptype_king, ++ ptype_wpawn, ++ ptype_wlance, ++ ptype_wknight, ++ ptype_wsilver, ++ ptype_wgold ++}; + + /* node flags */ + #define pmask 0x000f /* 15 */ --- gnushogi-1.3.2.orig/debian/patches/30-MiniShogi-ScorePosition.patch +++ gnushogi-1.3.2/debian/patches/30-MiniShogi-ScorePosition.patch @@ -0,0 +1,62 @@ +From 3733051ccccf5fa85b614ec0f2c6d49e832c5b39 Mon Sep 17 00:00:00 2001 +From: Yann Dirson +Date: Wed, 28 Sep 2011 23:25:24 +0200 +Subject: [PATCH 1/4] Fix ScorePosition() for MiniShogi. + +Gcc's stack-smashing protection combined with glibc's -D_FORTIFY_SOURCE +detected with a segfault that we were using 9x9-board offsets on our 5x5 +board. This patch abstracts the relevant hardcoded constants and provides +correct values for MiniShogi. +--- + gnushogi/eval.c | 21 ++++++++++++++++++--- + 1 files changed, 18 insertions(+), 3 deletions(-) + +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index 1dd3bbc..0192569 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -2240,6 +2240,21 @@ ScorePosition(short side) + ScoreCaptures(); + } + ++#ifndef MINISHOGI ++# define BLACKHOME_START 0 ++# define BLACKHOME_END 26 ++# define MIDDLEROW_START 36 ++# define MIDDLEROW_END 44 ++# define WHITEHOME_START 54 ++# define WHITEHOME_END 80 ++#else ++# define BLACKHOME_START 0 ++# define BLACKHOME_END 4 ++# define MIDDLEROW_START 10 ++# define MIDDLEROW_END 14 ++# define WHITEHOME_START 19 ++# define WHITEHOME_END 24 ++#endif + for (c1 = black, c2 = white; c1 <= white; c1++, c2--) + { + short n; +@@ -2247,7 +2262,7 @@ ScorePosition(short side) + fv1 = fvalue[c1]; + + /* Score fifth rank */ +- for (sq = 36, n = 0; sq <= 44; sq++) ++ for (sq = MIDDLEROW_START, n = 0; sq <= MIDDLEROW_END; sq++) + { + if ((color[sq] == c1) || (attack[c1][sq] != 0)) + n++; +@@ -2259,8 +2274,8 @@ ScorePosition(short side) + } + + /* Score holes */ +- for (sq = ((c1 == black) ? 0 : 54), n = 0; +- sq <= ((c1 == black) ? 26 : 80); ++ for (sq = ((c1 == black) ? BLACKHOME_START : WHITEHOME_START), n = 0; ++ sq <= ((c1 == black) ? BLACKHOME_END : WHITEHOME_END); + sq++) + { + if (board[sq] == no_piece && attack[c1][sq] == 0) +-- +1.7.6.3 + --- gnushogi-1.3.2.orig/debian/patches/33-MiniShogi-deadcode.patch +++ gnushogi-1.3.2/debian/patches/33-MiniShogi-deadcode.patch @@ -0,0 +1,149 @@ +From 44abebec132ee3c11366ddbc7d34fb63db3db33e Mon Sep 17 00:00:00 2001 +From: Yann Dirson +Date: Thu, 29 Sep 2011 00:12:07 +0200 +Subject: [PATCH] Avoid looking at the game type to determine minishogi piece + values. + +We don't know how to determine the game type anyway, and a previous +patch disables its computation, but no need to compile dead code in this +case. + +Another problem to look at is that "in_opening_stage" is surely +badly tuned for MiniShogi, but the program seems to score better with +current code that by telling there is opening stage. + +Flag FIXME's where applicable so some willing soul would know where to +find things to improve for MiniShogi. +--- + gnushogi/eval.c | 31 +++++++++++++++++++++++++++++++ + 1 files changed, 31 insertions(+), 0 deletions(-) + +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index 81b472e..e4a5834 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -1383,6 +1383,10 @@ PawnValue(short sq, short side) + } + } + ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + if ((GameType[c1] == STATIC_ROOK) && (sq == csquare(c1, 43))) + { + if ((atk2[csquare(c1, 52)] & CNT_MASK) < 2) +@@ -1404,6 +1408,7 @@ PawnValue(short sq, short side) + s += (ds = -2 * fv1[ATTACKED]); + } + } ++#endif + } + + return s; +@@ -1497,6 +1502,10 @@ SilverValue(short sq, short side) + + if (in_opening_stage) + { ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + if (GameType[c1] == STATIC_ROOK) + { + if (csquare(c1, sq) == 12) +@@ -1510,6 +1519,7 @@ SilverValue(short sq, short side) + } + } + } ++#endif + } + else + { +@@ -1540,6 +1550,10 @@ GoldValue(short sq, short side) + + if (in_opening_stage) + { ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + if ((GameType[c1] == STATIC_ROOK) && (GameType[c2] != STATIC_ROOK)) + { + if (Mvboard[csquare(c1, 3)]) +@@ -1547,6 +1561,7 @@ GoldValue(short sq, short side) + s += (ds = -2 * fv1[OPENWRONG]); + } + } ++#endif + } + else + { +@@ -1569,6 +1584,10 @@ BishopValue(short sq, short side) + + if (in_opening_stage) + { ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + if (GameType[c1] == RANGING_ROOK) + { + /* Bishops diagonal should not be open */ +@@ -1590,6 +1609,7 @@ BishopValue(short sq, short side) + s += (ds = -fv1[OPENWRONG]); + } + } ++#endif + } + else + { +@@ -1614,6 +1634,10 @@ RookValue(short sq, short side) + + if (in_opening_stage) + { ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + short WRONG = fv1[OPENWRONG], OPOK = WRONG / 3; + + if (GameType[c1] == STATIC_ROOK) +@@ -1672,6 +1696,7 @@ RookValue(short sq, short side) + } + } + } ++#endif + } + else + { +@@ -1795,6 +1820,10 @@ KingValue(short sq, short side) + if (fv1[KSFTY] != 0) + s += KingScan(sq); + ++#ifndef MINISHOGI ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 ++ * board - and anyway we don't know the stage really :) ++ */ + if (in_opening_stage) + { + if ((GameType[c1] != UNKNOWN) && (ccolumn(c1, sq) == 4)) +@@ -1810,6 +1839,7 @@ KingValue(short sq, short side) + s += (ds = -fv1[OPENWRONG] / 2); + } + } ++#endif + + /* CHECKME: is this correct? */ + if ((ds = fv1[HOPN])) +@@ -2544,6 +2574,7 @@ ExaminePosition(short side) + + + ++/* FIXME: calculations below are wrong for minishogi, all done for 9x9 */ + void + DetermineStage(short side) + { +-- +1.7.6.3 + --- gnushogi-1.3.2.orig/debian/patches/34-InputCommand-overflow.patch +++ gnushogi-1.3.2/debian/patches/34-InputCommand-overflow.patch @@ -0,0 +1,26 @@ +From 0a65b44bcb552f60a679822b665be693f78aa73d Mon Sep 17 00:00:00 2001 +From: Luis Felipe Strano Moraes +Date: Tue, 13 Mar 2012 17:58:00 -0300 +Subject: [PATCH] Fix buffer overflow, patch by Typone Alfredo + (alfredo@tupone.it). + +--- + gnushogi/commondsp.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index b5b59d7..af9df16 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -1735,7 +1735,7 @@ InputCommand(char *command) + s[0] = sx[0] = '\0'; + + while(!sx[0]) +- (void)fgets(sx, 256, stdin); ++ (void)fgets(sx, 80, stdin); + } + else + { +-- +1.7.10 + --- gnushogi-1.3.2.orig/debian/patches/10-out-of-tree.patch +++ gnushogi-1.3.2/debian/patches/10-out-of-tree.patch @@ -0,0 +1,272 @@ +commit 6cde91d2c4b6bd61cfb8e26837f019df8f7058d4 +Author: Yann Dirson +Date: Mon Feb 11 01:46:59 2008 +0100 + + Add support for building gnushogi and xshogi out of source tree. + +diff --git a/gnushogi/Makefile.in b/gnushogi/Makefile.in +index 1fb7f4f..584da68 100644 +--- a/gnushogi/Makefile.in ++++ b/gnushogi/Makefile.in +@@ -35,8 +35,10 @@ VERS = 1.3 + INSTALL = @INSTALL@ + INSTALL_DATA = @INSTALL_DATA@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ +-ROOT = .. ++ROOT = @top_srcdir@ ++SRCDIR = @srcdir@ + ++VPATH=$(SRCDIR) + + # Installation directory. + prefix = @prefix@ +@@ -68,7 +70,7 @@ LCURSES = -lcurses -ltermcap + CC = @CC@ + CWARNINGS = @WARNINGS@ + CEXTRAFLAGS = @CEXTRAFLAGS@ +-CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I.. ++CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(CWARNINGS) -I$(ROOT) -I@top_builddir@ + + + # The hashfile is a record of positions seen. It is used by +@@ -151,68 +153,68 @@ profile: + + # Common files. + +-attacks.o: +- $(CC) $(CFLAGS) -c attacks.c ++attacks.o: attacks.c ++ $(CC) $(CFLAGS) -c $< + +-book.o: +- $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c book.c ++book.o: book.c ++ $(CC) $(CFLAGS) $(TEXTBOOK) $(BINBOOK) -c $< + +-commondsp.o: +- $(CC) $(CFLAGS) -c commondsp.c ++commondsp.o: commondsp.c ++ $(CC) $(CFLAGS) -c $< + +-cursesdsp.o: +- $(CC) $(CFLAGS) -c cursesdsp.c ++cursesdsp.o: cursesdsp.c ++ $(CC) $(CFLAGS) -c $< + +-dspwrappers.o: +- $(CC) $(CFLAGS) -c dspwrappers.c ++dspwrappers.o: dspwrappers.c ++ $(CC) $(CFLAGS) -c $< + +-genmove.o: +- $(CC) $(CFLAGS) -c genmove.c ++genmove.o: genmove.c ++ $(CC) $(CFLAGS) -c $< + +-globals.o: +- $(CC) $(CFLAGS) -c globals.c ++globals.o: globals.c ++ $(CC) $(CFLAGS) -c $< + +-eval.o: +- $(CC) $(CFLAGS) -c eval.c ++eval.o: eval.c ++ $(CC) $(CFLAGS) -c $< + +-init.o: +- $(CC) $(CFLAGS) $(LANGF) -c init.c ++init.o: init.c ++ $(CC) $(CFLAGS) $(LANGF) -c $< + +-main.o: +- $(CC) $(CFLAGS) $(BINBOOK) -c main.c ++main.o: main.c ++ $(CC) $(CFLAGS) $(BINBOOK) -c $< + + # To create "pattern.inc" with "pat2inc", the external + # pattern textfile must be used. + +-makepattern.o: +- $(CC) $(CFLAGS) $(PATTERN) -c makepattern.c ++makepattern.o: makepattern.c ++ $(CC) $(CFLAGS) $(PATTERN) -c $< + +-pattern.o: +- $(CC) $(CFLAGS) -c pattern.c ++pattern.o: pattern.c ++ $(CC) $(CFLAGS) -c $< + +-rawdsp.o: +- $(CC) $(CFLAGS) -c rawdsp.c ++rawdsp.o: rawdsp.c ++ $(CC) $(CFLAGS) -c $< + +-search.o: +- $(CC) $(CFLAGS) -c search.c ++search.o: search.c ++ $(CC) $(CFLAGS) -c $< + +-sysdeps.o: +- $(CC) $(CFLAGS) -c sysdeps.c ++sysdeps.o: sysdeps.c ++ $(CC) $(CFLAGS) -c $< + +-tcontrl.o: +- $(CC) $(CFLAGS) -c tcontrl.c ++tcontrl.o: tcontrl.c ++ $(CC) $(CFLAGS) -c $< + +-util.o: +- $(CC) $(CFLAGS) -c util.c ++util.o: util.c ++ $(CC) $(CFLAGS) -c $< + + + # Files specific to particular targets. + +-pat2inc.o: +- $(CC) $(CFLAGS) $(LANGF) $(BINBOOK) $(PATTERN) -c pat2inc.c ++pat2inc.o: pat2inc.c ++ $(CC) $(CFLAGS) $(LANGF) $(BINBOOK) $(PATTERN) -c $< + +-sizetest.o: +- $(CC) $(CFLAGS) -c sizetest.c ++sizetest.o: sizetest.c ++ $(CC) $(CFLAGS) -c $< + + + # +@@ -222,7 +224,7 @@ sizetest.o: + gnushogi.bbk: + @if [ -f ./gnushogi.bbk ]; then rm ./gnushogi.bbk; fi + echo quit > test +- cat ../misc/gnushogi.tbk > _tmp_t ++ cat $(ROOT)/misc/gnushogi.tbk > _tmp_t + cat test | ./gnushogi -R -b _tmp_t -B ./gnushogi.bbk -S 8000 -P 40 3 0 + rm test _tmp_t + @echo +@@ -263,24 +265,24 @@ clean: + gnushogi: $(GNUSHOGI_FILES) + pat2inc: $(PAT2INCFILES) + sizetest: sizetest.o +-attacks.o: attacks.c gnushogi.h ../version.h +-book.o: book.c gnushogi.h ../version.h +-commondsp.o: commondsp.c gnushogi.h ../version.h +-cursesdsp.o: cursesdsp.c gnushogi.h ../version.h +-dspwrappers.o: dspwrappers.c gnushogi.h ../version.h +-genmove.o: genmove.c gnushogi.h ../version.h +-globals.o: globals.c gnushogi.h ../version.h +-eval.o: eval.c eval.h gnushogi.h ../version.h pattern.h +-init.o: init.c gnushogi.h ../version.h pattern.h +-main.o: main.c gnushogi.h ../version.h +-makepattern.o: pattern.c gnushogi.h pattern.h +-pattern.o: pattern.c gnushogi.h pattern.h pattern.inc +-rawdsp.o: rawdsp.c gnushogi.h ../version.h +-search.o: search.c gnushogi.h ../version.h +-sysdeps.o: sysdeps.c gnushogi.h ../version.h +-tcontrl.o: tcontrl.c gnushogi.h ../version.h +-util.o: util.c gnushogi.h ../version.h +-pat2inc.o: pat2inc.c pattern.h gnushogi.h +-sizetest.o: sizetest.c gnushogi.h eval.h ++attacks.o: attacks.c gnushogi.h $(ROOT)/version.h ++book.o: book.c gnushogi.h $(ROOT)/version.h ++commondsp.o: commondsp.c gnushogi.h $(ROOT)/version.h ++cursesdsp.o: cursesdsp.c gnushogi.h $(ROOT)/version.h ++dspwrappers.o: dspwrappers.c gnushogi.h $(ROOT)/version.h ++genmove.o: genmove.c gnushogi.h $(ROOT)/version.h ++globals.o: globals.c gnushogi.h $(ROOT)/version.h ++eval.o: eval.c eval.h gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h ++init.o: init.c gnushogi.h $(ROOT)/version.h $(SRCDIR)/pattern.h ++main.o: main.c gnushogi.h $(ROOT)/version.h ++makepattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h ++pattern.o: pattern.c gnushogi.h $(SRCDIR)/pattern.h $(SRCDIR)/pattern.inc ++rawdsp.o: rawdsp.c gnushogi.h $(ROOT)/version.h ++search.o: search.c gnushogi.h $(ROOT)/version.h ++sysdeps.o: sysdeps.c gnushogi.h $(ROOT)/version.h ++tcontrl.o: tcontrl.c gnushogi.h $(ROOT)/version.h ++util.o: util.c gnushogi.h $(ROOT)/version.h ++pat2inc.o: pat2inc.c $(SRCDIR)/pattern.h $(SRCDIR)/gnushogi.h ++sizetest.o: sizetest.c $(SRCDIR)/gnushogi.h $(SRCDIR)/eval.h + gnushogi.bbk: gnushogi + +diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h +index 423a864..e14f528 100644 +--- a/gnushogi/gnushogi.h ++++ b/gnushogi/gnushogi.h +@@ -39,7 +39,7 @@ + #ifndef _GNUSHOGI_H_ + #define _GNUSHOGI_H_ + +-#include "../config.h" /* Portability #defines. */ ++#include "config.h" /* Portability #defines. */ + #include "debug.h" + #include "opts.h" /* Various option-setting #defines. */ + +diff --git a/xshogi/Makefile.in b/xshogi/Makefile.in +index 7840912..eafc13c 100644 +--- a/xshogi/Makefile.in ++++ b/xshogi/Makefile.in +@@ -33,7 +33,10 @@ VERS = 1.3 + INSTALL = @INSTALL@ + INSTALL_DATA = @INSTALL_DATA@ + INSTALL_PROGRAM = @INSTALL_PROGRAM@ +-ROOT = .. ++ROOT = @top_srcdir@ ++SRCDIR = @srcdir@ ++ ++VPATH=$(SRCDIR) + + + # +@@ -61,7 +64,7 @@ CC = @CC@ + XINCLUDES = @X_CFLAGS@ + CWARNINGS = @WARNINGS@ + CEXTRAFLAGS = @CEXTRAFLAGS@ +-CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(XINCLUDES) -I.. ++CFLAGS = @CFLAGS@ $(CEXTRAFLAGS) $(XINCLUDES) -I$(ROOT) -I@top_builddir@ + LIBS = + XLIBS = @X_LIBS@ -lXaw -lXmu -lXt -lXext -lX11 + LDFLAGS = $(XLIBS) $(LIBS) +@@ -83,8 +86,8 @@ all: xshogi + xshogi: + $(CC) -o xshogi xshogi.o parser.o $(CFLAGS) $(LDFLAGS) + +-xshogi.o: +- $(CC) -c xshogi.c $(CWARNINGS) $(CFLAGS) \ ++xshogi.o: xshogi.c ++ $(CC) -c $< $(CWARNINGS) $(CFLAGS) \ + $(OPT) $(FIRST_SHOGI_PROGRAM) $(SECOND_SHOGI_PROGRAM) \ + $(FIRST_HOST) $(SECOND_HOST) + +@@ -94,15 +97,15 @@ xshogi.o: + # is #included into parser.y. + # + +-parser.o: +- $(CC) -c parser.c $(CFLAGS) ++parser.o: parser.c ++ $(CC) $(CFLAGS) -I$(SRCDIR) -c $< + +-parser.c: +- $(YACC) parser.y ++parser.c: parser.y ++ $(YACC) $< + mv y.tab.c parser.c + + scanner.c: scanner.l +- $(LEX) scanner.l ++ $(LEX) $< + mv lex.yy.c scanner.c + + +@@ -142,8 +145,8 @@ clean: + # + + xshogi: xshogi.o parser.o +-xshogi.o: xshogi.c sysdeps.h xshogi.h bitmaps.h ../version.h ../config.h +-parser.o: parser.c xshogi.h ++xshogi.o: xshogi.c $(SRCDIR)/sysdeps.h $(SRCDIR)/xshogi.h $(SRCDIR)/bitmaps.h $(ROOT)/version.h ../config.h ++parser.o: parser.c $(SRCDIR)/xshogi.h + parser.c: parser.y scanner.c + scanner.c: scanner.l + --- gnushogi-1.3.2.orig/debian/patches/22-format-string.patch +++ gnushogi-1.3.2/debian/patches/22-format-string.patch @@ -0,0 +1,250 @@ +From 813c43b9e58ee7d102e2562cff88b51aeb44852a Mon Sep 17 00:00:00 2001 +From: Yann Dirson +Date: Tue, 27 Sep 2011 22:31:11 +0200 +Subject: [PATCH] Deal with warnings raised by -Wformat-security. + +--- + gnushogi/book.c | 3 +-- + gnushogi/commondsp.c | 18 +++++++++--------- + gnushogi/main.c | 6 +++--- + gnushogi/rawdsp.c | 40 ++++++++++++++++++++-------------------- + 4 files changed, 33 insertions(+), 34 deletions(-) + +diff --git a/gnushogi/book.c b/gnushogi/book.c +index e379363..42a6dcd 100644 +--- a/gnushogi/book.c ++++ b/gnushogi/book.c +@@ -293,8 +293,7 @@ BVerifyMove(char *s, unsigned short *mv, int moveno) + /* Illegal move in check */ + #if !defined QUIETBOOKGEN + /* 077: "Illegal move (in check) %s" */ +- printf(CP[77]); +- printf("\n"); ++ puts(CP[77]); + bkdisplay(s, cnt, moveno); + #endif + return false; +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index fb49521..2f0024b 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -723,12 +723,12 @@ SaveGame(void) + + fprintf(fd, CP[37], w, b, Game50, + flag.force ? "force" : ""); +- fprintf(fd, empty); ++ fputs(empty, fd); + fprintf(fd, CP[111], TCflag, OperatorTime); + fprintf(fd, CP[117], + TimeControl.clock[black], TimeControl.moves[black], + TimeControl.clock[white], TimeControl.moves[white]); +- fprintf(fd, empty); ++ fputs(empty, fd); + + for (i = NO_ROWS - 1; i > -1; i--) + { +@@ -766,14 +766,14 @@ SaveGame(void) + fprintf(fd, "\n"); + } + +- fprintf(fd, empty); ++ fputs(empty, fd); + #ifndef MINISHOGI + fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); +- fprintf(fd, empty); ++ fputs(empty, fd); + fprintf(fd, " p l n s g b r k\n"); + #else + fprintf(fd, " 5 4 3 2 1\n"); +- fprintf(fd, empty); ++ fputs(empty, fd); + fprintf(fd, " p s g b r k\n"); + #endif + +@@ -793,8 +793,8 @@ SaveGame(void) + fprintf(fd, "\n"); + } + +- fprintf(fd, empty); +- fprintf(fd, CP[126]); ++ fputs(empty, fd); ++ fputs(CP[126], fd); + + for (i = 1; i <= GameCnt; i++) + { +@@ -1233,8 +1233,8 @@ ListGame(void) + + /* fprintf(fd, "gnushogi game %d\n", u); */ + fprintf(fd, CP[161], version, patchlevel); +- fprintf(fd, CP[10]); +- fprintf(fd, CP[11]); ++ fputs(CP[10], fd); ++ fputs(CP[11], fd); + + for (i = 1; i <= GameCnt; i++) + { +diff --git a/gnushogi/main.c b/gnushogi/main.c +index ccbfe87..79f2e28 100644 +--- a/gnushogi/main.c ++++ b/gnushogi/main.c +@@ -211,7 +211,7 @@ main (int argc, char **argv) + long j; + struct fileentry n; + +- printf(CP[66]); ++ fputs(CP[66], stdout); + n.f = n.t = 0; + n.flags = 0; + n.depth = 0; +@@ -245,7 +245,7 @@ main (int argc, char **argv) + int nr[MAXDEPTH]; + struct fileentry n; + +- printf(CP[49]); ++ fputs(CP[49], stdout); + + for (i = 0; i < MAXDEPTH; i++) + nr[i] = 0; +@@ -308,7 +308,7 @@ main (int argc, char **argv) + + + default: +- fprintf(stderr, CP[113]); ++ fputs(CP[113], stderr); + exit(1); + } + +diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c +index 90897d1..d890ef7 100644 +--- a/gnushogi/rawdsp.c ++++ b/gnushogi/rawdsp.c +@@ -66,7 +66,7 @@ PromptForMove(void) + if (!barebones && !XSHOGI) + { + /* printf("\nYour move is? "); */ +- printf(CP[124]); ++ fputs(CP[124], stdout); + } + } + +@@ -246,7 +246,7 @@ Raw_help(void) + "------------------------------\n"); + /* printf("7g7f move from 7g to 7f quit + * Exit Shogi\n"); */ +- printf(CP[158]); ++ fputs(CP[158], stdout); + /* printf("S6h move silver to 6h beep + * turn %s\n", (flag.beep) ? "off" : "on"); */ + printf(CP[86], (flag.beep) ? CP[92] : CP[93]); +@@ -260,36 +260,36 @@ Raw_help(void) + printf(CP[174], (flag.hash) ? CP[92] : CP[93]); + /* printf("bd redraw board reverse + * board display\n"); */ +- printf(CP[130]); ++ fputs(CP[130], stdout); + /* printf("list game to shogi.lst book + * turn %s used %d of %d\n", (Book) ? "off" : "on", bookcount); */ + printf(CP[170], (Book) ? CP[92] : CP[93], bookcount, booksize); + /* printf("undo undo last ply remove + * take back a move\n"); */ +- printf(CP[200]); ++ fputs(CP[200], stdout); + /* printf("edit edit board force + * enter game moves\n"); */ +- printf(CP[153]); ++ fputs(CP[153], stdout); + /* printf("switch sides with computer both + * computer match\n"); */ +- printf(CP[194]); ++ fputs(CP[194], stdout); + /* printf("black computer plays black white + * computer plays white\n"); */ +- printf(CP[202]); ++ fputs(CP[202], stdout); + /* printf("depth set search depth clock + * set time control\n"); */ +- printf(CP[149]); ++ fputs(CP[149], stdout); + /* printf("post principle variation hint + * suggest a move\n"); */ +- printf(CP[177]); ++ fputs(CP[177], stdout); + /* printf("save game to file get + * game from file\n"); */ +- printf(CP[188]); ++ fputs(CP[188], stdout); + printf("xsave pos. to xshogi file xget" + " pos. from xshogi file\n"); + /* printf("random randomize play new + * start new game\n"); */ +- printf(CP[181]); ++ fputs(CP[181], stdout); + printf("--------------------------------" + "--------------------------------\n"); + /* printf("Computer: %-12s Opponent: %s\n", */ +@@ -335,13 +335,13 @@ Raw_EditBoard(void) + Raw_ClearScreen(); + Raw_UpdateDisplay(0, 0, 1, 0); + /* printf(". exit to main\n"); */ +- printf(CP[29]); ++ fputs(CP[29], stdout); + /* printf("# clear board\n"); */ +- printf(CP[28]); ++ fputs(CP[28], stdout); + /* printf("c change sides\n"); */ +- printf(CP[136]); ++ fputs(CP[136], stdout); + /* printf("enter piece & location: \n"); */ +- printf(CP[155]); ++ fputs(CP[155], stdout); + + a = black; + +@@ -479,7 +479,7 @@ SetupBoard(void) + Raw_ClearScreen(); + Raw_UpdateDisplay(0, 0, 1, 0); + /* printf("Setup successful\n"); */ +- printf(CP[106]); ++ fputs(CP[106], stdout); + } + + +@@ -571,7 +571,7 @@ Raw_OutputMove(void) + if (root->flags & draw) + { + /* printf("Drawn game!\n"); */ +- printf(CP[57]); ++ fputs(CP[57], stdout); + } + else if (root->score == -(SCORE_LIMIT + 999)) + { +@@ -688,7 +688,7 @@ Raw_GiveHint(void) + printf(CP[72], mvstr[0]); /*hint*/ + } + else +- printf(CP[223]); ++ fputs(CP[223], stdout); + } + + +@@ -715,7 +715,7 @@ Raw_SelectLevel(char *sx) + /* line empty ask for input */ + if (!T[0]) + { +- printf(CP[61]); ++ fputs(CP[61], stdout); + fgets(T, NO_SQUARES + 1, stdin); + strcat(T, "XX"); + } +@@ -746,7 +746,7 @@ Raw_SelectLevel(char *sx) + TCseconds = 0; + + #ifdef OPERATORTIME +- printf(CP[94]); ++ fputs(CP[94], stdout); + scanf("%hd", &OperatorTime); + #endif + +-- +1.7.6.3 + --- gnushogi-1.3.2.orig/debian/patches/14-internals-doc.patch +++ gnushogi-1.3.2/debian/patches/14-internals-doc.patch @@ -0,0 +1,71 @@ +commit 6437a3e4315fe69a488bc73507dc2c05017c1602 +Author: Yann Dirson +Date: Mon Feb 11 01:47:00 2008 +0100 + + Document internal APIs. + +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index 5251649..183cec7 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -128,6 +128,17 @@ movealgbr(short m, char *s) + + /* + * Generate move strings in different formats. ++ * ++ * INPUT: ++ * - f piece to be moved ++ * - 0 < f < NO_SQUARES source square ++ * - NO_SQUARES <= f NO_SQUARES + 2*NO_PIECES dropped piece modulo NO_PIECES ++ * - t & 0x7f target square ++ * - t & 0x80 promotion flag ++ * - flag FIXME: must be zero ? ++ * ++ * OUTPUT: ++ * - GLOBAL mvstr + */ + + void +diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h +index c05a7b9..2e03cc4 100644 +--- a/gnushogi/gnushogi.h ++++ b/gnushogi/gnushogi.h +@@ -258,6 +258,7 @@ enum { + king + }; + ++/* move types */ + enum { + ptype_no_piece = 0, + ptype_pawn = 0, +diff --git a/gnushogi/init.c b/gnushogi/init.c +index ff28830..2dc8e94 100644 +--- a/gnushogi/init.c ++++ b/gnushogi/init.c +@@ -313,12 +313,12 @@ Initialize_dist(void) + + + /* +- * nextpos[piece][from-square], nextdir[piece][from-square] gives vector +- * of positions reachable from from-square in ppos with piece such that the ++ * nextpos[ptype][from-square], nextdir[ptype][from-square] gives vector ++ * of positions reachable from from-square in ppos with ptype such that the + * sequence + * +- * ppos = nextpos[piece][from-square]; +- * pdir = nextdir[piece][from-square]; ++ * ppos = nextpos[ptype][from-square]; ++ * pdir = nextdir[ptype][from-square]; + * u = ppos[sq]; + * + * do +@@ -517,6 +517,9 @@ Initialize_moves(void) + short steps[8]; + short fpo = inunmap[0], tpo = 1 + inunmap[NO_SQUARES-1]; + ++ /* pre-fill nextpos and nextdir with source position, probably so ++ * (color[u] == neutral) stops to match once all moves have been seen ++ */ + for (ptyp = 0; ptyp < NO_PTYPE_PIECES; ptyp++) + { + for (po = 0; po < NO_SQUARES; po++) --- gnushogi-1.3.2.orig/debian/patches/20-minishogi.patch +++ gnushogi-1.3.2/debian/patches/20-minishogi.patch @@ -0,0 +1,1052 @@ +commit bfb2c3f6c1710a623471f67a02a861d5d88d3a7c +Author: Yann Dirson +Date: Mon Feb 11 01:47:00 2008 +0100 + + Initial attempt at minishogi. + + This preliminar minishogi takes the approach of conditional + compilation, so I can focus on differences between shogi and + minishogi. Those ifdef's are expected to progressively disappear as + the support code is made generic enough to support the needs of both + variants. + +diff --git a/TODO b/TODO +new file mode 100644 +index 0000000..12b25b5 +--- /dev/null ++++ b/TODO +@@ -0,0 +1,28 @@ ++Generic cleanups ++ ++- hunt for more hardcoded variant-specific constants ++ - position of captured pieces in curses mode ++ - compile with bound-checker ++- add autosave mode to ease hunt for segfaults ? ++- generate patterns.inc at build-time ++- use 2D array for the board, get rid of the (i)nunmap stuff ++- fixup build procedure to support parallel make runs ++- investigate those preexisting "overflow in implicit constant ++ conversion" warnings ++ ++Minishogi-related stuff ++ ++- make minishogi a run-time option rather than a compile-time one ++- minishogi patterns ++- tune difficulty levels ++- other tunings to investigate ++ * PromotionZoneDistanceBonus ++ * OPENING_HINT ++- add minishogi stuff to the doc ++- use valid minishogi moves in online help ++ ++- segfault (on level 1) following 2e1d 1d4a ++ => field.piece can reach 14 in pattern.c::update_advance_bonus ++ => probably related to using patterns for standard shogi ++ => must break the circular pattern.o <-> pattern.inc dep to ++ be able to generated pattern.inc as needed +diff --git a/gnushogi/attacks.c b/gnushogi/attacks.c +index e70f358..efe10ac 100644 +--- a/gnushogi/attacks.c ++++ b/gnushogi/attacks.c +@@ -118,6 +118,7 @@ SqAttacked(short square, short side, short *blockable) + } + while (u != square); + ++#ifndef MINISHOGI + /* try a knight capture (using xside's knight moves) */ + + ptyp = ptype[side ^ 1][knight]; +@@ -141,6 +142,7 @@ SqAttacked(short square, short side, short *blockable) + #endif + } + while (u != square); ++#endif /* MINISHOGI */ + + *blockable = true; + +@@ -216,6 +218,7 @@ SqAttacked(short square, short side, short *blockable) + } + while (u != square); + ++#ifndef MINISHOGI + /* try a lance capture (using xside's lance moves) */ + + ptyp = ptype[side ^ 1][lance]; +@@ -248,6 +251,7 @@ SqAttacked(short square, short side, short *blockable) + } + } + while (u != square); ++#endif /* MINISHOGI */ + + return false; + } +diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c +index 183cec7..fb49521 100644 +--- a/gnushogi/commondsp.c ++++ b/gnushogi/commondsp.c +@@ -584,10 +584,12 @@ GetGame(void) + skipb(); + Captured[side][pawn] = atoi(InPtr); + skip(); ++#ifndef MINISHOGI + Captured[side][lance] = atoi(InPtr); + skip(); + Captured[side][knight] = atoi(InPtr); + skip(); ++#endif + Captured[side][silver] = atoi(InPtr); + skip(); + Captured[side][gold] = atoi(InPtr); +@@ -765,16 +767,24 @@ SaveGame(void) + } + + fprintf(fd, empty); +- fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); /* FIXME */ ++#ifndef MINISHOGI ++ fprintf(fd, " 9 8 7 6 5 4 3 2 1\n"); + fprintf(fd, empty); + fprintf(fd, " p l n s g b r k\n"); ++#else ++ fprintf(fd, " 5 4 3 2 1\n"); ++ fprintf(fd, empty); ++ fprintf(fd, " p s g b r k\n"); ++#endif + + for (side = 0; side <= 1; side++) + { + fprintf(fd, "%c", (side == black) ? 'B' : 'W'); + fprintf(fd, " %2d", Captured[side][pawn]); ++#ifndef MINISHOGI + fprintf(fd, " %2d", Captured[side][lance]); + fprintf(fd, " %2d", Captured[side][knight]); ++#endif + fprintf(fd, " %2d", Captured[side][silver]); + fprintf(fd, " %2d", Captured[side][gold]); + fprintf(fd, " %2d", Captured[side][bishop]); +@@ -938,10 +948,12 @@ GetXGame(void) + InPtr = fname; + Captured[side][pawn] = atoi(InPtr); + skip(); ++#ifndef MINISHOGI + Captured[side][lance] = atoi(InPtr); + skip(); + Captured[side][knight] = atoi(InPtr); + skip(); ++#endif + Captured[side][silver] = atoi(InPtr); + skip(); + Captured[side][gold] = atoi(InPtr); +@@ -1035,10 +1047,17 @@ SaveXGame(void) + + for (side = 0; side <= 1; side++) + { +- sprintf(fname, "%d %d %d %d %d %d %d %d\n", ++ sprintf(fname, ++#ifndef MINISHOGI ++ "%d %d %d %d %d %d %d %d\n", ++#else ++ "%d %d %d %d %d %d\n", ++#endif + Captured[side][pawn], ++#ifndef MINISHOGI + Captured[side][lance], + Captured[side][knight], ++#endif + Captured[side][silver], + Captured[side][gold], + Captured[side][bishop], +diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c +index 78feaa0..5d9e20f 100644 +--- a/gnushogi/cursesdsp.c ++++ b/gnushogi/cursesdsp.c +@@ -853,10 +853,17 @@ Curses_UpdateDisplay(short f, short t, short redraw, short isspec) + gotoXY(3, 4 + 2*NO_ROWS); + printw(" "); + ++#ifndef MINISHOGI + if (flag.reverse) + printw(CP[16]); + else + printw(CP[15]); ++#else ++ if (flag.reverse) ++ printw(CP[240]); ++ else ++ printw(CP[239]); ++#endif + + for (sq = 0; sq < NO_SQUARES; sq++) + DrawPiece(sq); +diff --git a/gnushogi/eval.c b/gnushogi/eval.c +index 7ba3b3d..1dd3bbc 100644 +--- a/gnushogi/eval.c ++++ b/gnushogi/eval.c +@@ -44,6 +44,7 @@ int PUTVAR = false; /* shall the current scoring be cached? */ + + /* Pieces and colors of initial board setup */ + ++#ifndef MINISHOGI + const small_short Stboard[NO_SQUARES] = + { + lance, knight, silver, gold, king, gold, silver, knight, lance, +@@ -79,8 +80,27 @@ const small_short Stcolor[NO_SQUARES] = + white, white, white, white, + white, white, white, white, white + }; ++#else ++const small_short Stboard[NO_SQUARES] = ++{ ++ king, gold, silver, bishop, rook, ++ pawn, 0, 0, 0, 0, ++ 0, 0, 0, 0, 0, ++ 0, 0, 0, 0, pawn, ++ rook, bishop, silver, gold, king, ++}; + + ++const small_short Stcolor[NO_SQUARES] = ++{ ++ black, black, black, black, black, ++ black, neutral, neutral, neutral, neutral, ++ neutral, neutral, neutral, neutral, neutral, ++ neutral, neutral, neutral, neutral, white, ++ white, white, white, white, white ++}; ++#endif ++ + /* Actual pieces and colors */ + + small_short board[NO_SQUARES], color[NO_SQUARES]; +@@ -95,15 +115,19 @@ static small_short ispvalue[NO_PIECES][MAIN_STAGES] = + { 0, 35, 70, 99 }, /* main stage borders */ + /* ------------------------------------------ */ + { 7, 7, 8, 10 }, /* Pawn */ ++#ifndef MINISHOGI + { 20, 35, 45, 60 }, /* Lance */ + { 20, 35, 45, 60 }, /* Knight */ ++#endif + { 35, 40, 60, 80 }, /* Silver */ + { 35, 50, 65, 80 }, /* Gold */ + { 90, 90, 90, 90 }, /* Bishop */ + { 95, 95, 95, 95 }, /* Rook */ + { 15, 25, 40, 65 }, /* promoted Pawn */ ++#ifndef MINISHOGI + { 25, 45, 55, 65 }, /* promoted Lance */ + { 25, 45, 55, 65 }, /* promoted Knight */ ++#endif + { 35, 55, 75, 75 }, /* promoted Silver */ + { 99, 99, 99, 99 }, /* promoted Bishop */ + { 97, 97, 99, 99 }, /* promoted Rook */ +@@ -192,8 +216,13 @@ static const short OwnKingDistanceBonus[10] = + { 0, 5, 2, 1, 0, -1, -2, -3, -4, -5 }; + + /* distance to promotion zone */ ++#ifndef MINISHOGI + static const int PromotionZoneDistanceBonus[NO_ROWS] = + { 0, 0, 0, 0, 2, 6, 6, 8, 8 }; ++#else ++static const int PromotionZoneDistanceBonus[NO_ROWS] = ++{ 0, 0, 2, 6, 8 }; /* FIXME ? */ ++#endif + + #define MAX_BMBLTY 20 + #define MAX_RMBLTY 20 +@@ -207,12 +236,22 @@ static const short BMBLTY[MAX_BMBLTY] = + static const short RMBLTY[MAX_RMBLTY] = + { 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 14, 14, 16, 16, 16, 16 }; + ++#ifndef MINISHOGI + /* Lance mobility bonus indexed by # reachable squares */ + static const short LMBLTY[MAX_LMBLTY] = + { 0, 0, 0, 0, 4, 6, 8, 10 }; ++#endif + + static const short MBLTY[NO_PIECES] = +-{ 0, 2, 1, 10, 5, 5, 1, 1, 5, 5, 5, 5, 1, 1, 4 }; ++{ 0, 2, ++#ifndef MINISHOGI ++ 1, 10, ++#endif ++ 5, 5, 1, 1, 5, ++#ifndef MINISHOGI ++ 5, 5, ++#endif ++ 5, 1, 1, 4 }; + + static const short KTHRT[36] = + { 0, -8, -20, -36, -52, -68, -80, -80, -80, -80, -80, -80, +@@ -255,17 +294,30 @@ static small_short Mpawn [2][NO_SQUARES]; + static small_short Msilver[2][NO_SQUARES]; + static small_short Mgold [2][NO_SQUARES]; + static small_short Mking [2][NO_SQUARES]; ++#ifndef MINISHOGI + static small_short Mlance [2][NO_SQUARES]; + static small_short Mknight[2][NO_SQUARES]; ++#endif + static small_short Mbishop[2][NO_SQUARES]; + static small_short Mrook [2][NO_SQUARES]; + +-static Mpiece_array Mpawn, Mlance, Mknight, Msilver, Mgold, +- Mbishop, Mrook, Mking; ++static Mpiece_array Mpawn, ++#ifndef MINISHOGI ++ Mlance, Mknight, ++#endif ++ Msilver, Mgold, Mbishop, Mrook, Mking; + + Mpiece_array *Mpiece[NO_PIECES] = +-{ NULL, &Mpawn, &Mlance, &Mknight, &Msilver, &Mgold, &Mbishop, &Mrook, +- &Mgold, &Mgold, &Mgold, &Mgold, &Mbishop, &Mrook, &Mking }; ++{ NULL, &Mpawn, ++#ifndef MINISHOGI ++ &Mlance, &Mknight, ++#endif ++ &Msilver, &Mgold, &Mbishop, &Mrook, ++ &Mgold, ++#ifndef MINISHOGI ++ &Mgold, &Mgold, ++#endif ++ &Mgold, &Mbishop, &Mrook, &Mking }; + + + static short c1, c2; +@@ -478,11 +530,13 @@ CheckTargetPiece(short sq, short side) + add_target(sq, side, 11); + break; + ++#ifndef MINISHOGI + case knight: /* vertically ahead if advanced */ + /* FIXME: gotta love them magic numbers... */ + if ((sq != 1) && (sq != 7) && (sq != 73) && (sq != 79)) + add_target(sq, side, 11); + break; ++#endif + } + } + +@@ -847,6 +901,7 @@ BRLscan(short sq, short *mob) + /* it's the first piece in the current direction */ + if (color[u] == c1) + { ++#ifndef MINISHOGI + /* own intercepting piece in x-ray attack */ + if (upiece == lance) + { +@@ -861,6 +916,7 @@ BRLscan(short sq, short *mob) + } + } + else ++#endif + { + /* bishop or rook x-ray */ + if ((upiece == bishop) && (board[u] == pawn) +@@ -868,17 +924,20 @@ BRLscan(short sq, short *mob) + { + s += (ds = -2*fv1[HCLSD]); + } ++#ifndef MINISHOGI + else if ((upiece == rook) && (board[u] == lance) + && (GameType[c1] == STATIC_ROOK) + && (column(u) == csq)) + { + s += (ds = fv1[XRAY]); + } ++#endif + } + } + else + { + /* enemy's intercepting piece in pin attack */ ++#ifndef MINISHOGI + if (upiece == lance) + { + /* lance pin attack */ +@@ -892,6 +951,7 @@ BRLscan(short sq, short *mob) + } + } + else ++#endif + { + /* bishop or rook pin attack */ + if (board[u] == pawn) +@@ -958,11 +1018,13 @@ BRLscan(short sq, short *mob) + } + else + { ++#ifndef MINISHOGI + if (upiece == lance) + { + s += (ds = fv1[XRAY] / 2); + } + else ++#endif + { + s += (ds = fv1[XRAY]); + } +@@ -1347,7 +1409,7 @@ PawnValue(short sq, short side) + } + + +- ++#ifndef MINISHOGI + /* + * Calculate the positional value for a lance on 'sq'. + */ +@@ -1411,6 +1473,7 @@ KnightValue(short sq, short side) + + return s; + } ++#endif + + + +@@ -1635,6 +1698,7 @@ PPawnValue(short sq, short side) + + + ++#ifndef MINISHOGI + /* + * Calculate the positional value for a promoted lance on 'sq'. + */ +@@ -1664,6 +1728,7 @@ PKnightValue(short sq, short side) + + return s; + } ++#endif + + + +@@ -1784,8 +1849,10 @@ PieceValue(short sq, short side) + s += (ds = BMBLTY[mob] * fv1[MOBILITY] / 100); + else if ((piece == rook) || (piece == prook)) + s += (ds = RMBLTY[mob] * fv1[MOBILITY] / 100); ++#ifndef MINISHOGI + else + s += (ds = LMBLTY[mob] * fv1[MOBILITY] / 100); ++#endif + } + else + { +@@ -1877,6 +1944,7 @@ PieceValue(short sq, short side) + s += PawnValue(sq, side); + break; + ++#ifndef MINISHOGI + case lance: + s += LanceValue(sq, side); + break; +@@ -1884,6 +1952,7 @@ PieceValue(short sq, short side) + case knight: + s += KnightValue(sq, side); + break; ++#endif + + case silver: + s += SilverValue(sq, side); +@@ -1909,6 +1978,7 @@ PieceValue(short sq, short side) + s += PPawnValue(sq, side); + break; + ++#ifndef MINISHOGI + case plance: + s += PLanceValue(sq, side); + break; +@@ -1916,6 +1986,7 @@ PieceValue(short sq, short side) + case pknight: + s += PKnightValue(sq, side); + break; ++#endif + + case psilver: + s += PSilverValue(sq, side); +@@ -2063,7 +2134,7 @@ ScoreCaptures(void) + + if ((m = seed[c1])) + { +- for (piece = lance, n = 0; piece <= rook; piece++) ++ for (piece = pawn+1, n = 0; piece <= rook; piece++) + { + if (Captured[c1][piece]) + n++; +@@ -2086,9 +2157,11 @@ ScoreCaptures(void) + ds = RMBLTY[MAX_RMBLTY - 1]; + break; + ++#ifndef MINISHOGI + case lance: + ds = LMBLTY[MAX_LMBLTY - 1]; + break; ++#endif + + default: + ds = MBLTY[piece]; +@@ -2381,8 +2454,10 @@ DetermineGameType(short side_to_move) + GuessGameType(side_to_move); + + array_zero(Mpawn, sizeof(Mpawn)); ++#ifndef MINISHOGI + array_zero(Mlance, sizeof(Mlance)); + array_zero(Mknight, sizeof(Mknight)); ++#endif + array_zero(Msilver, sizeof(Msilver)); + array_zero(Mgold, sizeof(Mgold)); + array_zero(Mbishop, sizeof(Mbishop)); +@@ -2490,6 +2565,7 @@ DetermineStage(short side) + stage = 30; + } + ++#ifndef MINISHOGI + /* Update stage depending on board features and attack balance value */ + + if (abs(ds = (mtl[side] - mtl[xside])) +@@ -2504,6 +2580,7 @@ DetermineStage(short side) + + stage += (ds = db1); + } ++#endif + + for (c1 = black, c2 = white; c1 <= white; c1++, c2--) + { +@@ -2576,8 +2653,10 @@ DetermineStage(short side) + /* Determine stage dependant weights */ + + ADVNCM[pawn] = 1; /* advanced pawn bonus increment */ ++#ifndef MINISHOGI + ADVNCM[lance] = 1; + ADVNCM[knight] = 1; ++#endif + ADVNCM[silver] = 1; /* advanced silver bonus increment */ + ADVNCM[gold] = 1; /* advanced gold bonus increment */ + ADVNCM[bishop] = 1; +diff --git a/gnushogi/genmove.c b/gnushogi/genmove.c +index 5c4ff6d..4eb6895 100644 +--- a/gnushogi/genmove.c ++++ b/gnushogi/genmove.c +@@ -326,8 +326,10 @@ PromotionPossible(short color, short f, short t, short p) + switch (p) + { + case pawn: ++#ifndef MINISHOGI + case lance: + case knight: ++#endif + case silver: + case bishop: + case rook: +@@ -358,6 +360,7 @@ NonPromotionPossible(short color, short f, + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } + ++#ifndef MINISHOGI + case lance: + if (color == black) + { +@@ -385,6 +388,7 @@ NonPromotionPossible(short color, short f, + ? true + : (generate_move_flags ? ILLEGAL_TRAPPED : false)); + } ++#endif + } + + return true; +@@ -533,7 +537,11 @@ field_bonus(short ply, short side, short piece, + + /* CHECKME: is this right? */ + if (((rvupiece == rvuboard) && (upiece == pawn)) +- || (upiece == bishop) || (upiece == knight)) ++ || (upiece == bishop) ++#ifndef MINISHOGI ++ || (upiece == knight) ++#endif ++ ) + { + s++; /* The opposing pawn (piece) */ + +@@ -772,7 +780,11 @@ LinkMove(short ply, short f, + { + #ifdef TESUJIBONUS + /* Look at non-promoting silver or knight */ +- if (piece == silver || piece == knight) ++ if (piece == silver ++#ifndef MINISHOGI ++ || piece == knight ++#endif ++ ) + { + local_flag |= tesuji; /* Non-promotion */ + s++; +@@ -908,6 +920,7 @@ DropPossible(short piece, short side, short sq) + GenUnmakeMove(side, f, sq, tempb, tempc, false); + } + } ++#ifndef MINISHOGI + else if (piece == lance) + { + if ((side == black) && (r == 8)) +@@ -922,6 +935,7 @@ DropPossible(short piece, short side, short sq) + else if ((side == white) && (r <= 1)) + possible = (generate_move_flags ? ILLEGAL_TRAPPED : false); + } ++#endif + + return possible; + } +@@ -1110,9 +1124,13 @@ LinkPreventCheckDrops(short side, short xside, short ply) + if (board[square = PieceList[side][0]] != king) + return; + +- for (piece = lance; piece <= rook; piece++) /* FIXME */ ++ for (piece = pawn+1; piece <= rook; piece++) + { +- if (piece == lance || piece == bishop || piece == rook) ++ if ( ++#ifndef MINISHOGI ++ piece == lance || ++#endif ++ piece == bishop || piece == rook) + { + /* check for threat of xside piece */ + ptyp = ptype[side][piece]; +@@ -1639,7 +1657,7 @@ IsCheckmate(short side, short in_check, short blockable) + * Drops are restricted for pawns, lances, and knights. + */ + +- if (piece > knight) ++ if (piece >= silver) + break; + } + } +diff --git a/gnushogi/globals.c b/gnushogi/globals.c +index 5018e6d..d16740e 100644 +--- a/gnushogi/globals.c ++++ b/gnushogi/globals.c +@@ -116,12 +116,28 @@ const short kingP[3] = + { 4, 76, 0 }; + + const small_short relative_value[NO_PIECES] = +-{ 0, 1, 3, 4, 7, 9, 10, 12, +- 2, 5, 6, 8, 11, 13, 14 }; ++{ 0, 1, ++#ifndef MINISHOGI ++ 3, 4, ++#endif ++ 7, 9, 10, 12, ++ 2, ++#ifndef MINISHOGI ++ 5, 6, ++#endif ++8, 11, 13, 14 }; + + const long control[NO_PIECES] = +-{ 0, ctlP, ctlL, ctlN, ctlS, ctlG, ctlB, ctlR, +- ctlPp, ctlLp, ctlNp, ctlSp, ctlBp, ctlRp, ctlK }; ++{ 0, ctlP, ++#ifndef MINISHOGI ++ ctlL, ctlN, ++#endif ++ ctlS, ctlG, ctlB, ctlR, ++ ctlPp, ++#ifndef MINISHOGI ++ ctlLp, ctlNp, ++#endif ++ ctlSp, ctlBp, ctlRp, ctlK }; + + short stage, stage2; + short balance[2]; +diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h +index 2e03cc4..80f276c 100644 +--- a/gnushogi/gnushogi.h ++++ b/gnushogi/gnushogi.h +@@ -160,11 +160,19 @@ extern void movealgbr(short m, char *s); + #define SEEK_SET 0 + #define SEEK_END 2 + ++#ifdef MINISHOGI ++#define NO_PIECES 11 ++#define MAX_CAPTURED 19 ++#define NO_PTYPE_PIECES 11 ++#define NO_COLS 5 ++#define NO_ROWS 5 ++#else + #define NO_PIECES 15 + #define MAX_CAPTURED 19 + #define NO_PTYPE_PIECES 15 + #define NO_COLS 9 + #define NO_ROWS 9 ++#endif + #define NO_SQUARES (NO_COLS*NO_ROWS) + + #define ROW_NAME(n) ('a' + NO_ROWS - 1 - n) +@@ -217,12 +225,18 @@ extern void movealgbr(short m, char *s); + + + /* board properties */ ++#ifndef MINISHOGI + #define InBlackCamp(sq) ((sq) < 27) + #define InWhiteCamp(sq) ((sq) > 53) ++#else ++#define InBlackCamp(sq) ((sq) < 5) ++#define InWhiteCamp(sq) ((sq) > 19) ++#endif + #define InPromotionZone(side, sq) \ + (((side) == black) ? InWhiteCamp(sq) : InBlackCamp(sq)) + + /* constants */ ++/* FIXME ? */ + #define OPENING_HINT 0x141d /* P7g-7f (20->29) */ + + /* truth values */ +@@ -243,15 +257,20 @@ extern void movealgbr(short m, char *s); + enum { + no_piece = 0, + pawn, ++#ifndef MINISHOGI + lance, + knight, ++#endif ++ /* start of pieces that can be dropped at any square */ + silver, + gold, + bishop, + rook, + ppawn, ++#ifndef MINISHOGI + plance, + pknight, ++#endif + psilver, + pbishop, + prook, +@@ -262,8 +281,10 @@ enum { + enum { + ptype_no_piece = 0, + ptype_pawn = 0, ++#ifndef MINISHOGI + ptype_lance, + ptype_knight, ++#endif + ptype_silver, + ptype_gold, + ptype_bishop, +@@ -272,8 +293,10 @@ enum { + ptype_prook, + ptype_king, + ptype_wpawn, ++#ifndef MINISHOGI + ptype_wlance, + ptype_wknight, ++#endif + ptype_wsilver, + ptype_wgold + }; +@@ -300,10 +323,17 @@ enum { + #endif + + /* move symbols */ ++#ifndef MINISHOGI + #define pxx (CP[2]) + #define qxx (CP[1]) + #define rxx (CP[4]) + #define cxx (CP[3]) ++#else ++#define pxx (CP[236]) ++#define qxx (CP[235]) ++#define rxx (CP[238]) ++#define cxx (CP[237]) ++#endif + + /***************** Table limits ********************************************/ + +@@ -349,7 +379,7 @@ enum { + #define MAXDEPTH 40 /* max depth a search can be carried */ + #define MINDEPTH 2 /* min search depth =1 (no hint), >1 hint */ + #define MAXMOVES 300 /* max number of half moves in a game */ +-#define CPSIZE 235 /* size of lang file max */ ++#define CPSIZE 241 /* size of lang file max */ + + #if defined SMALL_MEMORY + # if defined SAVE_SSCORE +@@ -753,7 +783,11 @@ typedef unsigned char next_array[NO_SQUARES][NO_SQUARES]; + typedef small_short distdata_array[NO_SQUARES][NO_SQUARES]; + + extern const small_short inunmap[NO_SQUARES]; ++#ifndef MINISHOGI + extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)]; ++#else ++extern const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 2)]; ++#endif + + #if defined SAVE_NEXTPOS + extern const small_short direc[NO_PTYPE_PIECES][8]; +diff --git a/gnushogi/init.c b/gnushogi/init.c +index 2dc8e94..4306972 100644 +--- a/gnushogi/init.c ++++ b/gnushogi/init.c +@@ -75,15 +75,32 @@ unsigned int ttbllimit; + + const small_short piece_of_ptype[NO_PTYPE_PIECES] = + { +- pawn, lance, knight, silver, gold, bishop, rook, pbishop, prook, king, +- pawn, lance, knight, silver, gold ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold, bishop, rook, pbishop, prook, king, ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold + }; + + ++/* FIXME: all bishops and rooks are black ? */ + const small_short side_of_ptype[NO_PTYPE_PIECES] = + { +- black, black, black, black, black, black, black, black, black, black, +- white, white, white, white, white ++ black, ++#ifndef MINISHOGI ++ black, black, ++#endif ++ black, black, black, black, black, black, black, ++ white, ++#ifndef MINISHOGI ++ white, white, ++#endif ++ white, white + }; + + #ifdef SAVE_NEXTPOS +@@ -96,8 +113,16 @@ const small_short psweep[NO_PTYPE_PIECES] = + + const small_short sweep[NO_PIECES] = + { +- false, false, true, false, false, false, true, true, +- false, false, false, false, true, true, false ++ false, false, ++#ifndef MINISHOGI ++ true, false, ++#endif ++ false, false, true, true, ++ false, ++#ifndef MINISHOGI ++ false, false, ++#endif ++ false, true, true, false + }; + + +@@ -154,6 +179,7 @@ ptype_distance(short ptyp, short f, short t) + else + return drow; + ++#ifndef MINISHOGI + case lance: + if ((dcol != 0) || (drow < 1)) + return CANNOT_REACH; +@@ -167,6 +193,7 @@ ptype_distance(short ptyp, short f, short t) + return CANNOT_REACH; + else + return (drow / 2); ++#endif + + case silver: + if (drow > 0) +@@ -193,8 +220,10 @@ ptype_distance(short ptyp, short f, short t) + + case gold: + case ppawn: ++#ifndef MINISHOGI + case pknight: + case plance: ++#endif + case psilver: + if (abs(dcol) == 0) + return (abs(drow)); +@@ -346,38 +375,78 @@ Initialize_dist(void) + const small_short ptype[2][NO_PIECES] = + { + { +- ptype_no_piece, ptype_pawn, ptype_lance, ptype_knight, ++ ptype_no_piece, ptype_pawn, ++#ifndef MINISHOGI ++ ptype_lance, ptype_knight, ++#endif + ptype_silver, ptype_gold, ptype_bishop, ptype_rook, +- ptype_gold, ptype_gold, ptype_gold, ptype_gold, ++ ptype_gold, ++#ifndef MINISHOGI ++ ptype_gold, ptype_gold, ++#endif ++ ptype_gold, + ptype_pbishop, ptype_prook, ptype_king + }, + { +- ptype_no_piece, ptype_wpawn, ptype_wlance, ptype_wknight, ++ ptype_no_piece, ptype_wpawn, ++#ifndef MINISHOGI ++ ptype_wlance, ptype_wknight, ++#endif + ptype_wsilver, ptype_wgold, ptype_bishop, ptype_rook, +- ptype_wgold, ptype_wgold, ptype_wgold, ptype_wgold, ++ ptype_wgold, ++#ifndef MINISHOGI ++ ptype_wgold, ptype_wgold, ++#endif ++ ptype_wgold, + ptype_pbishop, ptype_prook, ptype_king + }, + }; + + const small_short promoted[NO_PIECES] = + { +- no_piece, ppawn, plance, pknight, psilver, gold, pbishop, prook, +- ppawn, plance, pknight, psilver, pbishop, prook, king ++ no_piece, ppawn, ++#ifndef MINISHOGI ++ plance, pknight, ++#endif ++ psilver, gold, pbishop, prook, ++ ppawn, ++#ifndef MINISHOGI ++ plance, pknight, ++#endif ++ psilver, pbishop, prook, king + }; + + const small_short unpromoted[NO_PIECES] = + { +- no_piece, pawn, lance, knight, silver, gold, bishop, rook, +- pawn, lance, knight, silver, bishop, rook, king ++ no_piece, pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, gold, bishop, rook, ++ pawn, ++#ifndef MINISHOGI ++ lance, knight, ++#endif ++ silver, bishop, rook, king + }; + + const small_short is_promoted[NO_PIECES] = + { +- false, false, false, false, false, false, false, false, +- true, true, true, true, true, true, false ++ false, false, ++#ifndef MINISHOGI ++ false, false, ++#endif ++ false, false, false, false, ++ true, ++#ifndef MINISHOGI ++ true, true, ++#endif ++ true, true, true, false + }; + + /* data used to generate nextpos/nextdir */ ++#ifndef MINISHOGI ++/* FIXME: use predefined constants ! */ + #if !defined SAVE_NEXTPOS + static + #endif +@@ -397,8 +466,27 @@ const small_short direc[NO_PTYPE_PIECES][8] = + { -11, 0, 0, 0, 0, 0, 0, 0 }, /* 11 ptype_wlance */ + { -21, -23, 0, 0, 0, 0, 0, 0 }, /* 12 ptype_wknight */ + { -10, -11, -12, 12, 10, 0, 0, 0 }, /* 13 ptype_wsilver */ +- { -10, -11, -12, 1, -1, 11, 0, 0 } +-}; /* 14 ptype_wgold */ ++ { -10, -11, -12, 1, -1, 11, 0, 0 } /* 14 ptype_wgold */ ++}; ++#else ++#if !defined SAVE_NEXTPOS ++static ++#endif ++const small_short direc[NO_PTYPE_PIECES][8] = ++{ ++ { 7, 0, 0, 0, 0, 0, 0, 0 }, /* 0 ptype_pawn */ ++ { 6, 7, 8, -8, -6, 0, 0, 0 }, /* 3 ptype_silver */ ++ { 6, 7, 8, -1, 1, -7, 0, 0 }, /* 4 ptype_gold */ ++ { 6, 8, -8, -6, 0, 0, 0, 0 }, /* 5 ptype_bishop */ ++ { 7, -1, 1, -7, 0, 0, 0, 0 }, /* 6 ptype_rook */ ++ { 6, 8, -8, -6, 7, -1, 1, -7 }, /* 7 ptype_pbishop */ ++ { 7, -1, 1, -7, 6, 8, -8, -6 }, /* 8 ptype_prook */ ++ { 6, 7, 8, -1, 1, -8, -7, -6 }, /* 9 ptype_king */ ++ { -7, 0, 0, 0, 0, 0, 0, 0 }, /* 10 ptype_wpawn */ ++ { -6, -7, -8, 8, 6, 0, 0, 0 }, /* 13 ptype_wsilver */ ++ { -6, -7, -8, 1, -1, 7, 0, 0 } /* 14 ptype_wgold */ ++}; ++#endif + + + small_short diagonal(short d) +@@ -407,12 +495,20 @@ small_short diagonal(short d) + } + + ++#ifndef MINISHOGI ++/* FIXME */ + static const small_short max_steps[NO_PTYPE_PIECES] = + { + 1, 8, 1, 1, 1, 8, 8, 8, 8, 1, 1, 8, 1, 1, 1 + }; ++#else ++static const small_short max_steps[NO_PTYPE_PIECES] = ++{ ++ 1, 1, 1, 4, 4, 4, 4, 1, 1, 1, 1 ++}; ++#endif + +- ++#ifndef MINISHOGI + const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 4)] = + { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, +@@ -443,8 +539,29 @@ const small_short inunmap[NO_SQUARES] = + 100, 101, 102, 103, 104, 105, 106, 107, 108, + 111, 112, 113, 114, 115, 116, 117, 118, 119 + }; ++#else ++const small_short nunmap[(NO_COLS + 2)*(NO_ROWS + 2)] = ++{ ++ -1, -1, -1, -1, -1, -1, -1, ++ -1, 0, 1, 2, 3, 4, -1, ++ -1, 5, 6, 7, 8, 9, -1, ++ -1, 10, 11, 12, 13, 14, -1, ++ -1, 15, 16, 17, 18, 19, -1, ++ -1, 20, 21, 22, 23, 24, -1, ++ -1, -1, -1, -1, -1, -1, -1, ++}; + + ++const small_short inunmap[NO_SQUARES] = ++{ ++ 8, 9, 10, 11, 12, ++ 15, 16, 17, 18, 19, ++ 22, 23, 24, 25, 26, ++ 29, 30, 31, 32, 33, ++ 36, 37, 38, 39, 40, ++}; ++#endif ++ + int InitFlag = false; + + +diff --git a/misc/gnushogi.lng b/misc/gnushogi.lng +index ad09596..7d8c352 100644 +--- a/misc/gnushogi.lng ++++ b/misc/gnushogi.lng +@@ -232,3 +232,9 @@ + /* 232: eng: */ "Tsume: %-12s Force: %s\n", + /* 233: eng: */ "Invalid command-line arguments:", + /* 234: eng: */ "", ++/* 235: eng: */ " psgbrpsbrk ", ++/* 236: eng: */ " PSGBRPSBRK ", ++/* 237: eng: */ "54321", ++/* 238: eng: */ "edcba", ++/* 239: eng: */ " 5 4 3 2 1", ++/* 240: eng: */ " 1 2 3 4 5", --- gnushogi-1.3.2.orig/debian/patches/01-info.patch +++ gnushogi-1.3.2/debian/patches/01-info.patch @@ -0,0 +1,22 @@ +Author: Rene Mayorga +Description: Adds missing info headers (Closes: #422032). + +diff -Naurp gnushogi.orig/doc/gnushogi.texinfo gnushogi/doc/gnushogi.texinfo +--- gnushogi.orig/doc/gnushogi.texinfo 2009-08-03 06:01:40.000000000 +0000 ++++ gnushogi/doc/gnushogi.texinfo 2009-08-03 06:20:09.000000000 +0000 +@@ -5,6 +5,15 @@ + @settitle GNU Shogi manual + @c % ** End of header. + ++@smallbook ++@set EDITION 0.1 ++@set VERSION 2.0.0 ++ ++@dircategory Games ++@direntry ++* gnushogi: (gnushogi). Japan chess ++@end direntry ++ + @setchapternewpage odd + + @c ==================================