Exeter Chess Club: Techie Bit

This all seems horribly dated now.  If I was starting to make a chess website today I might use Wordpress and the rather neat chess plugin, or PGN2JS (anyone know a website for this package?) that I used for the Vacuum page... I'm having a good time with PalView to maintain my blog, and I believe lots of chess software these days has some sort of web publishing facility (e.g. ChessBase).  If you still like command line hacking, read on!


For geeks only...

Obviously, typing in moves by hand and cut-and-pasting GIFs from screen captures is as easy as ABC, well, easy as DEF at most. This page is for folk who like to lift the bonnet hood of the computer and start tweaking the engine to make things run more smoothly.
Creating Web pages is easy, this booklet describes the tricky bits of getting chess diagrams to appear. This too is easy if you cut-and-paste pictures of chess boards, but that is very inefficient. [If you want it easy and on a plate, Traveller Archives offer a wonderful diagram creation service where you can even make 3-D boards for newsletters.]

  But what you really want is a little 8x8 array of characters like this:

+--------+
|rnbqkbnr|
|pppppppp|
|-+-+-+-+|
|+-+-+-+-|
|-+-+-+-+|
|+-+-+-+-|
|PPPPPPPP|
|RNBQKBNR|
+--------+
The notes below describe how to do this in Word Processors and how to do this in HTML, and how to get from a handout to a Web page.
I am pleased to see that Alastair's terrific Chess DTP page is occasionally back up, and there is an equally terrific Chess DTP page from Eric Bentzen, and the wonderfully public-spirited folk at Palamede have got more chess publishing stuff than you can shake a stick at. between them, these sites list all the currently available PD, shareware and commercial fonts together with chess Web authoring tools.

 [Jon Perry and Patrick Surry at Edinburgh offer more technical advice and programmes: if you're into UNIX, you can produce great diagrams like they do.]

 The links above probably describe everything you need; read on only if you are determined to imitate or use the pages here.


Do you just want to know how to edit/print out the handouts? Or write booklets with a word processor?

  To make these pages, the games are entered on a PC using Fritz, and then turned into teaching handouts using Word for Windows via Andy Duplain's superb CBASCII utilities, which have their own CBASCII homepage. They are also available via FTP from the Internet Chess Library (Caissa) ChessBase Tools directory and the Pittsburgh site Directory UTIL. There are hundreds of great PD/shareware files around; I've put the ones I use most for these pages on FTP here at Exeter, but I also get a lot out of Rob Weir's ChessBase Utilities.

 All the diagrams in these pages exist as 8x8 arrays of squares. I could have used GIFs of the whole board (e.g. cut and paste from CHESSBD or CBDEMO) but this is memory-hungry (5k a diagram) and doesn't allow use of efficiencies in caching. The GIFs I scrounged from John Tamplin, although I believe they are originally from a release of xboard, author Tim Mann. Patrick uses a different set of pieces (watch for case of file names).

  If you have a text-only browser the diagrams should still appear as 8x8 arrays using the alt="*" element; the light and dark squares are "-" and "+", the white pieces are "kqrbn" on light squares and "KQRBN" on dark, and the Black pieces are respectively "jdtls" and "JDTLS". If you have a chess font you should be able to save the file, and edit in the characters you need; this is pretty much the reverse of what I do to make them in the first place.

 These Web pages are derived from either the Fritz database (Method 1) or the handouts (Method 2).

 N.B. You don't need the Fritz programme itself to make handouts: try instead the ChessBase Windows Demo (which has its own FAQ), or see below! If you can use the CBWin demo., or any other piece of software that writes PGN or CBF files, you can bypass some of the CBASCII route I describe below: see the notes at the end of Method 1.

 N.B. When I say Word for Windows, I imagine any other Windows word processor would do.

 This is how I do it. You need an IBM PC and a UNIX machine for this trick, although DOS versions of the UNIX-y tools are freely available. The thought of doing all 400 of the games in the Canon by hand makes me dizzy, but if you want to do lots of games/positions yourself, you might fancy either just

  1. typing in the positions like Jon Perry does, or
  2. setting up positions using SLICS/CHESSBD
  3. using xboard on a Unix machine like Patrick Surry does, then and using xbdtohtml on a Unix machine or DOS port of PERL.
See also notes on Creating handouts. Now read on...

Method 1: From Fritz .cbf database

  1. Download a copy of CBASCII to your PC from ICL/Pittsburgh or my FTP site or CBASCII homepage.
  2. Download a copy of SLICS/CHESSBD from my FTP site or Don Fong.
  3. Enter games and positions in PGN format using SLICS/CHESSBD. Set output option variable to 2 (PGN), and save as "games.pgn".
  4. Edit the PGN file manually: type in {DIAGRAM} wherever you want your arrays. (Actually {CTRL-D} will also work.)
  5. Convert from PGN to CHESSBASE using
    c:\ cbascii -i games.pgn games.cbf
  6. Convert back out to text with added 8x8 diagrams using
    c:\ cbascii -e -fcb -d8x8=squares.def games.txt games.cbf

      You need to set up a sed definition file: I use this one, which puts junky "^A" characters in, but you can't put nothing in, and lots of other characters have other meanings in chess. [In order to create Word handouts I use instead the mappings to Eric Schiller's Tilburg font: see notes below.]

  7. Upload the text file to Unix. Currently it has "junk" CTRL-A (^A) characters in, which can be removed easily using "mg" or "emacs".
  8. Edit using sed command file:
    % sed -f sq2img.sed games.txt > games.html
  9. Patch in header, footer and get it so as it looks right.

      The sed command file looks a bit of a nightmare but each line beginning with a "|" is a diagram line, I change all the KQRNB to <IMG> tags, and add in 'alt=' elements.

      I have to do it circuitously because I use "l" and "t" to stand for black bishop and rook, both of which are found in the word 'alt'!.

  10. Split your games up somehow: I have a little utility that does it for me but I don't think I'm free to give it away (yet).
  11. Breathe huge sigh thinking that however painful this was, making them manually is worse.
  12. Lastly, don't forget to e-mail Andy Duplain saying what a great programme CBASCII is. Also, write to Don Fong saying what a great programme CHESSBD is, and enclosing at least $12 registration.
The advantage of using PGN is that (a) you can use existing database games, and (b) the computer gets all the piece positions right, and doesn't occasionally leave off pawns like I do.

  A desire to do coordinates led me to lash out some of my hard-earned on the Linares font family. If you are compiling Handouts using the character sets appropriate to the ChessBase for Windows fonts, the sed scripts required to turn them into HTML are

sed -f CBWIN1.sed games.doc > games.tmp
sed -f CBWIN2.sed games.tmp > games.html
If you can use the CBWin demo., you can bypass the CBASCII route I describe above using cut-and-paste or Printing-CreateTextFile.

Method 2: From Word handouts

  1. Create a Word for Windows handout, as in steps 1-2 below.
  2. The Word for Windows handout is saved as a Rich Text Format file.
  3. Upload the RTF file to UNIX and apply rtftohtml to get an HTML version.
  4. Edit in piece image references using
    % sed -f tilbrtf.sed handout.html > test.tmp
    cat head handout.tmp tail > handout.html
    This is the real point: having put some sweat into creating a neat word-processed handout for a coaching session, I can upload it to this server and with one macro command I can turn it into valid HTML without creating or uploading new diagrams. (*bows*) With all the diagrams, about 12 pages of A4 in Word comes out at 100-150k of HTML.

Method 3: Creating handouts

There are several PC solutions to this task (if you aren't using a chess-playing programme with a print facility) but they all start with getting hold of a chess font. The ICL has a very nice set of PD graphics to enhance the basic stuff below.

  Then you need to create little 8x8 arrays of characters in your document to fit your font. You can do this either:

The last being the most accurate, and hence the one I use.
  1. use CBASCII to create text files with 8x8 diagram arrays, as in steps 1-6 above. [I use Eric Schiller's Tilburg font (see below), which also can be used nicely with Anders Thulin's Chess Diagram Editor, available from my FTP site or the big US sites and their mirrors.] I get to a document I can edit by using a CBASCII character mapping that fits the chess font I use, that is, on the PC going:
    c:\ cbascii -e -fcb -d8x8=tilburg.def games.doc games.cbf

     CBASCII takes game number options, so you can output just the ones you want.

  2. edit the text file using your favourite word processor: I usually set the handout in two columns, with half-a-dozen or so separate paragraph styles to get the appearance of chess diagrams:
    normal text:
    Arial 12pt, paragraph 0.5 line before, 1.5 spacing
    game comment:
    normal + 1.0 spacing
    game moves:
    normal + indent and bold
    game variation:
    normal + italic
    game subvariation:
    normal + italic and indent
    diagram:
    Tilburg 12 pt, paragraph indented both sides, border
    variation diagram:
    diagram + Tilburg 10pt,extra indent, double border
    Here is a completed Word for Windows handout. There's also an example of a Word 6 file italian.doc among the Openings handouts. If you don't have Tilburg you'll have to edit in another font (change TILBURG to TASC) and change the characters (/0220 to A, /0221 to a, ...) to see these properly. The troff character translations to create a plain ASCII text are given here.
  3. Using other TrueType fonts: Tilburg was the firstest with the mostest as far as I was concerned, and is still advertised as the main commercial option by UK database agents, although it has been overtaken by Steve Smith's Alpine fonts (Linares, Zurich, Hastings, etc.).

      Excellent free public domain [PD] alternatives have appeared since I got going, including: I have stored here possibly old copies of Hans Bodlaender's Utrecht font [homepage], and Alan Cowderey's wonderful new PD Traveller font. There's a TT version of the Adobe cheq font around; I also keep a copy here.
    Some fonts like the TASC's Figurine font [homepage] are designed to accompany commercial packages, including now: ChessMaster 5000, Chess Office and Smart Chess.

      They all have their own advantages: cheq can be read easily in small font sizes, Traveller is very comprehensive but doesn't read well on the screen in Windows 3.1, and so on.

     Some of these fonts have borders but I don't think any have coordinates. All praise and thanks to these folks for putting their hard work out free for us hacks... Someone posted a list of Sites with downloadable chess fonts, and there is a great archive in Norresundby Chess Club's site "En Passant".

     As all these fonts use 'normal' characters like ABC to stand for chess pieces you have to use different fonts for diagrams and body text. [You might end up doing that anyhow with Tilburg as it uses characters in the 0220-0244 range for pieces, which is a royal pain to type in].

      Of course, you can use all these with CBASCII in the same way as Tilburg, viz.

    c:> cbascii -e -fcb -d8x8=normal.def normal.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=tilburg.def tilburg.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=std.def std.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=utrecht.def utrecht.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=tasc.def tasc.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=cheq.def cheq.txt diagram.cbf
    c:> cbascii -e -fcb -d8x8=linares.def linares.txt diagram.cbf

     I have made up a demonstration file for these fonts in this way as a Windows Write file. Alastair Scott spent a long while tidying up DTP for users of CBASCII and some of the fruits of his labour are in a little file called cbasckit.zip; I am pleased to see that Alastair's page is back up.

Steve Smith's commercial TT fonts e.g. Linares, also use "normal" characters and can offer borders and coordinates. If I was starting again I would always use one of these, as I think Tilburg doesn't yet support borders or coordinates. The Linares fonts include versions which will (a) work wonderfully with the Chessbase for Windows Demo, and (b) turn 'natural' chess text (1.Nf3) into figurines. If you can use the CBWin demo. with these fonts, you can bypass the CBASCII routes I describe above using cut-and-paste or Printing-CreateTextFile.


Clearly all these files still need a lot of tweaking with sundry UNIX tools to get them to look like web pages, and if I could get the hang of the TeX chess macros, I might even use them instead! Shaihin very kindly sent me not one but two studies laid out in beautiful LaTeX PostScript, if you are interested in this approach.

  Anyhow, if you have any comments or suggestions on how to do this more easily, I'd love to hear from you.


How do I print out the Web page handouts?

These notes arose after I got a note from a friend:
 [...] 
I don't know how easy it is, but one suggestion I have is to make a
text/postscript printable version of the material, without the
diagrams! They are great in colour on the web page, but do take up a
lot of paper, and don't go into wordprocessors (mine, at least). I
made a copy of your French Defence ideas by dragging and dropping the
text around the diagrams into a text editor, a few Latex commands, and
the whole looks nice in six pages, very handy at home with the chess
board.

Of course, most browsers have a simple print option. These notes are only for those who find this unsatisfactory (the diagrams are bulky, and the handouts are sometimes very long) and would like another route. [PC/UNIX users only, I'm afraid, until someone helps me out]
  1. The easiest way I know to create your own text-only printable version using the save (p) option in LYNX, which will include ASCI diagrams. This is very quick, although I'd find it a bore to do the lot that way. I've no idea how to do this in Netscape: you can turn images off but I don't think you can do that when you print. But
    • there is a DOS LYNX
    • it serves people right for using Netscape
  2. Otherwise, you'll have to save the source and macro out the tags. I've had a go at doing this myself, i.e.
    sed -f html2txt.sed file.html > file.html.txt
    • The diagrams in the resulting text files are derived from the alt="*" elements; the light and dark squares are "-" and "+", the white pieces are "kqrbn" on light squares and "KQRBN" on dark, and the Black pieces are respectively "jdtls" and "JDTLS". If you have a chess font you should be able to save the file, and edit in the characters you need; this is pretty much the reverse of what I do to make them in the first place.
    • You can do this by creating the "file.html.txt" and running a sed macro on it which matches the font you intend to use: for example, if you use the character map for Traveller Standard font or Adobe cheq or Linares you can use the sed macro for std or cheq or Linares. [If you design your own, you could post it to me and I'd put a link in here.]
      So, having saved the source, you go:
      sed -f std.sed file.html.txt > file.txt
      sed -f cheq.sed file.html.txt > cheq.txt
      or
      sed -f linares.sed file.html.txt > linares.txt

      You can then create your e.g. Word for Windows version of the Web page.
    • If you intend to leave it as plain text, but prefer "kqrbn" for White pieces and "KQRBN" for Black (thus losing the square colour information), then try running (guess?) this sed macro on it.
Comments etc. to the usual mailbox.
Back to Chess Coaching Page

This document (techie.html) was last modified on 21 Jan 97 by [cool blue cat]

Dr. Dave