Skip to main content

Generating Xiangqi setup images, publishing/print level quality

(Last edit 2014-08-31) I wrote a tool that takes the board setup from a WXF file (example below) and produces an SVG image visualizing that setup. Different themes for board and pieces are supported (including your own), the gap between pieces can be adjusted, output width can be adjusted, too. It's called xiangqi-setup. Internally, the tool takes the an SVG file of the board, places piece SVGs at the right places and saves the result. The tool uses svgutils by Bartosz Telenczu. I'm very happy he made that available as free software. My tool is free software (licensed under GNU AGPL 3.0 or later) too, of course. If you want to imitate the style of Chinese end- game books, you could go with these themes:

(Image licensed under CC0 1.0 Universal: Public Domain Dedication)

If you want to imitate LaTeX xq 0.3 style (with added flexibility), you could go with this:

(Image licensed under CC0 1.0 Universal: Public Domain Dedication)

If you would rather go for something more colourful, for screen rather than print, or you want to explicitly imitate the look of PlayOK.com, you could go with this:

(Image licensed under CC0 1.0 Universal: Public Domain Dedication, piece artwork kindly shared and released by PlayOK)

There is a version of the pieces without shadows (for PDF generation), too. Latter image was created running

# ./xiangqi-setup \
    --board themes/board/playok_2014_remake/ \
    --pieces themes/pieces/playok_2014_chinese \
    --scale-pieces 1.025 \
    --width-px 400 \
    demo.wxf setup_imitate_playok.svg

This what you pass in: a WXF file (e.g. produced by XieXie by saving with .wxf extension):

FORMAT          WXF
GAME    
RED             ;;;
BLACK           ;;;
DATE            2014-07-16
FEN             4kaer1/4a2c1/2h1e1h2/3Rp1C1p/2C6/5rP2/1pP1P3P/8E/9/1cEAKA1R1 b

START{
}END

As of now, the complete usage of xiangqi-setup is:

# ./xiangqi-setup --help
usage: xiangqi-setup [-h] [--board DIRECTORY] [--pieces DIRECTORY]
                     [--width-px PIXEL] [--width-cm CENTIMETER] [--dpi FLOAT]
                     [--scale-pieces FACTOR] [--debug]
                     INPUT_FILE OUTPUT_FILE

positional arguments:
  INPUT_FILE
  OUTPUT_FILE

optional arguments:
  -h, --help            show this help message and exit
  --board DIRECTORY
  --pieces DIRECTORY
  --width-px PIXEL
  --width-cm CENTIMETER
  --dpi FLOAT
  --scale-pieces FACTOR
  --debug

For themes, these are your options (at the moment):

# find themes -maxdepth 2 -type d | sort
themes
themes/board
themes/board/a4_blank_2cm_margin
themes/board/clean_alpha
themes/board/clean_beta
themes/board/commons_xiangqi_board_2008
themes/board/commons_xiangqi_board_2008_bw_thin
themes/board/dhtmlxq_2014_remake
themes/board/latex_xq_remake
themes/board/minimal
themes/board/minimal_chinese
themes/board/minimal_chinese_arabic
themes/board/playok_2014_remake
themes/board/xiexie_2_5_0_remake_minimal
themes/pieces
themes/pieces/ccbridge_3_0_beta4_default_preview_remake
themes/pieces/commons_xiangqi_pieces_print_2010
themes/pieces/commons_xiangqi_pieces_print_2010_bw_heavy
themes/pieces/latex_xqlarge_2006_chinese_autotrace
themes/pieces/latex_xqlarge_2006_chinese_potrace
themes/pieces/playok_2014_chinese
themes/pieces/playok_2014_chinese_noshadow
themes/pieces/retro_simple

If none of the existing themes fit your needs, you may create board and/or pieces of your own. For boards, drawing a custom grid, palace, start markers and border can be done using the xiangqi-board tool. A demonstration of its current options:

# ./xiangqi-board --help
usage: xiangqi-board [-h] [--line-thickness-px FLOAT] [--field-width-px FLOAT]
                     [--field-height-px FLOAT] [--border-thickness-px FLOAT]
                     [--border-gap-width-px FLOAT]
                     [--border-gap-height-px FLOAT] [--cross-width-px FLOAT]
                     [--cross-thickness-px FLOAT] [--cross-gap-px FLOAT]
                     SVG_FILE INI_FILE

positional arguments:
  SVG_FILE
  INI_FILE

optional arguments:
  -h, --help            show this help message and exit
  --line-thickness-px FLOAT
                        Line thickness of square fields in pixel (default: 1)
  --field-width-px FLOAT
                        Width of fields in pixel (default: 53)
  --field-height-px FLOAT
                        Height of fields in pixel (default: 53)
  --border-thickness-px FLOAT
                        Line thickness of border in pixel (default: 2)
  --border-gap-width-px FLOAT
                        Widtn of gap to border in pixel (default: 40)
  --border-gap-height-px FLOAT
                        Height of gap to border in pixel (default: 40)
  --cross-width-px FLOAT
                        Width of starting position cross segments in pixel
                        (default: 10)
  --cross-thickness-px FLOAT
                        Line thickness of starting position cross in pixel
                        (default: 1)
  --cross-gap-px FLOAT  Gap to starting position cross in pixel (default: 4)

For text on the river, the characters are:

  • Chu river: 楚河
  • Han border: 漢界 traditional, 汉界 simplified

On the Open Source font end of things these are your main options to my understanding:

On a side note, in Gentoo Linux look for these packages:

  • Adobe Source Han Sans: media-fonts/source-han-sans (gentoo-zh overlay)
  • AR PL UKai/UMing CN/TW: media-fonts/arphicfonts
  • Google Noto Sans CJK: media-fonts/notofonts (betagarden overlay)
  • Wangfonts: media-fonts/wangfonts (gentoo-zh overlay)
  • WenQuanYi Micro/Zen Hei: media-fonts/wqy-microhei, media-fonts/wqy-zenhei

If you use xiangqi-setup tool to generate images, feel free to drop me a mail, I would be curious to see your results and check out your custom themes. I would not mind a free of copy of your book, either :) Cheers!

Things not to do when publishing a book on Xiangqi (or any other topic)

One minute version

If you're buying an English book on Xiangqi do not buy "A Beginners guide to Xiangqi" by Tyler Rea: It's a ripp-off and does more harm than good. For something in English, you could go with "Chinese Chess: An Introduction to China's Ancient Game of Strategy" by H. T. Lau for print or browse www.xqinenglish.com, instead.

Disclaimer

  • First, sorry for the poor picture quality!
  • If I highlighted say two errors in a picture below, it does not mean it's only two.
  • This review is not meant to be complete: it's way too much already.

How did I get here?

I ran into this video on YouTube: While I've been playing Xiangqi for quite a while already, I was thinking "that book looks like fun, I'll buy it just to have a closer look, maybe there's something in there that I haven't seen yet, too". So I did have some expectations. I started skip-reading through the book and soon stumbled over error after error: to the point of laugh-or-cry. It starts with the cover page, already. Read on for details.

Quick review summary

  • Whole chapters match Internet content 1:1 (mostly xqinenglish.com, also en.wikipedia.org).
  • About 100 pages are wasted to two uncommented example games, one move per page.
  • Of those, the first example game is declared a win when the king is not even in check.
  • Poor teaching (mis-leading, logic errors, no examples where needed)
  • No chapter explaining AXF/WXF (or any) move notation (despite use in the book)
  • Many errors details, spelling, case, punctuation (even on cover page)

The book lacks declaration of an edition or a print date. It does say "Printed in Germany by Amazon Distribution GmbH, Leipzig" at the end. According to the book's Amazon page it was published at/by CreateSpace: Self Publishing and Free Distribution for Books, CD, DVD, "an Amazon company" in 2013. This beginners guide is actually a beginner's guide. Maybe that's a typo.

The cover says it loud and clear

Interesting things to spot on the cover:

  • "Writen" should have been "Written" with double "t"
  • On the bottom, Red's king and elephant use the characters of Black
  • Red's pawns show characters of Black's pawns and vice versa

Too bad I noticed all of that after buying.

Whole chapters match Internet content 1:1

So far I have identified these matches with Internet content (some 1:1, some adjusted):

The author of xqinenglish.com confirmed to me via e-mail that use of his content in that book has not been authorized/licensed by him. The two places where I noticed copying first: At page 170 it reads "term use[d] on this site" rather than "in this book":

At page 49 the "Basic, commonly used tactics in Xiangqi" is not a complete sentence and does not have a full stop either. That is because in the original that is the title of a section, not a sentence.

On the example games

While showing a complete game move by move could be helpful in teaching, a few things went wrong in general:

  • Moves should be commented, e.g. "Red is attacking piece X to make up for blacks attack against .." rather than "Black has responded by advancing the horse".
  • WXF/AXF and algebraic move notation could have been shown: There is plenty of space for that.
  • Since there are no arrows indicating the current move on the board, "finding" the move is much more work than necessary, especially when turning pages.
  • No more than a single move per page is plain waste of paper.
  • Roughly 100 pages for two examples games take more than half the page count.

On the first game in particular: The game ends at move #79 of Red which is commented as:

WINNING Move #79, Red secures Checkmate. Black's General is it check from Red's Chariot and Red's General as part of a Face to face laughing check.

That's rather surprising since Black is not even in check after Red has moved. Is this a joke?

On the second game: page 167 shows the second last move of the game. Black responds with R9+2 / Ri0-i8. How does that do anything against the threat of C5=6 / Ce5-d5 by Red? What about C2=5 / Cb8-e8 for a proper reply? If we assume a really poor opponent, maybe that deserves mentioning. Also, let me use the occasion to point out the characters used for Red's king and advisors. A friend of mine who has been studying English, Chinese and German literature on Xiangqi for years said he has never seen those characters used anywhere in the context of Xiangqi.

The quality of teaching

This page is meant to teach movement of the king:

What I see is:

  • Pictures indicating movement of more than one step at a time
  • Lack of a system: it's neither where-to-go-from-here nor where-could-he-have-come-from

Up next is the oddity I noticed very first: How would the two pawns go sideways before crossing the river?

This page is meant to explain movement of the horse. With that little blocking pieces there are quite a few move options missing.

Here the idea seemed to be: show all possible steps a pawn can do. However, there are lots of arrows missing:

This one is really bad: If I hop my cannon right in front of the king with no protection, he eats my cannon and that's it:

To me, this dry list of checkmates clearly lacks examples:

No chapter on move notation

Despite use of AXF notation in the book, there is no chapter explaining how to read or write that (or any) move notation. Why not?

Many errors at details, spelling, case, punctuation

In a printed book, finding spelling mistakes is expected to be hard. Not so with this book: A few examples. On page 4 we can see how punctuation is pulled into quotes — always but once:

The word "Xiangqi" can be found in the book as "Xiàngqí", "Xiànqí" (typo, lacks "g") and "Xiangqi" (without accents):

Also, uppercase is used at interesting places, e.g.

  • Page 44: "leap frog Perpetually"
  • Page 45: "The Anatomy and structure"
  • Page 39: "to Augment your defense"

to name a few. That's all for the moment.

(Update 2014-08-31: The book is "out-of-order" on Amazon.com and .de; as of today, it is sold by a reseller for 32.05 EUR at Amazon.de and for 189.20(!) USD at Amazon.com.)

(German) Zu "Ran an die Buletten" von Elisabeth Raether, ZEITmagazin #33, 17. Juli 2014

Die Titel-Story des ZEITmagazins Nummer 33 vom 17. Juli 2014 heißt "Ran an die Buletten" und ist eine verzweifelte Kampagne von Elisabeth Raether, die Reputation der Fleisch-Esser wiederherzustellen: Weiter Fleisch essen aber weniger schlecht fühlen dabei. Zum Untertitel "Warum fleischlose Ernährung größer Käse ist" wird keine schlüssige Argumentation geliefert, auch sonst werden keine ernstnehmbaren Schlüsse angeboten. Ich hatte erst überlegt, selbst mit dem digitalen Rotstift ranzugehen, eine ernsthafte Analyse des Textes auszuarbeiten, aber das erscheint mir inzwischen als Zeitverschwendung. Nur zwei Zitate möchte ich bringen:

[..] Fleischessen ist der Genuss der Ignoranten geworden, wie SUV fahren und Kette rauche. Ich schreibe im ZEITmagazin eine wöchentliche Rezeptkolumne. Wenn ich etwas zu Hähnchen oder Hackbällchen schreibe, bekomme ich vorwurfsvolle E-Mails und Onlinekommentare.

Hier findet sich also die Motivation zum Schreiben des Artikels.

Der Verzicht [auf Entrecôte] wäre kein Geringer. [..] Haben wir nicht so etwas wie eine moralische Verpflichtung, uns am Leben zu erfreuen?

Ohne Worte. Ein paar der Kommentare zum Artikel online sind recht gut oder amüsant. Meine Verwunderung auf den Punkt bringt dieser Kommentar von Nutzer "Bird Henning":

Wie kann es sein, dass die ZEIT soetwas veröffentlicht? Gibt es keine Verantwortlichen, die so einen Bockmist verhindern können? Oder darf da jeder schreiben was er will und es wird unter die Menschen gebracht? Ich bin jedenfalls sprachlos, so etwas hier in einem doch so "seriösen Magazin" zu lesen.

Die Kommentare und die sieben "widerlegten" Annahmen finden sich auf der Seite des Magazins. Den gesamten Artikel müsste man kaufen, aber davon möchte ich explizit abraten: Das wäre Geldverschwendung.

Audible "Command done" notifiction on the shell

Background story / context

At work I'm dealing with a test suite running >30 minutes, even on moderately fast hardware. When testing some changes, I launch the test suite and start working on something else to not be waiting for the test suite. Now the sooner I know that the test suite finished execution, the sooner I can fix errors and give it another spin. So checking the test suite for being done manually is not efficient.

The problem

What I wanted was a notification, something audible, looped, like an alarm clock. Either

$ ALARM_WHEN_DONE cmd [p1 p2 ..]

or

$ cmd [p1 p2 ..] ; ALARM

usage would have worked for me.

My approach

I ended up grabbing the free Analog Alarm Clock sound — the low-quality MP3 version download works without registration — and this shell alias:

$ alias ALARM='mplayer --loop=0 ~/Desktop/alarm.mp3 &>/dev/null'

With this alias, now I can do stuff like

$ ./testrunner ; ALARM

on the shell and never miss the end of test suite execution again. Do you have a different/better approach to the same problem? Let me know! PS: Yes, I have heard of continuous integration and we do that, too.

EGF Xiangqi file format tool and documentation

Hello :) I don't get to playing with code much lately. Yesterday and today I put some effort into trying to understand and document the EGF file format used by Xie Xie to store Xiangqi games including per-move comments and a bit of other metadata. Status quo includes a simple command line tool:

# ./egf/cli.py test.egf 
Event:  Blog post
Site:  At home
Date:  6-7-2014
Round:  1
Red name:  sping
Black name:  Xie Xie Freeware 2.5.0
Description:  Command line tool demo input
Author:  sping

File i:  R _ _ P _ _ p _ _ r
File h:  H _ C _ _ _ _ c _ h
File g:  E _ _ P _ _ p _ _ e
File f:  A _ _ _ _ _ _ _ _ a
File e:  K _ _ P _ _ p _ _ k
File d:  A _ _ _ _ _ _ _ _ a
File c:  E _ _ P _ _ p _ _ e
File b:  H _ C _ _ _ _ c _ h
File a:  R _ _ P _ _ p _ _ r
(Ranks 9 to 0 from left to right)

To start:  red

6 single moves in total
[ 1]  c h3  - e3 
[ 1]                   H h10 - g8 
[ 2]  h h1  - g3 
[ 2]                   R i10 - h10
[ 3]  r i1  - h1 
[ 3]                   C h8  - h4 

Result:  to be determined

Bytes remaining to be read:
0 0

I welcome help to fill in the remaining blanks, e.g. with decoding time markers and king-in-check markers of moves. If you are on Gentoo and would like to run Xie Xie the easy way, grab games-board/xiexie-freeware-bin from the betagarden overlay. EGF files for inspection can be downloaded from http://www.cc-xiexie.com/download.php.

freshplayerplugin (Chrome Flash for Firefox) in Gentoo betagarden, uses uriparser

Since Adobe has stopped developing Flash for Firefox and Mozilla has no plans to support the Pepper plug-in API, Rinat Ibragimov is developing a wrapper to use Google Chrome's Pepper-based Flash plug-in with Mozilla Firefox:

GitHub: i-rinat/freshplayerplugin

A live ebuild is now available in the "betagarden" overlay. Users of non-stable Chrome can edit the plug-in path in /etc/freshwrapper.conf. Interestingly, freshplayerplugin makes use of my library uriparser for URI handling. Very nice!

Paris, France: Exhibition "Bill Viola"

If you happen to be in Paris during 2014-03-05 and 2014-07-21 I recommend to check out exposition "Bill Viola". It's the first exhibition with video "objects" only that I have been to. After a number of less exciting things to see, the exhibition became both interesting and relaxing at the same time. After leaving, everything I saw felt like a video installation to me...

This video gives a good overview of what to expect: Bill Viola : l'exposition

And this is (a small mid-time excerpt of) a piece that I really liked: The Encounter - Bill Viola

(German) Rückblick: Chinesisches Schach mit der Sprach- und Kulturbörse bei der Langen Nacht der Wissenschaften 2014

Worum geht es?

Am Samstag den 10.05.2014 habe ich mit/für die Sprach- und Kulturbörse der TU Berlin im Rahmen der Langen Nacht der Wissenschaften im ersten Stock des Foyers im Hauptgebäude der TU Berlin interessierten Besuchern Chinesisches Schach erklärt und im Spiel ausprobieren lassen.

Informelle Sicht

Mitgebracht hatte ich: zwei Spiele mit hybriden Spielsteinen (chinesisch und westlich), eine Ausgabe von H. T. Laus Buch "Chinese Chess" auf Englisch, eine englisch- deutsche Anleitung von Philos-Spiele, eine deutsche Broschüre von Rainer Schmidt, die neben den Regeln auch spannende Hintergrundinformationen liefert. Interesse zeigte vor allem jüngeres Publikum: jünger, als ich erwartet hatte. Ein neunjähriger Junge, der seit kurzem westliches Schach im Verein spielt, bot bereis in seiner ersten Partie spannende Züge an. Ähnliches später auch mit einem zwölfjährigen Spieler. Schwierigkeiten, die Regeln zu verstehen, hatte generell keiner der Besucher. Eine wiederkehrende Frage war, wie die Figuren denn (generell) schlagen würden. Bedarf an Gewöhnung zeigten im Spiel nicht unerwartet die Natur der Kanone, die Blockade des Pferdes sowie der Wunsch nach Seitwärtsgehen mit Bauern bereits vor Überquerung des Flusses. Partien mit jüngeren Spielern wurden interessanterweise nicht abgebrochen, weil das Spiel sich in einer demotivierenden Verknotung verfangen hätte, sondern weil Eltern andere Pläne hatten. Partien zu Ende gespielt wurden im Allgemeinen kaum: Abgebrochen wurde meist aus Zeitmangel auf Seiten des Besuchers. Präferenz des westlichen Schaches äußerten nur ein Spieler, der ein Spiel gewagt hatte, und ein Besucher, der an Details gar nicht interessiert gewesen war (...). Zuweilen wäre mehr als ein "Lehrer" am Stand praktisch gewesen. Da ich nicht wusste, welcher Andrang mich erwarten würde, hatte ich mich im Vorfeld nicht nach Unterstützung umgesehen. Mein über die Zeit variierter Ansatz zum Erklären lässt sich als Skript zusammenfassen als:

  1. Vogelperspektive: manche Dinge sind genau gleich wie im westlichen Schach, manche ähnlich, manche komplett anders
  2. Genau gleich ist, dass es darum geht, den König "schachmatt" zu setzen, und, wie die Türme sich verhalten
  3. Dann Erklärung der Figuren auf der Grundlinie von außen nach innen (bereits begonnen mit dem Turm): Pferd, Elefant (erste Erwähnung Fluss, gegebenenfalls gegenseitige Deckung der Elefanten zum Schutz des Königs als Klassiker in der Defensive)
  4. Erklärung des Königs und seiner Leibwächter, ihre Bewegung als Komplementär und nur auf gezeichneten Linien, Erwähnung Platzmangel und Bindung an den Palast
  5. Verweis für die Übrigen — Elefant, Pferd, Turm — auf die andere, bereist erklärte Seite (Symmetrie)
  6. Vorschau, dass nur noch die Bauern, die Kanonen und eine Sonderregel mit dem König fehlen
  7. Erklärung der Bauern (zweite Erwähnung Fluss), Kanonen, Todesblick beim König mit zwei Beispielen
  8. Gegebenenfalls das Szenario der "Doppelkanone", die gängigste Eröffnung inklusive Antwort (zentrale Kanone, Antwort mit Pferd)

Außerdem:

  • Unterschiede zum westlichen Schach bei Remi und Patt vor Beginn einer ersten Partie meist außen vor gelassen
  • Bildliche Erklärung für "die Elefanten dürfen nicht über den Fluss" (mögen kein Wasser, können nicht schwimmen (gegebenenfalls mit Hinweis, dass das Unsinn ist), ...) und die Beförderung der Bauern (sind dann gewaschen, haben ihre Rüstung abgelegt und sind dadurch agiler, ...) mit Augenzwinkern ohne Fokus auf Richtigkeit, um das Einprägen der Regel zu fördern

Persönliche Sicht

Das Erklären des Spieles hat Spaß gemacht, die Besucher waren durchweg angenehm. Beeindruckend fand ich, wie schnell gerade die jüngeren Besucher das Spiel beherrschten. Eine Frau mit zwei Kindern, die selbst an Details interessiert war, beantwortete meine Frage nach ihrem Beruf mit "Beraterin", meine Nachfrage nach der Art von Beraterin aber mit "das darf ich nicht sagen". Das habe ich so auch noch nicht erlebt und wunderte mich reichlich. Vielleicht ist besser, wenn ich es nicht genauer weiß :) Kurz vor Schluss kamen noch drei junge Studentinnen vorbei, die Chemie beziehungsweise Physik studierten, vielfältig interessiert und relativ nerdig unterwegs waren und untereinander ihre erste Partie bis zum Ende spielten. Aus Zeitgründen wechselten wir zum Endspiel auf "20 Sekunden Zeit pro Zug", was das Spiel schlagartig noch deutlich spannender und spaßiger machte. Ohne diese Gesellschaft wäre ich wohl nicht bis 1:20 geblieben, was mit geplantem Aufstehen um 8:00 am nächsten Tag alles andere als früh war. Beim SKB, besonders bei Ioanna, möchte ich für die liebe Betreuung und die Versorgung mit Essen und Trinken bedanken!

(German) Termin eines Dauerauftrages verändern (Girokonto ING-DiBa)

Ich überweise unter anderem meine Miete per Dauerauftrag. Beim Umzug meines Girokontos (von der Postbank) zu ING-DiBa hatte ich den Dauerauftrag versehentlich so neu angelegt, dass jeweils am 3. eines Monats überweisen wird. Am 3. soll das Geld allerdings schon überwiesen sein, der 3. als Überweisungsdatum ist also zu spät. Der gleiche Denkfehler war mir auch mit dem Dauerauftrag für die GASAG unterlaufen.

Im Web-Interface, mit dem ich sonst sehr zufrieden bin, lässt sich der Ausführungstermin nicht verändern. Löschen und erneutes Anlegen wäre natürlich gegangen, aber da ich das zweimal hätte machen müssen und das ganze mit mehreren TANs hätte bestätigen müssen, habe ich eine Anfrage an den Kundendienst gestellt. Der reagiert am nächsten Tag mit (Auszug) folgender Antwort:

Im Internetbanking kann aus technischen Gründen der Termin oder der Turnus für einen bestehenden Dauerauftrag nicht geändert werden. Bitte löschen sie hierzu den entsprechenden Dauerauftrag und legen Sie einfach einen neuen an.

Gerne nehmen wir Ihren Änderungsauftrag auch telefonisch entgegen. Sie erreichen uns rund um die Uhr unter 069 / 34 22 24. Halten Sie bei einem Anruf bitte Ihre Kontonummer und Ihre 5-stellige Telebanking PIN bereit.

Also habe ich diese Nummer angerufen, die unter Kontakt als "Kontoführung / Banking" geführt wird. Nach Eingabe meiner Kontonummer und Telefonbanking-PIN finde ich mich in einem Sprach-Menü, lande mit Nichts-Sagen im Hauptmenü und wähle Punkt "7" für Kundenbetreuer. Der Kundenbetreuer passt beide Ausführungstermine an, stellt dabei Rückfragen zur Absicherung und beim nächsten Log-In sind meine Daueraufträge, wie ich es haben wollte. Etwas umständlich, aber für meinen Geschmack doch spannender, als mehrmals Löschen und Wiederanlegen :)