--- crafty-books-medium-1.0.debian1.orig/debian/README.Debian +++ crafty-books-medium-1.0.debian1/debian/README.Debian @@ -0,0 +1,9 @@ +crafty-books-medium for Debian +---------------------------------- + +These are the opening books used by the Crafty chess engine. Previously they +were shipped with the chess engine package (crafty). Alternatively you can use +crafty-books-small or crafty-books-medtosmall if you want smaller opening +moves databases. + + -- Eric Van Buggenhaut , Fri, 13 Feb 2002 12:03:29 +0100 --- crafty-books-medium-1.0.debian1.orig/debian/changelog +++ crafty-books-medium-1.0.debian1/debian/changelog @@ -0,0 +1,70 @@ +crafty-books-medium (1.0.debian1-3) unstable; urgency=medium + + * QA upload. + * Bump debhelper compat to 7. + * Set maintainer to Debian QA Group . (see: #835318) + * debian/rules: Add build-{arch,indep} (Closes: #999036). + + -- Marcos Talau Fri, 04 Nov 2022 07:47:50 -0300 + +crafty-books-medium (1.0.debian1-2) unstable; urgency=low + + * crafty >= 23 reports the book to be outdated, so a rebuild is done + * Added a ${misc:Depends} entry to the control file + * Moved the books to /usr/share/crafty. These books are no changing + data and should be used in $HOME/.crafty anyway. (Closes: #172899) + * Adjusted Standards-Version to 3.8.3 + + -- Oliver Korff Thu, 07 Jan 2010 13:55:19 +0100 + +crafty-books-medium (1.0.debian1-1) unstable; urgency=low + + * Repackaged the source and added subdirectory to + the orig.tar.gz + * Removed crafty-books-medium.override + * Added debhelper (>> 5.0.0) to ensure compat level 5 + * Added adopt note to the copyright file + * New-maintainer upload (Closes: #505947) + * crafty 22.10 reported book to be outdated, rebuild (Closes: #515021) + * There is no use for this book without crafty and it is not working + with 20.14 so I added a Depends: crafty (>= 22.10-1) to the control + file + * Changed file permissions in /var/lib/crafty to 664 + * Set compatlevel to 5 + * Removed fullstop from short description + * Removed empty prerm script + * Removed dh_undocumented from rules and changed dh_installmanpages + * Removed binary_arch from debian/rules + + -- Oliver Korff Sat, 16 May 2009 12:49:37 +0200 + +crafty-books-medium (1.0-2.1) unstable; urgency=high + + * Non-maintainer upload. + * Rebuild for the /usr/doc transition (Closes: #411973). + + -- Thijs Kinkhorst Sun, 4 Mar 2007 18:14:57 +0100 + +crafty-books-medium (1.0-2) unstable; urgency=low + + * No more binary conffiles (closes: #154502) + + -- Eric Van Buggenhaut Thu, 15 Aug 2002 22:27:25 +0200 + +crafty-books-medium (1.0-1) unstable; urgency=high + + * Initial debianization. + * Closing ITP (closes: #136302) + * Originally, the opening books for crafty were included in the same package + as the chess engine. Since they are quite large files and we don't want to + waste bandwidth everytime we do a change to the chess engine, they now + exist on their own. + * Priority set to high because crafty, which lives in sid needs this + new package (closes: #147700) + + -- Eric Van Buggenhaut Wed, 10 Jul 2002 11:41:31 +0100 + + +Local variables: +mode: debian-changelog +End: --- crafty-books-medium-1.0.debian1.orig/debian/compat +++ crafty-books-medium-1.0.debian1/debian/compat @@ -0,0 +1 @@ +7 --- crafty-books-medium-1.0.debian1.orig/debian/control +++ crafty-books-medium-1.0.debian1/debian/control @@ -0,0 +1,15 @@ +Source: crafty-books-medium +Section: contrib/games +Priority: optional +Build-Depends: crafty (>= 23.1), debhelper (>= 7) +Maintainer: Debian QA Group +Standards-Version: 3.8.3 + +Package: crafty-books-medium +Architecture: all +Depends: ${misc:Depends}, crafty(>= 23.1) +Conflicts: crafty-books-small, crafty-books-medium, crafty-books-large +Description: Medium size opening books for the crafty chess engine + Opening books that crafty use to evaluate the position during the game. + This is the medium version, occupying 4MB and containing +7500 games + computed until the 60th ply. --- crafty-books-medium-1.0.debian1.orig/debian/copyright +++ crafty-books-medium-1.0.debian1/debian/copyright @@ -0,0 +1,18 @@ +This package was debianized by Eric Van Buggenhaut + on +Wed Jul 10 11:31:38 CEST 2002 + +It was downloaded from ftp.cis.uab.edu:/pub/hyatt + +This package only contains chess games, which belong to the public domain. + +This package was adopted by Oliver Korff +Sat, 16 May 2009 12:49:37 +0200 + +It also contains learned chess positions, which belong to the public domain too. + +The Debian packaging is (C) 2009 by Oliver Korff and +is licensed under the GPL. + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- crafty-books-medium-1.0.debian1.orig/debian/crafty-books-medium.doc +++ crafty-books-medium-1.0.debian1/debian/crafty-books-medium.doc @@ -0,0 +1 @@ +debian/doc/crafty-book.doc --- crafty-books-medium-1.0.debian1.orig/debian/dirs +++ crafty-books-medium-1.0.debian1/debian/dirs @@ -0,0 +1 @@ +usr/share/crafty --- crafty-books-medium-1.0.debian1.orig/debian/doc/crafty-books.doc +++ crafty-books-medium-1.0.debian1/debian/doc/crafty-books.doc @@ -0,0 +1,384 @@ + Opening Book Setup and Usage + ---------------------------- + +Crafty uses two pre-compiled opening books, called +"book.bin" and "books.bin". + +The file book.bin is usually build from a large text file +containing PGN games, often taken from collections of GM +games. Building book.bin is a simple exercise and requires +nothing other than the raw input file you are going to use. +Generally this will be either medium.zip or the set of four +files large[1-4].zip, all of which are stored on the ftp +machine ftp.cis.uab.edu/pub/hyatt/. + +To create the file book.bin, you need a PGN game collection +that is a *real* PGN-compliant file. Supposing this file is +called "large.pgn" you would use the following command: + +book create large.pgn [n] [wpct] + +The only thing you have to supply is , a number indicat- +ing how many moves from each game are to be stored in the +book.bin database. I typically use 60, which stores the +first 60 moves from each game. Increasing this number +slightly increases the probability that Crafty will stay in +book longer, but it also increases the probability that it +will follow a game too far, so that it begins to reach posi- +tions where the move actually played might not be the best +move, letting it fall into a bad hole. Increasing this also +increases the size of the database as well. + +You can decrease the size of the book, and also reduce the +number of ugly moves by specifying , which says that +unless a move is played in at least N games, the move is +discarded. This will substantially decrease the size of the +book.bin file, and also eliminate single game moves that +often have significant errors or blunders. + +You can increase the quality of book lines by specifying + which is the "winning percentage". This is specified +as a percentage of lost games, and is used to discard moves +that led to mostly losses. A safe value is 50, which says +that if a particular opening move didn't win at least 50% as +many games as it lost, the move is culled. A value of 100 +would mean that moves are culled if they produced more +losses than wins, and is really a strict criterion. + +After creating book.bin, you need to create books.bin. This +is a small version of book.bin, which is intended to give +you more control over the moves/openings Crafty will play. +This is usually built from the file start.pgn on the ftp +machine, but you can modify this file to suit your taste +easily. To build books.bin, you use the following command: + +books create start.pgn 60 + +Again, 60 is what I use, but none of my start.pgn lines go +anywhere near that many moves. The main point here is that +in start.pgn, you can append a "!" to any move you want, and +when it is Crafty's turn to move for that color, it will +play from the set of moves with "!" if there are any, ignor- +ing the rest of the book moves. If you only want it to play +1. e4 as white, you would just enter the short game: + +[Crafty only plays 1. e4] 1. e4! + +and you are finished!. You can enter as many as you want. +If on the other hand there is a move you don't want Crafty +to play, then follow that move with a "?" and it will never +play it. Moves in books.bin that are not flagged with ! or +? don't have any influence on Crafty's choice at all. + +Here's how the files are used. When searching a position, +Crafty first enumerates the set of moves it can find in the +opening database. It then does the same for the books.bin +database, and performs a "merge" operation to combine the ? +and ! flags... The purpose of the books.bin file is to give +you a small database that you can easily modify, rebuild, +and repeat this process over and over. Since it takes a +fraction of a second to completely rebuild this file, it is +very easy to modify this to control what Crafty will play, +without having to rebuild the large database. + +One important characteristic of the PGN input is the Result +tag must be specified in most of the lines, because Crafty +counts wins, losses and draws for each book move and uses +these counts with some of the book selection options given +below. + +How the flags are used. + +The ! and ? flags should only appear in the small books.bin +file, although there is no reason why they can not appear in +the large file as well. For this discussion, it doesn't +matter since Crafty takes the moves from both files and +"merges" the flags/etc into one entry for each move. + +Quite simply, if any book legal book move has a ! flag, then +Crafty will only play moves from the set of moves which all +have the ! flag. If a move has a ? flag, then that move is +immediately removed from the set of possible book moves. If +the only legal book move has a ? flag, it will not be played +as a book move and Crafty will simply pretend that it found +no book moves and will execute a normal tree search. Pretty +simple. + +How to control the frequency of opening move selection. + +A new feature in version 15.15 and beyond allows you to +append a PGN comment to any move in a text file used to cre- +ate books.bin, of the form {play nn%}. This will force the +move it follows to be played that percentage of the time, +regardless of the normal book-ordering values based on fre- +quency and so forth. + +Note that {play 0%} will not prevent a move from being +played at all, as this will look just like a move with no +percent specified. To avoid playing a move, use the ? flag. + +How does Crafty choose book moves? + +Crafty's book selection algorithm depends on two user- +defined values that can be set at any time during a game: + +book random + +book width + +The selection algorithm first finds the set of legal book +moves as above. This set will either be all ! moves, or +will have no ! moves in it. This set is then sorted based +on the setting of book random. Here's the options: + +book random 0. This is a special case for book selection. +Crafty simply takes the set of book moves, and searches only +these moves using a normal alpha/beta search, but with a +shorter than usual time limit. It then plays the move that +produces the best search value. This has one serious disad- +vantage in that there is no randomness to this at all. It +will always play the same move in the same position, unless +the evaluation is modified, or the time per move is differ- +ent enough to let the search find a different move from the +book move set. + +book random 1. This enables a random form of book move +selection, but you have a lot of control over how moves are +randomly chosen. The moves are ordered, based on 4 +parameters: frequency of play, win/lose ratio, static eval- +uation and learned results. Normally these are factored +into the value used to sort the moves, based on default set- +tings that you can modify by using the command "bookw option +N" "option" should be "freq", "ratio", "eval", "learn", or +"CAP". N should be any real number between 0 and 1. + +Crafty finds the min and max values for each of the 4 param- +eters, and then maps this into the range 0-1000 for each +parameter. Each parameter is multiplied by the correspond- +ing "weight" you have assigned, and this is used as a value +to sort the moves from low to high. Note that the first +sort value is always the "play percent" to move them to the +top of the list. For moves with equal "play percent" val- +ues, the normal sort-value is used as the second-level sort +variable (if no moves have a play-percent, then this second- +level variable is the only one used, of course.) + +Once Crafty has sorted the moves as given above, it next +excludes any book moves which have 0 wins. This culls the +odd lines where a player chose a bad line and lost quickly. +With zero wins, it will never be chosen, although Crafty +will happily follow it from the other side. :) This is not +anywhere near perfect, however, because an opening could +have 1 win and 19 losses and that still would stay in the +list. + +If a move has a learned value of > 100, this move is ele- +vated in priority to that of a ! move, since it appears to +win material instantly. If a value is < -100, it is given a +? since it appears to be a lemon. + +After this, the setting for "book width " is used to keep +the first moves in the list, after the above culling has +been completed. The smaller you make the less random- +ness you get, but the chance of Crafty popping out a really +bizarre book move gets smaller as well. + +After sorting, the final step is to fold in any mandatory +"play percent" values. What this step does is that it finds +all the moves in the "playable move set" just computed, +which have no percent-to-play value set. It sums the sort- +values for these moves, then adjusts the sort-values for the +other moves so that their percentages will be honored. + +Once this has been done, crafty simply uses the "sort value" +for each move to compute a total for all moves. It then +generates a random number between 1 and this limit, and +chooses the move that this probability distribution matches. +This will certainly evolve over time as new ideas are devel- +oped. + +For my play on ICC, I use book random 1, and book width 5 +normally, although for titled players this is reduced to +book width 3. For computers, I reduce this further to 2, to +try to play reasonable openings and cull the gambits and +things that don't work out. + +How does book learning work and how can I share learned +results? + +1. *all* of crafty's "learned knowledge" is in the book.bin +file. It keeps the learned value and learned count right in +the book file for speed. You can't modify it, although +"show book" will make crafty display all the book stuff +before it makes a move. + +2. the book.lrn file has two purposes: (a) to serve as a +log for your prying eyes, so you can see what it's learned, +against whom, and what the score was that got its attention +in the first place. The values on the end of each book +line, inside the {} characters are as follows: + {value, depth, rating_difference} value is the value of +the "key" search that comes from the first 10 moves out of +book. it's in centipawns, and + is good - is bad. depth is +the depth the search reached at this "key" position, the +deeper the search, the more the value is "trusted." rat- +ing_difference is crafty's rating - opponent's rating a neg- +ative value means pay more attention to the score since the +opponent is better than crafty, a positive value means to +take the score with a grain of salt, because the opponent +was weaker than Crafty. + +You can delete this file at any time, and it has no effect +on learning. As I mentioned, the learning takes place in +book.bin... this is mainly for you to peek at if you are +interested. However, this is the "portable learning data +file" also, and can be given to others to import into their +crafty, where it will affect the opening book just like +their crafty had played the openings and got the same +scores. There are two ways to use such "lrn" files: + +1. "import " will read and import the +knowledge therein into your book.bin. Since I use the same +learning code as is used when playing games, this informa- +tion also gets appended to *your* book.lrn file as well, so +that your book.lrn always reflects *everything* your program +has learned, so long as you don't ever remove this file. It +would be a mistake to use this command on your own book.lrn +file, because the things would get counted twice, which +might or might not be a good thing. + +2. "import clear" will read is no longer around) which will +import either book.lrn type data or position.lrn type data +and can tell them apart without your having to do anything. +The option is still there, should you want to use +it, and simply removes the position.lrn and position.bin +files before starting the import process for position learn- +ing. + +This can be turned off, if you like, by checking out the +"learn" command, which gives you the ability to turn off +book learning (as it presently works), position learning, +and the next book learning stage which will add to the book +in addition to learning which book lines are good and bad. + +What is this new "result" learning? + +Result learning works just like normal book learning, except +that if Crafty is checkmated or resigns, it will step back +through the book line to find the last point where it had +more than one move to choose from. It will flag the move it +chose as "never play again". + +This handles the case where the first ten non-book moves +produce reasonable scores, but the position is one that +Crafty simply can't handle very well. If it loses such a +game, it will still vary the next time this opening is +played, as otherwise it would possibly repeat the same open- +ing, and would certainly repeat the remainder of the game. + +All three learning modes are turned on by default, although +any of them can be disabled with the appropriate command +option to "learn". + --- crafty-books-medium-1.0.debian1.orig/debian/postinst +++ crafty-books-medium-1.0.debian1/debian/postinst @@ -0,0 +1,60 @@ +#! /bin/sh +# postinst script for crafty +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see /usr/doc/packaging-manual/ +# +# quoting from the policy: +# Any necessary prompting should almost always be confined to the +# post-installation script, and should be protected with a conditional +# so that unnecessary prompting doesn't happen if a package's +# installation fails and the `postinst' is called with `abort-upgrade', +# `abort-remove' or `abort-deconfigure'. + +case "$1" in + configure) + +#In previous versions, crafty used /var/cache to keep its opening books. These +#files have been moved to a more policy-compliant place. +#We have to remove the dir we copied in preinst + if [ -d /var/cache/crafty -a -d /var/lib/crafty ] + then rm -rf /var/cache/crafty + fi + ;; + + abort-upgrade) +#If upgrade fails, then let the files where they were before install/upgrade +#(cancel the 'move' stuff initiated in preinst). + if [ -d /var/lib/crafty -a -d /var/cache/crafty ] + then rm -rf /var/lib/crafty + fi + ;; + + abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- crafty-books-medium-1.0.debian1.orig/debian/postrm +++ crafty-books-medium-1.0.debian1/debian/postrm @@ -0,0 +1,50 @@ +#! /bin/sh +# postrm script for crafty +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' overwrit>r> +# for details, see /usr/doc/packaging-manual/ + +case "$1" in + purge|disappear) + +#Remove opening books + rm -rf /var/lib/crafty/book.bin || true + rm -rf /var/lib/crafty/books.bin || true + ;; + + abort-install|failed-upgrade|abort-upgrade) + +#If install is aborted, then let the files where they were before install/upgrade +#(cancel the 'move' stuff started in preinst). + if [ -d /var/lib/crafty -a -d /var/cache/crafty ] + then rm -rf /var/lib/crafty + fi + ;; + + remove|upgrade) + + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 0 + +esac + +# dh_installdeb will replace next line with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + + --- crafty-books-medium-1.0.debian1.orig/debian/preinst +++ crafty-books-medium-1.0.debian1/debian/preinst @@ -0,0 +1,50 @@ +#! /bin/sh +# preinst script for crafty +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' + +case "$1" in + install|upgrade) +#Opening books have been moved to a more compliant place. + #Get rid of empty dir + if test \( $(ls /var/cache/crafty 2>/dev/null|wc -w) = '0' \) + then rm -rf /var/cache/crafty + fi + if [ -d /var/cache/crafty -a ! -d /var/lib/crafty ] + then echo "Moving /var/cache/crafty to /var/lib/crafty" + #We first copy the files, they'll be removed in postinst. This allows us to + #unwind if install/upgrade fails or is aborted. + mkdir -p /var/lib/crafty + cp -R /var/cache/crafty/* /var/lib/crafty + fi + ;; + + abort-upgrade) + + if [ -d /var/cache/crafty -a -d /var/lib/crafty ] + then rm -rf /var/lib/crafty + fi + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + --- crafty-books-medium-1.0.debian1.orig/debian/rules +++ crafty-books-medium-1.0.debian1/debian/rules @@ -0,0 +1,92 @@ +#!/usr/bin/make -f +# Makefile for Debian package crafty. +# Copyright (C) 2001 by Eric Van Buggenhaut. +# 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. + + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +DEB_BUILD_ARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH) + +build: build-stamp + +build-stamp: + dh_testdir + #Build the openings books. + #uudecode learn.dat.gz.uu | gunzip > debian/books/learn.dat + #uudecode medtosmall.txt.gz.uu | gunzip > debian/books/medtosmall.txt + echo "book create medium.txt 60" \ + | /usr/games/crafty + echo "books create start.pgn 60" \ + | /usr/games/crafty + rm -f log* + rm -f game* + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + dh_clean + # Add here commands to clean up after the build process. + rm -f game* books.bin book.bin book.lrn *.*~ \ +debian/books/learn.dat debian/books/medium.txt + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/crafty + #install -o root -g games -d debian/crafty-books-med/var/lib/crafty/TB + # changed by ok was 644 + install -m664 -o root -g games books.bin debian/crafty-books-medium/usr/share/crafty + install -m664 -o root -g games book.bin debian/crafty-books-medium/usr/share/crafty + #touch debian/crafty-books-med/var/lib/crafty/position.lrn + #touch debian/crafty-books-med/var/lib/crafty/book.lrn + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +# binary-arch: build install +# dh_testversion + dh_testdir + dh_testroot +# dh_installdebconf + dh_installdocs + dh_installexamples + dh_installmenu +# dh_installpam +# dh_installinit + dh_installman +# dh_installinfo +# dh_undocumented + dh_installchangelogs + dh_link + dh_strip + dh_compress +# Changed by ok +# dh_fixperms --exclude="debian/crafty-books-medium/var/lib/crafty" + dh_fixperms + + # You may want to make some executables suid here. + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch + +build-arch: build +build-indep: build + +.PHONY: build build-arch build-indep clean binary-indep binary-arch binary install