Fork me on GitHub

Unicode piecepack diagrams

This article includes details on how to make piecepack game diagrams using just Unicode. There is another article full of tables of useful piecepack Unicode symbols.

Unicode text diagram theory

Rank and Suit symbols

The standard (and many non-standard) piecepack suit and rank symbols are available in Unicode. See the Unicode symbols article for tables of piecepack Unicode suit and rank symbols.

Rotation

Although Unicode in general doesn't support character rotations for some rank/suit symbols Unicode also has glyphs that are (or look like they are) rotated versions of those glyhps (i.e. both ☾ and ☽ (crescent) moons and both † and ⸸ daggers) or are symbols that are symmetric across certain (or all) axes of rotation such as the (alchemical) sun symbol ☉. For some piecepack game diagrams you'll want to have rotated versions of your rank/suit symbols in order to indicate rotated coins, tiles, dice, and perhaps directional pawns. Often Unicode will only have (if any) one or two rotations but will sometimes have more rotations - in particular Unicode 12.0 includes all 45 degree rotations of chess piece glyphs.

Color

In general Unicode itself doesn't encode color. But many text platforms do support coloring individiual characters such as terminals:

And web pages:

If on such a platform you could color the suit/rank symbols in the appropriate suit color or perhaps (as suggested by Michael Van Biesbrouck) use color to indicate levels of height.

Coins

To represent a piecepack coin simply take the relevant (potentially rotated) suit/rank symbol and combine with the "Combining Enclosing Circle" U+20DD. Theoretically Unicode also supports adding a directional mark to the suit/rank symbol with one of the several Combining Diacritical Marks (should be done before adding the enclosing circle) but I couldn't get such a glyph combination to look nice in any of the (monoscale) fonts I tried.

Dice

To represent a piecepack die simply take the relevant (potentially rotated) suit/rank symbol and combine with the "Combining Enclosing Square" U+20DE. If you need to support 45/135/225/315 degree rotations there is also "Combining Enclosing Diamond" U+20DF (although depending on your aesthetics you may want to use that for your pawn). Piecepack dice that follow the Anatomy of a piecepack standard don't have directional/suit marks but if you really want some one possibility found in Unicode's Combining Diacritical Marks are the s, m, c, and a superscripts.

Pawns

Depending on your aesthetics (and whether you need directional pawns and/or need to be able to distinguish pawns without aid of color) there are different options for pawns:

  1. Combine the relevant (potentially rotated) suit symbol with the "Combining Enclosing Diamond" U+20DF. This supports rotation in 90 degree rotations and lets you use your suit symbol.
  2. Combine the relevant suit symbol with the "Combining Enclosing Upward Pointing Triangle" U+20E4. Still lets you use your suit symbol but doesn't support any rotations (but standard piecepack pawns are not inherently directional anyways).
  3. Use the (chess) pawn symbol ♟ U+265F. Hard to distinguish suits unless you can apply color (and the people reading your diagrams aren't color-blind). With Unicode 12.0 can rotate the pawn symbol in all 45 degree rotations.
  4. Use the two chess pawn symbols and two chess bishop symbols for the four piecepack pawns. Even if can't apply color should be visually distinct (although maybe hard to remember which goes with each suit) and with Unicode 12.0 can rotate in all 45 degree rotations.

Tiles

Tiles are drawn using box-drawing characters. An individual tile is drawn with 5x5 (for a total of 25) characters but when other tiles are placed "adjacently" they will "share" border characters (so for example 2x2 tiles will be 9x9 characters). When placing pieces in the "cells" of the tile place them on the even rows/columns of the tile. When placing pieces on the "points" of the tile place them on the odd rows/columns of the tile.

Functions to generate unicode diagrams

The ppgames R packages has a prototype function cat_piece which generates piecepack Unicode text diagrams given data frame input (the same data frame input supported by pmap_piece). The diagrams generated by it look okay (but not perfect) with my terminal set to use GNU FreeMono (with a couple other fonts implicitly providing glyph backup support):

library("ppgames")
cat_piece(df_fide_chess())
Unicode text diagram for Chess
cat_piece(df_xiangqi())
Unicode text diagram for Xiangqi
cat_piece(df_backgammon())
Unicode text diagram for Backgammon

The prototype parser currently makes the following choices:

  1. Coins lack directional marks (symbol plus directional mark plus enclosing symbol didn't look good in any font I tried).
  2. I use a "dagger" for the Arms suit instead of the fleur-de-lis since Unicode has rotated versions of the "dagger".
  3. Piecepack pawns are represented by the suit symbol enclosed by a diamond.
  4. Pawns, dice, coin backs, and the tile faces' suit/rank symbols uses the suit color as their "foreground color".

The ppgames R package also can generate piecepack Unicode text diagrams of moves in a game recorded in PPN files (it is a wrapper around cat_piece):

ppn <- read_ppn(system.file("extdata/ex1.ppn", package="ppgames"))
game <- ppn[[1]]
cat_move(game)

Piecepack font wishlist

No font I tried did everything I would want a font to do for making nice looking piecepack Unicode text diagrams. For any font designers out looking for a new project here is a wishlist of features for a piecapack diagram friendly font:

  1. Needs to be Monoscale, ideally the width and height of the characters would be the same.
  2. Needs to have the important piecepack rank/suit Unicode symbols including support for all rotated versions of the glyphs. These symbols must still look nice when combining with Combining Diacritical Marks used as directional marks plus an enclosing circle, square, diamond, and/or triangle. Would also be nice to include the relevant "rotated" Unicode 12.0 chess piece glyphs (useful as piecapack Crowns and pawns).
  3. Needs support for all the thin/thick box-drawing characters. These should combine well with the piecepack coins, dice, and pawns (i.e. enclosing circles, squares, etc.) so it looks like those pieces are truly on top of the tiles (so no lines going through the "edge" of the coins, dice, pawns or awkward gaps between lines and piece "edges").

Comments


There are no comments yet.

Add a Comment

You can use Markdown or restructuredText to format your comment.

links

social