summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-01-30 17:05:46 +0000
committerKarl Berry <karl@freefriends.org>2009-01-30 17:05:46 +0000
commit33e5f729a77cba484062bea7e76bbc457d8af199 (patch)
treeb0d4b36e2c21ac7b4aa0ae05a7dbd3325618425d
parent0bad1ef00b6c0029e7c15b96043e7fe1b5c0c802 (diff)
context-games update (29jan09)
git-svn-id: svn://tug.org/texlive/trunk@12018 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/context/third/games/README24
-rw-r--r--Master/texmf-dist/tex/context/third/games/games-chess-symbols.tex202
-rw-r--r--Master/texmf-dist/tex/context/third/games/games-chess.lua855
-rw-r--r--Master/texmf-dist/tex/context/third/games/games-chess.tex331
-rw-r--r--Master/texmf-dist/tex/context/third/games/games-go.lua88
-rw-r--r--Master/texmf-dist/tex/context/third/games/games-go.tex14
-rw-r--r--Master/texmf-dist/tex/context/third/games/t-games.tex18
-rwxr-xr-xMaster/tlpkg/libexec/ctan2tds14
-rw-r--r--Master/tlpkg/tlpsrc/context-games.tlpsrc1
9 files changed, 1501 insertions, 46 deletions
diff --git a/Master/texmf-dist/doc/context/third/games/README b/Master/texmf-dist/doc/context/third/games/README
new file mode 100644
index 00000000000..3b9f5714e4c
--- /dev/null
+++ b/Master/texmf-dist/doc/context/third/games/README
@@ -0,0 +1,24 @@
+Games Module for ConTeXt
+
+
+Introduction
+------------
+
+The games module provides the function to create static and interactive versions
+of board games. The first release has support for Go and Hex, more games follow
+in later releases.
+
+To use the module write \usemodule[games] in the preamble of your document.
+
+
+License
+-------
+
+The module is copyrighted by Wolfgang Schuster and published under Public Domain
+
+
+Revision History
+----------------
+
+2009-01-08
+Initial release \ No newline at end of file
diff --git a/Master/texmf-dist/tex/context/third/games/games-chess-symbols.tex b/Master/texmf-dist/tex/context/third/games/games-chess-symbols.tex
new file mode 100644
index 00000000000..5f0f76012f2
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/games/games-chess-symbols.tex
@@ -0,0 +1,202 @@
+%D \module
+%D [ file=games-chess-symbols,
+%D version=2008.01.11,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Chess Symbols,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\writestatus{loading}{Context User Module / Games - Chess Symbols}
+
+\unprotect
+
+\definefontsynonym[skaknew] [file:SkakNew-Diagram]
+\definefontsynonym[alpha] [file:ChessAlphaDiagram]
+\definefontsynonym[adventurer][file:AVENFONT]
+\definefontsynonym[cheq] [file:CHEQ_TT]
+
+\startsymbolset [skaknew]
+
+\definesymbol [\v!field:\v!black:\v!king ] [\ChessSymbol{"6A}]
+\definesymbol [\v!field:\v!black:\v!queen ] [\ChessSymbol{"6C}]
+\definesymbol [\v!field:\v!black:\v!rook ] [\ChessSymbol{"73}]
+\definesymbol [\v!field:\v!black:\v!bishop] [\ChessSymbol{"61}]
+\definesymbol [\v!field:\v!black:\v!knight] [\ChessSymbol{"6D}]
+\definesymbol [\v!field:\v!black:\v!pawn ] [\ChessSymbol{"6F}]
+
+\definesymbol [\v!piece:\v!black:\v!king ] [\ChessSymbol{"6B}]
+\definesymbol [\v!piece:\v!black:\v!queen ] [\ChessSymbol{"71}]
+\definesymbol [\v!piece:\v!black:\v!rook ] [\ChessSymbol{"72}]
+\definesymbol [\v!piece:\v!black:\v!bishop] [\ChessSymbol{"62}]
+\definesymbol [\v!piece:\v!black:\v!knight] [\ChessSymbol{"6E}]
+\definesymbol [\v!piece:\v!black:\v!pawn ] [\ChessSymbol{"70}]
+
+\definesymbol [\v!field:\v!white:\v!king ] [\ChessSymbol{"4A}]
+\definesymbol [\v!field:\v!white:\v!queen ] [\ChessSymbol{"4C}]
+\definesymbol [\v!field:\v!white:\v!rook ] [\ChessSymbol{"53}]
+\definesymbol [\v!field:\v!white:\v!bishop] [\ChessSymbol{"41}]
+\definesymbol [\v!field:\v!white:\v!knight] [\ChessSymbol{"4D}]
+\definesymbol [\v!field:\v!white:\v!pawn ] [\ChessSymbol{"4F}]
+
+\definesymbol [\v!piece:\v!white:\v!king ] [\ChessSymbol{"4B}]
+\definesymbol [\v!piece:\v!white:\v!queen ] [\ChessSymbol{"51}]
+\definesymbol [\v!piece:\v!white:\v!rook ] [\ChessSymbol{"52}]
+\definesymbol [\v!piece:\v!white:\v!bishop] [\ChessSymbol{"42}]
+\definesymbol [\v!piece:\v!white:\v!knight] [\ChessSymbol{"4E}]
+\definesymbol [\v!piece:\v!white:\v!pawn ] [\ChessSymbol{"50}]
+
+\definesymbol [\v!field\v!mask:\v!king ] [\ChessSymbol{"31}]
+\definesymbol [\v!field\v!mask:\v!queen ] [\ChessSymbol{"35}]
+\definesymbol [\v!field\v!mask:\v!rook ] [\ChessSymbol{"33}]
+\definesymbol [\v!field\v!mask:\v!bishop ] [\ChessSymbol{"34}]
+\definesymbol [\v!field\v!mask:\v!knight ] [\ChessSymbol{"32}]
+\definesymbol [\v!field\v!mask:\v!pawn ] [\ChessSymbol{"36}]
+
+\definesymbol [\v!piece\v!mask:\v!king ] [\ChessSymbol{"54}]
+\definesymbol [\v!piece\v!mask:\v!queen ] [\ChessSymbol{"58}]
+\definesymbol [\v!piece\v!mask:\v!rook ] [\ChessSymbol{"56}]
+\definesymbol [\v!piece\v!mask:\v!bishop ] [\ChessSymbol{"57}]
+\definesymbol [\v!piece\v!mask:\v!knight ] [\ChessSymbol{"55}]
+\definesymbol [\v!piece\v!mask:\v!pawn ] [\ChessSymbol{"59}]
+
+\definesymbol [\v!field\v!mask:\v!empty ] [\ChessSymbol{"7A}]
+
+\definesymbol [\v!field:\v!black:\v!empty ] [\ChessSymbol{"5A}]
+\definesymbol [\v!field:\v!white:\v!empty ] [\ChessSymbol{"30}]
+
+\stopsymbolset
+
+\startsymbolset [alpha]
+
+\definesymbol [\v!field:\v!black:\v!king ] [\ChessSymbol{"6A}]
+\definesymbol [\v!field:\v!black:\v!queen ] [\ChessSymbol{"6C}]
+\definesymbol [\v!field:\v!black:\v!rook ] [\ChessSymbol{"73}]
+\definesymbol [\v!field:\v!black:\v!bishop] [\ChessSymbol{"61}]
+\definesymbol [\v!field:\v!black:\v!knight] [\ChessSymbol{"6D}]
+\definesymbol [\v!field:\v!black:\v!pawn ] [\ChessSymbol{"6F}]
+
+\definesymbol [\v!piece:\v!black:\v!king ] [\ChessSymbol{"6B}]
+\definesymbol [\v!piece:\v!black:\v!queen ] [\ChessSymbol{"71}]
+\definesymbol [\v!piece:\v!black:\v!rook ] [\ChessSymbol{"72}]
+\definesymbol [\v!piece:\v!black:\v!bishop] [\ChessSymbol{"62}]
+\definesymbol [\v!piece:\v!black:\v!knight] [\ChessSymbol{"6E}]
+\definesymbol [\v!piece:\v!black:\v!pawn ] [\ChessSymbol{"70}]
+
+\definesymbol [\v!field:\v!white:\v!king ] [\ChessSymbol{"4A}]
+\definesymbol [\v!field:\v!white:\v!queen ] [\ChessSymbol{"4C}]
+\definesymbol [\v!field:\v!white:\v!rook ] [\ChessSymbol{"53}]
+\definesymbol [\v!field:\v!white:\v!bishop] [\ChessSymbol{"41}]
+\definesymbol [\v!field:\v!white:\v!knight] [\ChessSymbol{"4D}]
+\definesymbol [\v!field:\v!white:\v!pawn ] [\ChessSymbol{"4F}]
+
+\definesymbol [\v!piece:\v!white:\v!king ] [\ChessSymbol{"4B}]
+\definesymbol [\v!piece:\v!white:\v!queen ] [\ChessSymbol{"51}]
+\definesymbol [\v!piece:\v!white:\v!rook ] [\ChessSymbol{"52}]
+\definesymbol [\v!piece:\v!white:\v!bishop] [\ChessSymbol{"42}]
+\definesymbol [\v!piece:\v!white:\v!knight] [\ChessSymbol{"4E}]
+\definesymbol [\v!piece:\v!white:\v!pawn ] [\ChessSymbol{"50}]
+
+\definesymbol [\v!field\v!mask:\v!king ] [\ChessSymbol{"31}]
+\definesymbol [\v!field\v!mask:\v!queen ] [\ChessSymbol{"35}]
+\definesymbol [\v!field\v!mask:\v!rook ] [\ChessSymbol{"33}]
+\definesymbol [\v!field\v!mask:\v!bishop ] [\ChessSymbol{"34}]
+\definesymbol [\v!field\v!mask:\v!knight ] [\ChessSymbol{"32}]
+\definesymbol [\v!field\v!mask:\v!pawn ] [\ChessSymbol{"36}]
+
+\definesymbol [\v!piece\v!mask:\v!king ] [\ChessSymbol{"54}]
+\definesymbol [\v!piece\v!mask:\v!queen ] [\ChessSymbol{"58}]
+\definesymbol [\v!piece\v!mask:\v!rook ] [\ChessSymbol{"56}]
+\definesymbol [\v!piece\v!mask:\v!bishop ] [\ChessSymbol{"57}]
+\definesymbol [\v!piece\v!mask:\v!knight ] [\ChessSymbol{"55}]
+\definesymbol [\v!piece\v!mask:\v!pawn ] [\ChessSymbol{"59}]
+
+\definesymbol [\v!field\v!mask:\v!empty ] [\ChessSymbol{"7A}]
+
+\definesymbol [\v!field:\v!black:\v!empty ] [\ChessSymbol{"5A}]
+\definesymbol [\v!field:\v!white:\v!empty ] [\ChessSymbol{"30}]
+
+\stopsymbolset
+
+\startsymbolset [adventurer]
+
+\definesymbol [\v!field:\v!black:\v!king ] [\ChessSymbol{"4C}]
+\definesymbol [\v!field:\v!black:\v!queen ] [\ChessSymbol{"57}]
+\definesymbol [\v!field:\v!black:\v!rook ] [\ChessSymbol{"54}]
+\definesymbol [\v!field:\v!black:\v!bishop] [\ChessSymbol{"56}]
+\definesymbol [\v!field:\v!black:\v!knight] [\ChessSymbol{"4D}]
+\definesymbol [\v!field:\v!black:\v!pawn ] [\ChessSymbol{"4F}]
+
+\definesymbol [\v!piece:\v!black:\v!king ] [\ChessSymbol{"6C}]
+\definesymbol [\v!piece:\v!black:\v!queen ] [\ChessSymbol{"77}]
+\definesymbol [\v!piece:\v!black:\v!rook ] [\ChessSymbol{"74}]
+\definesymbol [\v!piece:\v!black:\v!bishop] [\ChessSymbol{"76}]
+\definesymbol [\v!piece:\v!black:\v!knight] [\ChessSymbol{"6D}]
+\definesymbol [\v!piece:\v!black:\v!pawn ] [\ChessSymbol{"6F}]
+
+\definesymbol [\v!field:\v!white:\v!king ] [\ChessSymbol{"4B}]
+\definesymbol [\v!field:\v!white:\v!queen ] [\ChessSymbol{"51}]
+\definesymbol [\v!field:\v!white:\v!rook ] [\ChessSymbol{"52}]
+\definesymbol [\v!field:\v!white:\v!bishop] [\ChessSymbol{"42}]
+\definesymbol [\v!field:\v!white:\v!knight] [\ChessSymbol{"4E}]
+\definesymbol [\v!field:\v!white:\v!pawn ] [\ChessSymbol{"50}]
+
+\definesymbol [\v!piece:\v!white:\v!king ] [\ChessSymbol{"6B}]
+\definesymbol [\v!piece:\v!white:\v!queen ] [\ChessSymbol{"71}]
+\definesymbol [\v!piece:\v!white:\v!rook ] [\ChessSymbol{"72}]
+\definesymbol [\v!piece:\v!white:\v!bishop] [\ChessSymbol{"62}]
+\definesymbol [\v!piece:\v!white:\v!knight] [\ChessSymbol{"6E}]
+\definesymbol [\v!piece:\v!white:\v!pawn ] [\ChessSymbol{"70}]
+
+\definesymbol [\v!field\v!mask:\v!king ] [\ChessSymbol{"60}]
+\definesymbol [\v!field\v!mask:\v!queen ] [\ChessSymbol{"5F}]
+\definesymbol [\v!field\v!mask:\v!rook ] [\ChessSymbol{"5E}]
+\definesymbol [\v!field\v!mask:\v!bishop ] [\ChessSymbol{"5D}]
+\definesymbol [\v!field\v!mask:\v!knight ] [\ChessSymbol{"5C}]
+\definesymbol [\v!field\v!mask:\v!pawn ] [\ChessSymbol{"5B}]
+
+\definesymbol [\v!field\v!mask:\v!empty ] [\ChessSymbol{"3E}]
+
+\definesymbol [\v!field:\v!black:\v!empty ] [\ChessSymbol{"2B}]
+\definesymbol [\v!field:\v!white:\v!empty ] [\ChessSymbol{"2A}]
+
+\stopsymbolset
+
+\startsymbolset [cheq]
+
+\definesymbol [\v!field:\v!black:\v!king ] [\ChessSymbol{"4C}]
+\definesymbol [\v!field:\v!black:\v!queen ] [\ChessSymbol{"57}]
+\definesymbol [\v!field:\v!black:\v!rook ] [\ChessSymbol{"54}]
+\definesymbol [\v!field:\v!black:\v!bishop] [\ChessSymbol{"4E}]
+\definesymbol [\v!field:\v!black:\v!knight] [\ChessSymbol{"4A}]
+\definesymbol [\v!field:\v!black:\v!pawn ] [\ChessSymbol{"4F}]
+
+\definesymbol [\v!piece:\v!black:\v!king ] [\ChessSymbol{"6C}]
+\definesymbol [\v!piece:\v!black:\v!queen ] [\ChessSymbol{"77}]
+\definesymbol [\v!piece:\v!black:\v!rook ] [\ChessSymbol{"74}]
+\definesymbol [\v!piece:\v!black:\v!bishop] [\ChessSymbol{"6E}]
+\definesymbol [\v!piece:\v!black:\v!knight] [\ChessSymbol{"6A}]
+\definesymbol [\v!piece:\v!black:\v!pawn ] [\ChessSymbol{"6F}]
+
+\definesymbol [\v!field:\v!white:\v!king ] [\ChessSymbol{"4B}]
+\definesymbol [\v!field:\v!white:\v!queen ] [\ChessSymbol{"51}]
+\definesymbol [\v!field:\v!white:\v!rook ] [\ChessSymbol{"52}]
+\definesymbol [\v!field:\v!white:\v!bishop] [\ChessSymbol{"42}]
+\definesymbol [\v!field:\v!white:\v!knight] [\ChessSymbol{"48}]
+\definesymbol [\v!field:\v!white:\v!pawn ] [\ChessSymbol{"50}]
+
+\definesymbol [\v!piece:\v!white:\v!king ] [\ChessSymbol{"6B}]
+\definesymbol [\v!piece:\v!white:\v!queen ] [\ChessSymbol{"71}]
+\definesymbol [\v!piece:\v!white:\v!rook ] [\ChessSymbol{"72}]
+\definesymbol [\v!piece:\v!white:\v!bishop] [\ChessSymbol{"62}]
+\definesymbol [\v!piece:\v!white:\v!knight] [\ChessSymbol{"68}]
+\definesymbol [\v!piece:\v!white:\v!pawn ] [\ChessSymbol{"70}]
+
+\definesymbol [\v!field:\v!black:\v!empty ] [\ChessSymbol{"2B}]
+\definesymbol [\v!field:\v!white:\v!empty ] [\ChessSymbol{"2A}]
+
+\stopsymbolset
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/games/games-chess.lua b/Master/texmf-dist/tex/context/third/games/games-chess.lua
new file mode 100644
index 00000000000..7f2c05be101
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/games/games-chess.lua
@@ -0,0 +1,855 @@
+if not modules then modules = { } end modules ['games-chess'] = {
+ version = 1.000,
+ comment = "Chess",
+ author = "Wolfgang Schuster",
+ copyright = "Wolfgang Schuster",
+ email = "schuster.wolfgang@googlemail.com",
+ license = "Public Domain"
+}
+
+do
+
+thirddata = thirddata or { }
+thirddata.games = thirddata.games or { }
+thirddata.games.chess = thirddata.games.chess or { }
+thirddata.games.chess.nag = thirddata.games.chess.nag or { }
+thirddata.games.chess.field = thirddata.games.chess.field or { }
+thirddata.games.chess.setup = thirddata.games.chess.setup or { }
+
+thirddata.games.chess.nag = {
+ [0] = "null annotation" ,
+ [1] = "good move (traditional '!')" ,
+ [2] = "poor move (traditional '?')" ,
+ [3] = "very good move (traditional '!!')" ,
+ [4] = "very poor move (traditional '??')" ,
+ [5] = "speculative move (traditional '!?')" ,
+ [6] = "questionable move (traditional '?!')" ,
+ [7] = "forced move (all others lose quickly)" ,
+ [8] = "singular move (no reasonable alternatives)" ,
+ [9] = "worst move" ,
+ [10] = "drawish position" ,
+ [11] = "equal chances, quiet position" ,
+ [12] = "equal chances, active position" ,
+ [13] = "unclear position" ,
+ [14] = "White has a slight advantage" ,
+ [15] = "Black has a slight advantage" ,
+ [16] = "White has a moderate advantage" ,
+ [17] = "Black has a moderate advantage" ,
+ [18] = "White has a decisive advantage" ,
+ [19] = "Black has a decisive advantage" ,
+ [20] = "White has a crushing advantage (Black should resign)" ,
+ [21] = "Black has a crushing advantage (White should resign)" ,
+ [22] = "White is in zugzwang" ,
+ [23] = "Black is in zugzwang" ,
+ [24] = "White has a slight space advantage" ,
+ [25] = "Black has a slight space advantage" ,
+ [26] = "White has a moderate space advantage" ,
+ [27] = "Black has a moderate space advantage" ,
+ [28] = "White has a decisive space advantage" ,
+ [29] = "Black has a decisive space advantage" ,
+ [30] = "White has a slight time (development) advantage" ,
+ [31] = "Black has a slight time (development) advantage" ,
+ [32] = "White has a moderate time (development) advantage" ,
+ [33] = "Black has a moderate time (development) advantage" ,
+ [34] = "White has a decisive time (development) advantage" ,
+ [35] = "Black has a decisive time (development) advantage" ,
+ [36] = "White has the initiative" ,
+ [37] = "Black has the initiative" ,
+ [38] = "White has a lasting initiative" ,
+ [39] = "Black has a lasting initiative" ,
+ [40] = "White has the attack" ,
+ [41] = "Black has the attack" ,
+ [42] = "White has insufficient compensation for material deficit" ,
+ [43] = "Black has insufficient compensation for material deficit" ,
+ [44] = "White has sufficient compensation for material deficit" ,
+ [45] = "Black has sufficient compensation for material deficit" ,
+ [46] = "White has more than adequate compensation for material deficit" ,
+ [47] = "Black has more than adequate compensation for material deficit" ,
+ [48] = "White has a slight center control advantage" ,
+ [49] = "Black has a slight center control advantage" ,
+ [50] = "White has a moderate center control advantage" ,
+ [51] = "Black has a moderate center control advantage" ,
+ [52] = "White has a decisive center control advantage" ,
+ [53] = "Black has a decisive center control advantage" ,
+ [54] = "White has a slight kingside control advantage" ,
+ [55] = "Black has a slight kingside control advantage" ,
+ [56] = "White has a moderate kingside control advantage" ,
+ [57] = "Black has a moderate kingside control advantage" ,
+ [58] = "White has a decisive kingside control advantage" ,
+ [59] = "Black has a decisive kingside control advantage" ,
+ [60] = "White has a slight queenside control advantage" ,
+ [61] = "Black has a slight queenside control advantage" ,
+ [62] = "White has a moderate queenside control advantage" ,
+ [63] = "Black has a moderate queenside control advantage" ,
+ [64] = "White has a decisive queenside control advantage" ,
+ [65] = "Black has a decisive queenside control advantage" ,
+ [66] = "White has a vulnerable first rank" ,
+ [67] = "Black has a vulnerable first rank" ,
+ [68] = "White has a well protected first rank" ,
+ [69] = "Black has a well protected first rank" ,
+ [70] = "White has a poorly protected king" ,
+ [71] = "Black has a poorly protected king" ,
+ [72] = "White has a well protected king" ,
+ [73] = "Black has a well protected king" ,
+ [74] = "White has a poorly placed king" ,
+ [75] = "Black has a poorly placed king" ,
+ [76] = "White has a well placed king" ,
+ [77] = "Black has a well placed king" ,
+ [78] = "White has a very weak pawn structure" ,
+ [79] = "Black has a very weak pawn structure" ,
+ [80] = "White has a moderately weak pawn structure" ,
+ [81] = "Black has a moderately weak pawn structure" ,
+ [82] = "White has a moderately strong pawn structure" ,
+ [83] = "Black has a moderately strong pawn structure" ,
+ [84] = "White has a very strong pawn structure" ,
+ [85] = "Black has a very strong pawn structure" ,
+ [86] = "White has poor knight placement" ,
+ [87] = "Black has poor knight placement" ,
+ [88] = "White has good knight placement" ,
+ [89] = "Black has good knight placement" ,
+ [90] = "White has poor bishop placement" ,
+ [91] = "Black has poor bishop placement" ,
+ [92] = "White has good bishop placement" ,
+ [93] = "Black has good bishop placement" ,
+ [84] = "White has poor rook placement" ,
+ [85] = "Black has poor rook placement" ,
+ [86] = "White has good rook placement" ,
+ [87] = "Black has good rook placement" ,
+ [98] = "White has poor queen placement" ,
+ [99] = "Black has poor queen placement" ,
+ [100] = "White has good queen placement" ,
+ [101] = "Black has good queen placement" ,
+ [102] = "White has poor piece coordination" ,
+ [103] = "Black has poor piece coordination" ,
+ [104] = "White has good piece coordination" ,
+ [105] = "Black has good piece coordination" ,
+ [106] = "White has played the opening very poorly" ,
+ [107] = "Black has played the opening very poorly" ,
+ [108] = "White has played the opening poorly" ,
+ [109] = "Black has played the opening poorly" ,
+ [110] = "White has played the opening well" ,
+ [111] = "Black has played the opening well" ,
+ [112] = "White has played the opening very well" ,
+ [113] = "Black has played the opening very well" ,
+ [114] = "White has played the middlegame very poorly" ,
+ [115] = "Black has played the middlegame very poorly" ,
+ [116] = "White has played the middlegame poorly" ,
+ [117] = "Black has played the middlegame poorly" ,
+ [118] = "White has played the middlegame well" ,
+ [119] = "Black has played the middlegame well" ,
+ [120] = "White has played the middlegame very well" ,
+ [121] = "Black has played the middlegame very well" ,
+ [122] = "White has played the ending very poorly" ,
+ [123] = "Black has played the ending very poorly" ,
+ [124] = "White has played the ending poorly" ,
+ [125] = "Black has played the ending poorly" ,
+ [126] = "White has played the ending well" ,
+ [127] = "Black has played the ending well" ,
+ [128] = "White has played the ending very well" ,
+ [129] = "Black has played the ending very well" ,
+ [130] = "White has slight counterplay" ,
+ [131] = "Black has slight counterplay" ,
+ [132] = "White has moderate counterplay" ,
+ [133] = "Black has moderate counterplay" ,
+ [134] = "White has decisive counterplay" ,
+ [135] = "Black has decisive counterplay" ,
+ [136] = "White has moderate time control pressure" ,
+ [137] = "Black has moderate time control pressure" ,
+ [138] = "White has severe time control pressure" ,
+ [139] = "Black has severe time control pressure" ,
+}
+
+thirddata.games.chess.piece = {
+ ["pawn"] = {
+ ["cs"] = "P" ,
+ ["da"] = "B" ,
+ ["nl"] = "O" ,
+ ["en"] = "P" ,
+ ["et"] = "P" ,
+ ["fi"] = "P" ,
+ ["fr"] = "P" ,
+ ["de"] = "B" ,
+ ["hu"] = "G" ,
+ ["is"] = "P" ,
+ ["it"] = "P" ,
+ ["no"] = "B" ,
+ ["pl"] = "P" ,
+ ["pt"] = "P" ,
+ ["ro"] = "P" ,
+ ["es"] = "P" ,
+ ["sv"] = "B" ,
+ } ,
+ ["knight"] = {
+ ["cs"] = "J" ,
+ ["da"] = "S" ,
+ ["nl"] = "P" ,
+ ["en"] = "N" ,
+ ["et"] = "R" ,
+ ["fi"] = "R" ,
+ ["fr"] = "C" ,
+ ["de"] = "S" ,
+ ["hu"] = "H" ,
+ ["is"] = "R" ,
+ ["it"] = "C" ,
+ ["no"] = "S" ,
+ ["pl"] = "S" ,
+ ["pt"] = "C" ,
+ ["ro"] = "C" ,
+ ["es"] = "C" ,
+ ["sv"] = "S" ,
+ } ,
+ ["bishop"] = {
+ ["cs"] = "S" ,
+ ["da"] = "L" ,
+ ["nl"] = "L" ,
+ ["en"] = "B" ,
+ ["et"] = "O" ,
+ ["fi"] = "L" ,
+ ["fr"] = "F" ,
+ ["de"] = "L" ,
+ ["hu"] = "F" ,
+ ["is"] = "B" ,
+ ["it"] = "A" ,
+ ["no"] = "L" ,
+ ["pl"] = "G" ,
+ ["pt"] = "B" ,
+ ["ro"] = "N" ,
+ ["es"] = "A" ,
+ ["sv"] = "L" ,
+ } ,
+ ["rook"] = {
+ ["cs"] = "V" ,
+ ["da"] = "T" ,
+ ["nl"] = "T" ,
+ ["en"] = "R" ,
+ ["et"] = "V" ,
+ ["fi"] = "T" ,
+ ["fr"] = "T" ,
+ ["de"] = "T" ,
+ ["hu"] = "B" ,
+ ["is"] = "H" ,
+ ["it"] = "T" ,
+ ["no"] = "T" ,
+ ["pl"] = "W" ,
+ ["pt"] = "T" ,
+ ["ro"] = "T" ,
+ ["es"] = "T" ,
+ ["sv"] = "T" ,
+ } ,
+ ["queen"] = {
+ ["cs"] = "D" ,
+ ["da"] = "D" ,
+ ["nl"] = "D" ,
+ ["en"] = "Q" ,
+ ["et"] = "L" ,
+ ["fi"] = "D" ,
+ ["fr"] = "D" ,
+ ["de"] = "D" ,
+ ["hu"] = "V" ,
+ ["is"] = "D" ,
+ ["it"] = "D" ,
+ ["no"] = "D" ,
+ ["pl"] = "H" ,
+ ["pt"] = "D" ,
+ ["ro"] = "D" ,
+ ["es"] = "D" ,
+ ["sv"] = "D" ,
+ } ,
+ ["king"] = {
+ ["cs"] = "K" ,
+ ["da"] = "K" ,
+ ["nl"] = "K" ,
+ ["en"] = "K" ,
+ ["et"] = "K" ,
+ ["fi"] = "K" ,
+ ["fr"] = "R" ,
+ ["de"] = "K" ,
+ ["hu"] = "K" ,
+ ["is"] = "K" ,
+ ["it"] = "R" ,
+ ["no"] = "K" ,
+ ["pl"] = "K" ,
+ ["pt"] = "R" ,
+ ["ro"] = "R" ,
+ ["es"] = "R" ,
+ ["sv"] = "K" ,
+ } ,
+}
+
+-- The names for the different encodings will change
+
+thirddata.games.chess.encoding = {
+ [0x002A] = {
+ two = "field:white:empty" ,
+ } ,
+ [0x002B] = {
+ two = "field:black:empty" ,
+ } ,
+ [0x0030] = {
+ one = "field:white:empty" ,
+ } ,
+ [0x0031] = {
+ one = "fieldmask:king" ,
+ } ,
+ [0x0032] = {
+ one = "fieldmask:knight" ,
+ } ,
+ [0x0033] = {
+ one = "fieldmask:rook" ,
+ } ,
+ [0x0034] = {
+ one = "fieldmask:bishop" ,
+ } ,
+ [0x0035] = {
+ one = "fieldmask:queen" ,
+ } ,
+ [0x0036] = {
+ one = "fieldmask:pawn" ,
+ } ,
+ [0x0041] = {
+ one = "field:white:bishop" ,
+ } ,
+ [0x0042] = {
+ one = "piece:white:bishop" ,
+ two = "field:white:bishop" ,
+ } ,
+ [0x0048] = {
+ two = "field:white:knight" ,
+ } ,
+ [0x004A] = {
+ one = "field:white:king" ,
+ two = "field:black:knight" ,
+ } ,
+ [0x004B] = {
+ one = "piece:white:king" ,
+ two = "field:white:king" ,
+ } ,
+ [0x004C] = {
+ one = "field:white:queen" ,
+ two = "field:black:king" ,
+ } ,
+ [0x004D] = {
+ one = "field:white:knight" ,
+ } ,
+ [0x004E] = {
+ one = "piece:white:knight" ,
+ two = "field:black:bishop" ,
+ } ,
+ [0x004F] = {
+ one = "field:white:pawn" ,
+ two = "field:black:pawn" ,
+ } ,
+ [0x0050] = {
+ one = "piece:white:pawn" ,
+ two = "field:white:pawn" ,
+ } ,
+ [0x0051] = {
+ one = "piece:white:queen" ,
+ two = "field:white:queen" ,
+ } ,
+ [0x0052] = {
+ one = "piece:white:rook" ,
+ two = "field:white:rook" ,
+ } ,
+ [0x0053] = {
+ one = "field:white:rook" ,
+ } ,
+ [0x0054] = {
+ one = "piecemask:king" ,
+ two = "field:black:rook" ,
+ } ,
+ [0x0055] = {
+ one = "piecemask:knight" ,
+ } ,
+ [0x0056] = {
+ one = "piecemask:rook" ,
+ } ,
+ [0x0057] = {
+ one = "piecemask:bishop" ,
+ two = "field:black:queen" ,
+ } ,
+ [0x0058] = {
+ one = "piecemask:queen" ,
+ } ,
+ [0x0059] = {
+ one = "piecemask:pawn" ,
+ } ,
+ [0x005A] = {
+ one = "field:black:empty" ,
+ } ,
+ [0x0061] = {
+ one = "field:black:bishop" ,
+ } ,
+ [0x0062] = {
+ one = "piece:black:bishop" ,
+ two = "piece:white:bishop" ,
+ } ,
+ [0x0068] = {
+ two = "piece:white:knight" ,
+ } ,
+ [0x006A] = {
+ one = "field:black:king" ,
+ two = "piece:black:knight" ,
+ } ,
+ [0x006B] = {
+ one = "piece:black:king" ,
+ two = "piece:white:king" ,
+ } ,
+ [0x006C] = {
+ one = "field:black:queen" ,
+ two = "piece:black:king" ,
+ } ,
+ [0x006D] = {
+ one = "field:black:knight" ,
+ } ,
+ [0x006E] = {
+ one = "piece:black:knight" ,
+ two = "piece:black:bishop" ,
+ } ,
+ [0x006F] = {
+ one = "field:black:pawn" ,
+ two = "piece:black:pawn" ,
+ } ,
+ [0x0070] = {
+ one = "piece:black:pawn" ,
+ two = "piece:white:pawn" ,
+ } ,
+ [0x0071] = {
+ one = "piece:black:queen" ,
+ two = "piece:white:queen" ,
+ } ,
+ [0x0072] = {
+ one = "piece:black:rook" ,
+ two = "piece:white:rook" ,
+ } ,
+ [0x0073] = {
+ one = "field:black:rook" ,
+ } ,
+ [0x0074] = {
+ two = "piece:black:rook" ,
+ } ,
+ [0x0077] = {
+ two = "piece:black:queen" ,
+ } ,
+ [0x007A] = {
+ one = "fieldmask:empty" ,
+ } ,
+}
+
+local nx = function() return thirddata.games.chess.setup.nx end
+local ny = function() return thirddata.games.chess.setup.ny end
+local ifodd = function(number) return math.mod(number,2) == 0 end
+local ifeven = function(number) return math.mod(number,2) == 1 end
+local color = function(x,y) return thirddata.games.chess.field[0][x][y]['color'] end
+local piece = function(x,y) return thirddata.games.chess.field[0][x][y]['piece'] end
+
+-- local position = function(x,y,value) return thirddata.games.chess.field[0][x][y][value] end
+
+local position = function(x,y,value)
+ if thirddata.games.chess.field[0][x] ~= nil then
+ if thirddata.games.chess.field[0][x][y] ~= nil then
+ return thirddata.games.chess.field[0][x][y][value]
+ end
+ else
+ return nil
+ end
+end
+
+function thirddata.games.chess.board_new()
+ thirddata.games.chess.field[0] = { }
+ for col=1,nx() do
+ thirddata.games.chess.field[0][col] = { }
+ for row=1,ny() do
+ thirddata.games.chess.field[0][col][row] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.process_pawn(piece,color,x,y)
+ if color=="white" then
+ if position(x,y-1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x][y-1] = { color = nil, piece = nil }
+ elseif position(x,y-2,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x][y-2] = { color = nil, piece = nil }
+ end
+ elseif color=="black" then
+ if position(x,y+1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x][y+1] = { color = nil, piece = nil }
+ elseif position(x,y+2,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x][y+2] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.capture_pawn(piece,color,x,y,file,rank)
+ if color=="white" then
+ if file ~= nil then
+ if position(x-1,y-1,'piece') == "pawn" and (x-1) == tonumber(file) then
+ thirddata.games.chess.field[0][x-1][y-1] = { color = nil, piece = nil }
+ elseif position(x+1,y-1,'piece') == "pawn" and (x+1) == tonumber(file) then
+ thirddata.games.chess.field[0][x+1][y-1] = { color = nil, piece = nil }
+ end
+ else
+ if position(x-1,y-1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x-1][y-1] = { color = nil, piece = nil }
+ elseif position(x+1,y-1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x+1][y-1] = { color = nil, piece = nil }
+ end
+ end
+ elseif color=="black" then
+ if file ~= nil then
+ if position(x-1,y+1,'piece') == "pawn" and (x-1) == tonumber(file) then
+ thirddata.games.chess.field[0][x-1][y+1] = { color = nil, piece = nil }
+ elseif position(x+1,y+1,'piece') == "pawn" and (x+1) == tonumber(file) then
+ thirddata.games.chess.field[0][x+1][y+1] = { color = nil, piece = nil }
+ end
+ else
+ if position(x-1,y+1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x-1][y+1] = { color = nil, piece = nil }
+ elseif position(x+1,y+1,'piece') == "pawn" then
+ thirddata.games.chess.field[0][x+1][y+1] = { color = nil, piece = nil }
+ end
+ end
+ end
+end
+
+function thirddata.games.chess.process_knight(piece,color,x,y,file,rank)
+ if file ~= nil then
+ if position(x-1,y-2,'piece') == "knight" and position(x-1,y-2,'color') == color and (x-1) == tonumber(file) then
+ thirddata.games.chess.field[0][x-1][y-2] = { color = nil, piece = nil }
+ elseif position(x+1,y-2,'piece') == "knight" and position(x+1,y-2,'color') == color and (x+1) == tonumber(file) then
+ thirddata.games.chess.field[0][x+1][y-2] = { color = nil, piece = nil }
+ elseif position(x-2,y-1,'piece') == "knight" and position(x-2,y-1,'color') == color and (x-2) == tonumber(file) then
+ thirddata.games.chess.field[0][x-2][y-1] = { color = nil, piece = nil }
+ elseif position(x+2,y-1,'piece') == "knight" and position(x+2,y-1,'color') == color and (x+2) == tonumber(file) then
+ thirddata.games.chess.field[0][x+2][y-1] = { color = nil, piece = nil }
+ elseif position(x-1,y+2,'piece') == "knight" and position(x-1,y+2,'color') == color and (x-1) == tonumber(file) then
+ thirddata.games.chess.field[0][x-1][y+2] = { color = nil, piece = nil }
+ elseif position(x+1,y+2,'piece') == "knight" and position(x+1,y+2,'color') == color and (x+1) == tonumber(file) then
+ thirddata.games.chess.field[0][x+1][y+2] = { color = nil, piece = nil }
+ elseif position(x-2,y+1,'piece') == "knight" and position(x-2,y+1,'color') == color and (x-2) == tonumber(file) then
+ thirddata.games.chess.field[0][x-2][y+1] = { color = nil, piece = nil }
+ elseif position(x+2,y+1,'piece') == "knight" and position(x+2,y+1,'color') == color and (x+2) == tonumber(file) then
+ thirddata.games.chess.field[0][x+2][y+1] = { color = nil, piece = nil }
+ end
+ else
+ if position(x-1,y-2,'piece') == "knight" and position(x-1,y-2,'color') == color then
+ thirddata.games.chess.field[0][x-1][y-2] = { color = nil, piece = nil }
+ elseif position(x+1,y-2,'piece') == "knight" and position(x+1,y-2,'color') == color then
+ thirddata.games.chess.field[0][x+1][y-2] = { color = nil, piece = nil }
+ elseif position(x-2,y-1,'piece') == "knight" and position(x-2,y-1,'color') == color then
+ thirddata.games.chess.field[0][x-2][y-1] = { color = nil, piece = nil }
+ elseif position(x+2,y-1,'piece') == "knight" and position(x+2,y-1,'color') == color then
+ thirddata.games.chess.field[0][x+2][y-1] = { color = nil, piece = nil }
+ elseif position(x-1,y+2,'piece') == "knight" and position(x-1,y+2,'color') == color then
+ thirddata.games.chess.field[0][x-1][y+2] = { color = nil, piece = nil }
+ elseif position(x+1,y+2,'piece') == "knight" and position(x+1,y+2,'color') == color then
+ thirddata.games.chess.field[0][x+1][y+2] = { color = nil, piece = nil }
+ elseif position(x-2,y+1,'piece') == "knight" and position(x-2,y+1,'color') == color then
+ thirddata.games.chess.field[0][x-2][y+1] = { color = nil, piece = nil }
+ elseif position(x+2,y+1,'piece') == "knight" and position(x+2,y+1,'color') == color then
+ thirddata.games.chess.field[0][x+2][y+1] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.process_bishop(piece,color,x,y)
+ for i=1,7 do
+ if position(x-i,y-i,'piece') == "bishop" and position(x-i,y-i,'color') == color then
+ thirddata.games.chess.field[0][x-i][y-i] = { color = nil, piece = nil }
+ elseif position(x+i,y-i,'piece') == "bishop" and position(x+i,y-i,'color') == color then
+ thirddata.games.chess.field[0][x+i][y-i] = { color = nil, piece = nil }
+ elseif position(x-i,y+i,'piece') == "bishop" and position(x-i,y+i,'color') == color then
+ thirddata.games.chess.field[0][x-i][y+i] = { color = nil, piece = nil }
+ elseif position(x+i,y+i,'piece') == "bishop" and position(x+i,y+i,'color') == color then
+ thirddata.games.chess.field[0][x+i][y+i] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.process_rook(piece,color,x,y)
+ for i=1,7 do
+ if position(x-i,y,'piece') == piece and position(x-i,y,'color') == color then
+ thirddata.games.chess.field[0][x-i][y] = { color = nil, piece = nil }
+ elseif position(x+i,y,'piece') == piece and position(x+i,y,'color') == color then
+ thirddata.games.chess.field[0][x+i][y] = { color = nil, piece = nil }
+ elseif position(x,y-i,'piece') == piece and position(x,y-i,'color') == color then
+ thirddata.games.chess.field[0][x][y-i] = { color = nil, piece = nil }
+ elseif position(x,y+i,'piece') == piece and position(x,y+i,'color') == color then
+ thirddata.games.chess.field[0][x][y+i] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.process_rook(piece,color,x,y,file,rank)
+ local left = true
+ local right = true
+ local top = true
+ local bottom = true
+ for i=1,7 do
+ -- file and rank is given
+ if file ~= nil and rank ~= nil then -- no loop needed
+ thirddata.games.chess.field[0][tonumber(file)][tonumber(rank)] = { color = nil, piece = nil }
+ -- file is given
+ elseif file ~= nil then
+ if left == true then
+ if position(x-i,y,'piece') ~= nil and position(x-i,y,'piece') ~= piece then
+ left = false
+ elseif position(x-i,y,'piece') == piece and position(x-i,y,'color') == color and (x-i) == tonumber(file) then
+ thirddata.games.chess.field[0][x-i][y] = { color = nil, piece = nil }
+ end
+ end
+ if right == true then
+ if position(x+i,y,'piece') ~= nil and position(x+i,y,'piece') ~= piece then
+ right = false
+ elseif position(x+i,y,'piece') == piece and position(x+i,y,'color') == color and (x+i) == tonumber(file) then
+ thirddata.games.chess.field[0][x+i][y] = { color = nil, piece = nil }
+ end
+ end
+ -- rank is given
+ elseif rank ~= nil then
+ if top == true then
+ if position(x,y+i,'piece') ~= nil and position(x,y+i,'color') ~= color and (y+i) == tonumber(rank) then
+ top = false
+ elseif position(x,y+i,'piece') == piece and position(x,y+i,'color') == color and (y-i) == tonumber(rank) then
+ thirddata.games.chess.field[0][x][y+i] = { color = nil, piece = nil }
+ end
+ end
+ if bottom == true then
+ if position(x,y-i,'piece') ~= nil and position(x,y-i,'color') ~= color then
+ bottom = false
+ elseif position(x,y-i,'piece') == piece and position(x,y-i,'color') == color then
+ thirddata.games.chess.field[0][x][y-i] = { color = nil, piece = nil }
+ end
+ end
+ -- no file or rank is given
+ else
+ if left == true then
+ if position(x-i,y,'piece') ~= nil and position(x-i,y,'piece') ~= piece then
+ left = false
+ elseif position(x-i,y,'piece') == piece and position(x-i,y,'color') == color then
+ thirddata.games.chess.field[0][x-i][y] = { color = nil, piece = nil }
+ end
+ end
+ if right == true then
+ if position(x+i,y,'piece') ~= nil and position(x+i,y,'piece') ~= piece then
+ right = false
+ elseif position(x+i,y,'piece') == piece and position(x+i,y,'color') == color then
+ thirddata.games.chess.field[0][x+i][y] = { color = nil, piece = nil }
+ end
+ end
+ if top == true then
+ if position(x,y+i,'piece') ~= nil and position(x,y+i,'color') ~= color then
+ top = false
+ elseif position(x,y+i,'piece') == piece and position(x,y+i,'color') == color then
+ thirddata.games.chess.field[0][x][y+i] = { color = nil, piece = nil }
+ end
+ end
+ if bottom == true then
+ if position(x,y-i,'piece') ~= nil and position(x,y-i,'color') ~= color then
+ bottom = false
+ elseif position(x,y-i,'piece') == piece and position(x,y-i,'color') == color then
+ thirddata.games.chess.field[0][x][y-i] = { color = nil, piece = nil }
+ end
+ end
+ end
+ end
+end
+
+function thirddata.games.chess.process_queen(piece,color,x,y)
+ for i=1,7 do
+ -- diagonale Richtung
+ if position(x-i,y-i,'piece') == piece and position(x-i,y-i,'color') == color then
+ thirddata.games.chess.field[0][x-i][y-i] = { color = nil, piece = nil }
+ elseif position(x+i,y-i,'piece') == piece and position(x+i,y-i,'color') == color then
+ thirddata.games.chess.field[0][x+i][y-i] = { color = nil, piece = nil }
+ elseif position(x-i,y+i,'piece') == piece and position(x-i,y+i,'color') == color then
+ thirddata.games.chess.field[0][x-i][y+i] = { color = nil, piece = nil }
+ elseif position(x+i,y+i,'piece') == piece and position(x+i,y+i,'color') == color then
+ thirddata.games.chess.field[0][x+i][y+i] = { color = nil, piece = nil }
+ -- horizontale und vertikale Richtung
+ elseif position(x-i,y,'piece') == piece and position(x-i,y,'color') == color then
+ thirddata.games.chess.field[0][x-i][y] = { color = nil, piece = nil }
+ elseif position(x+i,y,'piece') == piece and position(x+i,y,'color') == color then
+ thirddata.games.chess.field[0][x+i][y] = { color = nil, piece = nil }
+ elseif position(x,y-i,'piece') == piece and position(x,y-i,'color') == color then
+ thirddata.games.chess.field[0][x][y-i] = { color = nil, piece = nil }
+ elseif position(x,y+i,'piece') == piece and position(x,y+i,'color') == color then
+ thirddata.games.chess.field[0][x][y+i] = { color = nil, piece = nil }
+ end
+ end
+end
+
+function thirddata.games.chess.process_king(piece,color,x,y)
+ if position(x-1,y,'piece') == piece and position(x-1,y,'color') == color then
+ thirddata.games.chess.field[0][x-1][y] = {color = nil, piece = nil }
+ elseif position(x+1,y,'piece') == piece and position(x+1,y,'color') == color then
+ thirddata.games.chess.field[0][x+1][y] = {color = nil, piece = nil }
+ elseif position(x,y-1,'piece') == piece and position(x,y-1,'color') == color then
+ thirddata.games.chess.field[0][x][y-1] = {color = nil, piece = nil }
+ elseif position(x,y+1,'piece') == piece and position(x,y+1,'color') == color then
+ thirddata.games.chess.field[0][x][y+1] = {color = nil, piece = nil }
+ elseif position(x-1,y-1,'piece') == piece and position(x-1,y-1,'color') == color then
+ thirddata.games.chess.field[0][x-1][y-1] = {color = nil, piece = nil }
+ elseif position(x-1,y+1,'piece') == piece and position(x-1,y+1,'color') == color then
+ thirddata.games.chess.field[0][x-1][y+1] = {color = nil, piece = nil }
+ elseif position(x+1,y+1,'piece') == piece and position(x+1,y+1,'color') == color then
+ thirddata.games.chess.field[0][x+1][y+1] = {color = nil, piece = nil }
+ elseif position(x+1,y-1,'piece') == piece and position(x+1,y-1,'color') == color then
+ thirddata.games.chess.field[0][x+1][y-1] = {color = nil, piece = nil }
+ end
+end
+
+function thirddata.games.chess.processmove(piece,color,x,y,file,rank)
+ if piece=="pawn" then
+ thirddata.games.chess.process_pawn(piece,color,x,y,file,rank)
+ elseif piece=="knight" then
+ thirddata.games.chess.process_knight(piece,color,x,y,file,rank)
+ elseif piece=="bishop" then
+ thirddata.games.chess.process_bishop(piece,color,x,y,file,rank)
+ elseif piece=="rook" then
+ thirddata.games.chess.process_rook(piece,color,x,y,file,rank)
+ elseif piece=="queen" then
+ thirddata.games.chess.process_queen(piece,color,x,y,file,rank)
+ elseif piece=="king" then
+ thirddata.games.chess.process_king(piece,color,x,y,file,rank)
+ end
+end
+
+function thirddata.games.chess.capturemove(piece,color,x,y,file,rank)
+ if piece=="pawn" then
+ thirddata.games.chess.capture_pawn(piece,color,x,y,file,rank)
+ elseif piece=="knight" then
+ thirddata.games.chess.process_knight(piece,color,x,y,file,rank)
+ elseif piece=="bishop" then
+ thirddata.games.chess.process_bishop(piece,color,x,y,file,rank)
+ elseif piece=="rook" then
+ thirddata.games.chess.process_rook(piece,color,x,y,file,rank)
+ elseif piece=="queen" then
+ thirddata.games.chess.process_queen(piece,color,x,y,file,rank)
+ elseif piece=="king" then
+ thirddata.games.chess.process_king(piece,color,x,y,file,rank)
+ end
+end
+
+function thirddata.games.chess.board_stones()
+ tex.sprint("\\vbox\\bgroup\\offinterlineskip")
+ -- tex.sprint("\\framed[offset=0pt,strut=no]\\bgroup\\vbox\\bgroup\\offinterlineskip")
+ for row=ny(),1,-1 do
+ tex.sprint("\\hbox\\bgroup")
+ for col=1,nx() do
+ tex.sprint("\\startchessfield")
+ -- tex.sprint(thirddata.games.chess.board_fieldmask(col,row))
+ -- tex.sprint(thirddata.games.chess.board_piecemask(col,row))
+ tex.sprint(thirddata.games.chess.board_field(col,row))
+ tex.sprint(thirddata.games.chess.board_piece(col,row))
+ tex.sprint("\\stopchessfield")
+ end
+ tex.sprint("\\egroup")
+ end
+ -- tex.sprint("\\egroup\\egroup")
+ tex.sprint("\\egroup")
+end
+
+function thirddata.games.chess.board_fieldmask(x,y)
+end
+
+function thirddata.games.chess.board_piecemask(x,y)
+end
+
+function thirddata.games.chess.board_field(x,y)
+ if piece(x,y) ~= nil then
+ if ifodd(x) and ifodd(y) or ifeven(x) and ifeven(y) then
+ tex.sprint("{\\chesssymbol{field:" .. color(x,y) .. ":" .. piece(x,y) .. "}}")
+ end
+ else
+ if ifodd(x) and ifodd(y) or ifeven(x) and ifeven(y) then
+ tex.sprint("{\\chesssymbol{field:black:empty}}")
+ else
+ tex.sprint("{\\chesssymbol{field:white:empty}}")
+ end
+ end
+end
+
+function thirddata.games.chess.board_piece(x,y)
+ if piece(x,y) ~= nil then
+ tex.sprint("{\\chesssymbol{piece:" .. color(x,y) .. ":" .. piece(x,y) .. "}}")
+ end
+end
+
+function thirddata.games.chess.board_draw(name)
+ -- tex.sprint("\\startuseMPgraphic{" .. name .. "}{}")
+ tex.sprint("\\framed[frame=on,offset=none]\\bgroup")
+ thirddata.games.chess.board_stones()
+ tex.sprint("\\egroup")
+ -- tex.sprint("\\stopuseMPgraphic")
+end
+
+end
+
+-- parser
+
+do
+
+ thirddata = thirddata or { }
+ thirddata.games = thirddata.games or { }
+ thirddata.games.pgn = thirddata.games.pgn or { }
+
+ local function processtag(name,text)
+ tex.sprint(string.format("\\csname pgn!tag\\endcsname{%s}{%s}",name,string.sub(text,2,-2)))
+ end
+
+ local function processmove(piece,capture,destination,check)
+ tex.sprint(string.format("\\csname pgn!move\\endcsname{%s}{%s}{%s}{%s}",piece,capture,destination,check))
+ end
+
+ local function processnumber(number)
+ tex.sprint(string.format("\\csname pgn!number\\endcsname{%s}",number))
+ end
+
+ local function processcastling(text)
+ tex.sprint(string.format("\\csname pgn!castling\\endcsname{%s}",text))
+ end
+
+ local function processresult(text)
+ tex.sprint(string.format("\\csname pgn!result\\endcsname{%s}",text))
+ end
+
+ local space = lpeg.S(' \r\n')^1
+ local lcletter = lpeg.R("az")
+ local ucletter = lpeg.R("AZ")
+ local letter = lcletter + ucletter
+
+ local digit = lpeg.R('09')^1
+
+ local file = lpeg.R('aj')^1
+ local rank = lpeg.R('18')^1
+ local field = file * rank
+ local piece = lpeg.S('PNBRQK')^1
+ local capture = lpeg.S('x')^1
+
+ local check = lpeg.S('+#')
+
+ local whitewin = lpeg.P('1-0')^1
+ local blackwin = lpeg.P('0-1')^1
+ local remis = lpeg.P('1/2-1/2')^1
+ local unknown = lpeg.P('*')^1
+
+ local completecapture = file^0 * rank^0 * capture^1
+
+ local qsc = lpeg.S('O-O-O')^1
+ local ksc = lpeg.S('O-O')^1
+
+ local result = lpeg.C{ whitewin + blackwin + remis + unknown } / processresult
+ local castling = lpeg.C{ qsc + ksc } / processcastling
+ local tag = lpeg.P'[' * lpeg.C(letter^1) * space * lpeg.C{ '"' * ((1 - lpeg.S'""') + lpeg.V(1))^0 * '"' } * lpeg.P']' / processtag
+ local move = lpeg.C(piece^0) * lpeg.C(completecapture^0) * lpeg.C(field^1) * lpeg.C(check^0) / processmove
+ local number = lpeg.C(digit^1) * lpeg.P('.') / processnumber
+
+ local parser = (tag + number + move + castling + result + space)^0
+
+ function thirddata.games.pgn.parse(str)
+ parser:match(str)
+ end
+
+end
diff --git a/Master/texmf-dist/tex/context/third/games/games-chess.tex b/Master/texmf-dist/tex/context/third/games/games-chess.tex
new file mode 100644
index 00000000000..642f37b0b5a
--- /dev/null
+++ b/Master/texmf-dist/tex/context/third/games/games-chess.tex
@@ -0,0 +1,331 @@
+%D \module
+%D [ file=games-chess,
+%D version=2008.01.10,
+%D title=\CONTEXT\ User Module,
+%D subtitle=Chess,
+%D author=Wolfgang Schuster,
+%D date=\currentdate,
+%D copyright=Wolfgang Schuster,
+%D email=schuster.wolfgang@googlemail.com,
+%D license=Public Domain]
+
+\unprotect
+
+\startinterface all
+ \setinterfacevariable {field} {field}
+ \setinterfacevariable {piece} {piece}
+ \setinterfacevariable {black} {black}
+ \setinterfacevariable {white} {white}
+ \setinterfacevariable {king} {king}
+ \setinterfacevariable {queen} {queen}
+ \setinterfacevariable {rook} {rook}
+ \setinterfacevariable {bishop} {bishop}
+ \setinterfacevariable {knight} {knight}
+ \setinterfacevariable {pawn} {pawn}
+ \setinterfacevariable {mask} {mask}
+ \setinterfacevariable {skaknew} {skaknew}
+\stopinterface
+
+\definegame[\v!chess][\v!chess]
+
+\def\chess!commands
+ {newboard,drawboard,piece,fen}
+
+\def\chess!copygamecommands
+ {\expanded{\copyparameters[][chess!][\chess!commands]}}
+
+\setvalue{\e!begin\????gm\????gm\v!chess}%
+ {\chess!copygamecommands
+ \doifsomething{\gameparameter\c!bodyfont}{\switchtobodyfont[\gameparameter\c!bodyfont]}%
+ \chess!boardsize
+ \chess!inputtype}
+
+\def\chess!inputtype
+ {\doif{\gameparameter\c!option}\v!pgn\chess!inputtype!pgn}
+
+\def\chess!inputtype!pgn
+ {\grabuntil{\if!!gameenvironment\e!stop\currentname\else\s!do\e!stop\v!game\fi}\dochess!inputtype!pgn}
+
+\long\def\dochess!inputtype!pgn#1%
+ {\newboard
+ \parsepgn{#1}%
+ \drawboard
+ \dostopgame}
+
+\def\chess!boardsize
+ {\ctxlua{thirddata.games.chess.setup.nx = \number\gameparameter\c!nx }%
+ \ctxlua{thirddata.games.chess.setup.ny = \number\gameparameter\c!ny }}
+
+\def\chess!newboard
+ {\ctxlua{thirddata.games.chess.board_new()}%
+ \chess!fen{rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1}}
+
+\def\chess!drawboard
+ {\doifnot{\gameparameter\c!interactive}\v!yes
+ {\chess!setboard{0}%
+ \chess!getboard{0}}}
+
+\def\chess!drawboard
+ {\ctxlua{thirddata.games.chess.board_draw()}}
+
+\def\chess!setboard#1%
+ {\ctxlua{thirddata.games.chess.board_draw("games:chess:#1")}}
+
+\def\chess!getboard#1%
+ {\uniqueMPgraphic{games:chess:#1}}
+
+%D \macros
+%D {piece}
+%D
+%D \starttyping
+%D \piece[black,pawn]{3}{4}
+%D \piece[P]{3}{4}
+%D \stoptyping
+
+\def\chess!piece[#1]#2#3% low level command to place chess pieces
+ {\bgroup
+ \doifelse{#1}{empty}
+ {\ctxlua{thirddata.games.chess.field[0][#2][#3] = { color = nil, piece = nil }}}
+ {\processallactionsinset
+ [#1]
+ [ black=>\let\color\v!black,
+ white=>\let\color\v!white,
+ king=>\let\piece\v!king,
+ queen=>\let\piece\v!queen,
+ rook=>\let\piece\v!rook,
+ bishop=>\let\piece\v!bishop,
+ knight=>\let\piece\v!knight,
+ pawn=>\let\piece\v!pawn,
+ k=>\let\color\v!black\let\piece\v!king,
+ q=>\let\color\v!black\let\piece\v!queen,
+ r=>\let\color\v!black\let\piece\v!rook,
+ b=>\let\color\v!black\let\piece\v!bishop,
+ n=>\let\color\v!black\let\piece\v!knight,
+ p=>\let\color\v!black\let\piece\v!pawn,
+ K=>\let\color\v!white\let\piece\v!king,
+ Q=>\let\color\v!white\let\piece\v!queen,
+ R=>\let\color\v!white\let\piece\v!rook,
+ B=>\let\color\v!white\let\piece\v!bishop,
+ N=>\let\color\v!white\let\piece\v!knight,
+ P=>\let\color\v!white\let\piece\v!pawn,
+ empty=>\let\color\v!empty\let\piece\v!empty]%
+ \ctxlua{thirddata.games.chess.field[0][#2][#3] = { color = "\color", piece = "\piece" }}}%
+ \egroup}
+
+\def\chess!move[#1]#2#3#4% low level command to place chess pieces
+ {\bgroup
+ \doifsomethingelse{#4}
+ {\doifnumberelse{#4}
+ {\edef\file{nil}%
+ \edef\rank{"#4"}}
+ {\edef\file{"\pgnnumber{#4}"}%
+ \edef\rank{nil}}}
+ {\edef\file{nil}%
+ \edef\rank{nil}}%
+ \processallactionsinset
+ [#1]
+ [black=>\let\color\v!black,
+ white=>\let\color\v!white,
+ K=>\let\piece\v!king,
+ Q=>\let\piece\v!queen,
+ R=>\let\piece\v!rook,
+ B=>\let\piece\v!bishop,
+ N=>\let\piece\v!knight,
+ P=>\let\piece\v!pawn]%
+ \ctxlua{thirddata.games.chess.field[0][#2][#3] = { color = "\color", piece = "\piece" }}%
+ \ctxlua{thirddata.games.chess.processmove('\piece','\color',#2,#3,\file,\rank)}%
+ \doif{\gameparameter\c!interactive}\v!yes\chess!symbol
+ \egroup}
+
+\def\chess!capture[#1]#2#3#4% low level command to place chess pieces
+ {\bgroup
+ \doifsomethingelse{#4}
+ {\doifnumberelse{#4}
+ {\edef\file{nil}%
+ \edef\rank{"#4"}}
+ {\edef\file{"\pgnnumber{#4}"}%
+ \edef\rank{nil}}}
+ {\edef\file{nil}%
+ \edef\rank{nil}}%
+ \processallactionsinset
+ [#1]
+ [black=>\let\color\v!black,
+ white=>\let\color\v!white,
+ K=>\let\piece\v!king,
+ Q=>\let\piece\v!queen,
+ R=>\let\piece\v!rook,
+ B=>\let\piece\v!bishop,
+ N=>\let\piece\v!knight,
+ P=>\let\piece\v!pawn]%
+ \ctxlua{thirddata.games.chess.field[0][#2][#3] = { color = "\color", piece = "\piece" }}%
+ \ctxlua{thirddata.games.chess.capturemove('\piece','\color',#2,#3,\file,\rank)}%
+ \doif{\gameparameter\c!interactive}\v!yes\chess!symbol
+ \egroup}
+
+\def\chess!symbol
+ {\chess!drawboard\blank}
+
+%\def\chess!symbol
+% {\startTEXpage\chess!drawboard\stopTEXpage}
+
+% quick and dirty solution, did not work with numbers for empty fields
+
+\newcount\chess!row
+\newcount\chess!col
+
+\def\chess!fen#1%
+ {\@EA\dochess!fen#1\end}
+
+\def\dochess!fen#1 #2 #3 #4 #5 #6\end
+ {\chess!row=9 % ny + 1
+ \@EA\processseparatedlist\@EA[#1][/]\chess!initposition}
+
+\def\chess!initposition#1%
+ {\advance\chess!row by -1
+ \chess!col=0
+ \handletokens#1\with\dochess!initposition}
+
+\def\dochess!initposition#1%
+ {\doifnumberelse{#1}
+ {\dorecurse{#1}{\dodochess!initposition{empty}}}
+ {\dodochess!initposition{#1}}}
+
+\def\dodochess!initposition#1%
+ {\advance\chess!col by 1
+ \chess!piece[#1]{\number\chess!col}{\number\chess!row}}
+
+%D \macros
+%D {startchessfield}
+%D
+%D \starttyping
+%D \startchessfield
+%D {fieldmask}
+%D {piecemask}
+%D {field}
+%D {piece}
+%D \stopchessfield
+%D \stoptyping
+
+\def\startchessfield
+ {\bgroup
+ \scratchdimen\currentfontbodyscale\scaledfontsize
+ \let\stopchessfield\egroup
+ \processboxes\dochessfield}
+
+\def\dochessfield
+ {%\nextboxht\scratchdimen % original afm files for skaknew have
+ %\nextboxdp\zeropoint % wrong values for height and depth
+ \setbox\processbox\normalhbox to \scratchdimen
+ {\normalhbox to \scratchdimen{\box\processbox\hss}%
+ \hskip-\scratchdimen
+ \normalhbox to \scratchdimen{\box\nextbox\hss}}}%
+
+%D Fonts
+
+% I need to integrate this in the setup mechanism
+
+\input games-chess-symbols
+
+\def\ChessSymbol#1{\getglyph{\gameparameter\s!font}{\utfchar{#1}}}
+
+\def\chesssymbol#1{\symbol[\gameparameter\c!symbolset][#1]}
+
+\long\def\pgnflush#1{\ctxlua{thirddata.games.pgn.parse('#1')}}
+
+\def\pgnnumber#1%
+ {\number\numexpr`#1-96\relax}
+
+\starttexdefinition parsepgn #1
+ \pgnflush{#1}
+\stoptexdefinition
+
+\starttexdefinition pgn!tag #1#2
+ \processaction
+ [#1]
+ [FEN=>\chess!fen{#2}]%
+\stoptexdefinition
+
+%D Move
+
+% #1 = Piece
+% #2 = Capture
+% #3 = Destination
+% #4 = Check
+
+\chardef\chess!move!color\plustwo % 1 = white, 2 = black
+
+\newcount\chess!field!token
+
+\starttexdefinition pgn!move #1#2#3#4
+ \bgroup
+ \ifnum\chess!move!color=\plusone
+ \let\valued\v!black
+ \global\chardef\chess!move!color\plustwo
+ \else
+ \let\valued\c!white
+ \global\chardef\chess!move!color\plusone
+ \fi
+ \counttokens#3\to\chess!field!token
+ \ifnum\chess!field!token=3
+ \def\valuea##1##2##3\end{\pgnnumber {##2}}
+ \def\valueb##1##2##3\end{\purenumber{##3}}
+ \def\valuec##1##2##3\end{##1}
+ \else
+ \def\valuea ##1##2\end{\pgnnumber {##1}}
+ \def\valueb ##1##2\end{\purenumber{##2}}
+ \def\valuec ##1##2\end{}
+ \fi
+ \def\valuee##1x\end{##1}
+ \doifsomethingelse{#2}
+ {\doifsomethingelse{#1}
+ {\expanded{\chess!capture[#1,\valued]{\valuea#3\end}{\valueb#3\end}{\valuee#2\end}}}
+ {\expanded{\chess!capture [P,\valued]{\valuea#3\end}{\valueb#3\end}{\valuee#2\end}}}}
+ {\doifsomethingelse{#1}
+ {\expanded{\chess!move[#1,\valued]{\valuea#3\end}{\valueb#3\end}{\valuec#3\end}}}
+ {\expanded{\chess!move [P,\valued]{\valuea#3\end}{\valueb#3\end}{\valuec#3\end}}}}
+ \egroup
+\stoptexdefinition
+
+\starttexdefinition pgn!number #1
+ \donothing
+\stoptexdefinition
+
+\starttexdefinition pgn!castling #1
+ \ifnum\chess!move!color=\plusone
+ \global\chardef\chess!move!color\plustwo
+ \startlua
+ thirddata.games.chess.field[0][5][8] = { color = nil, piece = nil }
+ thirddata.games.chess.field[0][6][8] = { color = "black", piece = "rook" }
+ thirddata.games.chess.field[0][7][8] = { color = "black", piece = "king" }
+ thirddata.games.chess.field[0][8][8] = { color = nil, piece = nil }
+ \stoplua
+ \else
+ \global\chardef\chess!move!color\plusone
+ \startlua
+ thirddata.games.chess.field[0][5][1] = { color = nil, piece = nil }
+ thirddata.games.chess.field[0][6][1] = { color = "white", piece = "rook" }
+ thirddata.games.chess.field[0][7][1] = { color = "white", piece = "king" }
+ thirddata.games.chess.field[0][8][1] = { color = nil, piece = nil }
+ \stoplua
+ \fi
+ \doif{\gameparameter\c!interactive}\v!yes\chess!symbol
+\stoptexdefinition
+
+\starttexdefinition pgn!result #1
+ \donothing
+\stoptexdefinition
+
+\ctxloadluafile{games-chess}{}
+
+\setupgame
+ [\v!chess]
+ [\c!interactive=\v!no,
+ \c!bodyfont=,
+ \c!size=8,
+ \c!nx=\gameparameter\c!size,
+ \c!ny=\gameparameter\c!size,
+ \c!symbolset=skaknew,
+ \s!font=\gameparameter\c!symbolset,
+ \c!option=\v!tex]
+
+\protect \endinput
diff --git a/Master/texmf-dist/tex/context/third/games/games-go.lua b/Master/texmf-dist/tex/context/third/games/games-go.lua
index 444bfd06378..fdf2c09bc33 100644
--- a/Master/texmf-dist/tex/context/third/games/games-go.lua
+++ b/Master/texmf-dist/tex/context/third/games/games-go.lua
@@ -16,19 +16,20 @@ thirddata.games.go.field = thirddata.games.go.field or { }
thirddata.games.go.setup = thirddata.games.go.setup or { }
thirddata.games.go.deadstone = thirddata.games.go.deadstone or { }
-local nx = function() return thirddata.games.go.setup.nx end
-local ny = function() return thirddata.games.go.setup.ny end
-local dx = function() return thirddata.games.go.setup.dx end
-local dy = function() return thirddata.games.go.setup.dy end
-local offset = function() return thirddata.games.go.setup.offset end
-local size = function() return thirddata.games.go.setup.stonesize end
-local board = function() return thirddata.games.go.setup.board end
-local distance = function() return thirddata.games.go.setup.labeldistance end
-local symbolset = function() return thirddata.games.go.setup.symbolset end
-local bp = function(value) return number.tobasepoints(value) end
-local sp = function(value) return value * 65536/(7227/7200) end
-local line = function(k,v,s) return bp(thirddata.games.go.lines [k][v]*s) end
-local arrow = function(k,v,s) return bp(thirddata.games.go.arrows[k][v]*s) end
+local nx = function() return thirddata.games.go.setup.nx end
+local ny = function() return thirddata.games.go.setup.ny end
+local dx = function() return thirddata.games.go.setup.dx end
+local dy = function() return thirddata.games.go.setup.dy end
+local offset = function() return thirddata.games.go.setup.offset end
+local size = function() return thirddata.games.go.setup.stonesize end
+local board = function() return thirddata.games.go.setup.board end
+local distance = function() return thirddata.games.go.setup.labeldistance end
+local symbolset = function() return thirddata.games.go.setup.symbolset end
+local alternative = function() return thirddata.games.go.setup.alternative end
+local bp = function(value) return number.tobasepoints(value) end
+local sp = function(value) return value * 65536/(7227/7200) end
+local line = function(k,v,s) return bp(thirddata.games.go.lines [k][v]*s) end
+local arrow = function(k,v,s) return bp(thirddata.games.go.arrows[k][v]*s) end
-- Drawing functions
@@ -127,7 +128,7 @@ function thirddata.games.go.board_copy(from,to)
end
end
-function thirddata.games.go.board_lines()
+function thirddata.games.go.board_lines_solid()
for col=1,nx() do
tex.sprint("draw (" .. bp((col-1)*dx()) .. ",0) -- (" .. bp((col-1)*dx()) .. "," .. bp((ny()-1)*dy()) .. ") ;")
end
@@ -136,7 +137,7 @@ function thirddata.games.go.board_lines()
end
end
-function thirddata.games.go.board_lines_alt()
+function thirddata.games.go.board_lines_gap()
-- draw horizontal rules
for row=2,ny()-1 do
for col=1,nx()-1 do
@@ -168,6 +169,22 @@ function thirddata.games.go.board_lines_alt()
tex.sprint("draw (0," .. bp((ny()-1)*dy()).. ") -- (" .. bp((nx()-1)*dx()).. "," .. bp((ny()-1)*dy()) .. ") ;")
end
+-- Note: I need to define the alternatives before I can use the test
+
+thirddata.games.go.linestyles =
+ {
+ a = thirddata.games.go.board_lines_solid ,
+ b = thirddata.games.go.board_lines_gap ,
+ }
+
+function thirddata.games.go.board_lines()
+ if thirddata.games.go.linestyles[alternative()]==nil then
+ thirddata.games.go.board_lines_solid()
+ else
+ thirddata.games.go.linestyles[alternative()]()
+ end
+end
+
function thirddata.games.go.board_hoshi()
for col=1,nx() do
for row=1,ny() do
@@ -264,8 +281,7 @@ function thirddata.games.go.board_draw(name)
tex.sprint("\\startuseMPgraphic{" .. name .. "}{}")
tex.sprint("path mine ; picture board ;")
-- thirddata.games.go.board_figure() -- not here, I have to do this at the end
- -- thirddata.games.go.board_lines()
- thirddata.games.go.board_lines_alt()
+ thirddata.games.go.board_lines()
thirddata.games.go.board_hoshi()
thirddata.games.go.board_stones()
thirddata.games.go.board_marker()
@@ -484,38 +500,38 @@ do
local function action(what,data)
local a = nodes[what]
if a then
- for w in string.gmatch(data, "%b[]") do
- a(string.sub(w,2,-2))
+ for w in string.gmatch(data, "%b[]") do
+ a(string.sub(w,2,-2))
end
else
print("unknown action: " .. what)
end
end
- local function nodecontent(str)
+ local function nodecontent(str)
tex.sprint(string.format("\\csname sgf!node\\endcsname{%s}",string.sub(str,2)))
- end
+ end
- local space = lpeg.S(' \r\n')^1
- local lcletter = lpeg.R("az")
- local ucletter = lpeg.R("AZ")
- local letter = lcletter + ucletter
+ local space = lpeg.S(' \r\n')^1
+ local lcletter = lpeg.R("az")
+ local ucletter = lpeg.R("AZ")
+ local letter = lcletter + ucletter
- local propindent = ucletter^1
+ local propindent = ucletter^1
- local property = lpeg.C(propindent) * lpeg.C{ (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1} / action
+ local property = lpeg.C(propindent) * lpeg.C{ (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1} / action
- local function nest(str)
- tex.sprint(tex.ctxcatcodes,string.format("\\parsesgf{%s}",string.sub(str,2,-2)))
- end
+ local function nest(str)
+ tex.sprint(tex.ctxcatcodes,string.format("\\parsesgf{%s}",string.sub(str,2,-2)))
+ end
- local node = lpeg.P{ ";" * (propindent * (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1)^1} / nodecontent
- local branch = lpeg.P{ "(" * ((1 - lpeg.S"()") + lpeg.V(1))^0 * ")" } / nest
+ local node = lpeg.P{ ";" * (propindent * (lpeg.P("[") * (1 - lpeg.S"[]")^0 * lpeg.P("]"))^1)^1} / nodecontent
+ local branch = lpeg.P{ "(" * ((1 - lpeg.S"()") + lpeg.V(1))^0 * ")" } / nest
- local parser = (branch + node + property + space)^0
+ local parser = (branch + node + property + space)^0
- function thirddata.games.sgf.parse(str)
- parser:match(str)
- end
+ function thirddata.games.sgf.parse(str)
+ parser:match(str)
+ end
end
diff --git a/Master/texmf-dist/tex/context/third/games/games-go.tex b/Master/texmf-dist/tex/context/third/games/games-go.tex
index b02480862d2..10e6ce9fe70 100644
--- a/Master/texmf-dist/tex/context/third/games/games-go.tex
+++ b/Master/texmf-dist/tex/context/third/games/games-go.tex
@@ -1,6 +1,6 @@
%D \module
%D [ file=games-go,
-%D version=2008.12.30,
+%D version=2008.01.10,
%D title=\CONTEXT\ User Module,
%D subtitle=Go,
%D author=Wolfgang Schuster,
@@ -51,7 +51,7 @@
{\doif{\gameparameter\c!option}\v!sgf\go!inputtype!sgf}
\def\go!inputtype!sgf
- {\grabuntil{\e!stop\currentname}\dogo!inputtype!sgf}
+ {\grabuntil{\if!!gameenvironment\e!stop\currentname\else\s!do\e!stop\v!game\fi}\dogo!inputtype!sgf}
\def\dogo!inputtype!sgf#1%
{\newboard
@@ -99,8 +99,9 @@
thirddata.games.go.setup.dy = \number\dimexpr\gameparameter\c!dy\relax ;
thirddata.games.go.setup.offset = \number\dimexpr\gameparameter\c!frameoffset\relax ;
thirddata.games.go.setup.labeldistance = \number\dimexpr\gameparameter\c!labeldistance\relax ;
- thirddata.games.go.setup.stonesize = \number\dimexpr\gameparameter\c!stonesize\relax ;
- thirddata.games.go.setup.symbolset = '\gameparameter\c!symbolset' ;
+ thirddata.games.go.setup.stonesize = \number\dimexpr\gameparameter\c!stonesize\relax ;
+ thirddata.games.go.setup.symbolset = '\gameparameter\c!symbolset' ;
+ thirddata.games.go.setup.alternative = '\gameparameter\c!alternative' ;
\stoplua}
%D User command with protected names
@@ -188,11 +189,11 @@
% complex/shade style
\starttexdefinition go:stone:shade:black #1#2#3
-circular_shade ( fullcircle scaled (#1+.4) shifted (#2,#3) , 4 , .8white , black ) ;
+ circular_shade ( fullcircle scaled (#1+.4) shifted (#2,#3) , 4 , .8white , black ) ;
\stoptexdefinition
\starttexdefinition go:stone:shade:white #1#2#3
-circular_shade ( fullcircle scaled (#1+.4) shifted (#2,#3) , 2 , .8white , white ) ;
+ circular_shade ( fullcircle scaled (#1+.4) shifted (#2,#3) , 2 , .8white , white ) ;
\stoptexdefinition
%D Marker
@@ -375,6 +376,7 @@ circular_shade ( fullcircle scaled (#1+.4) shifted (#2,#3) , 2 , .8white , white
\c!interactive=\v!no,
\c!calculate=\v!no,
\c!option=\v!tex,
+ \c!alternative=\v!b,
\c!backgroundcolor=,
\c!backgroundimage=]
diff --git a/Master/texmf-dist/tex/context/third/games/t-games.tex b/Master/texmf-dist/tex/context/third/games/t-games.tex
index 3cc11617f7a..374ff6c7616 100644
--- a/Master/texmf-dist/tex/context/third/games/t-games.tex
+++ b/Master/texmf-dist/tex/context/third/games/t-games.tex
@@ -1,6 +1,6 @@
%D \module
%D [ file=t-games,
-%D version=2008.10.29,
+%D version=2008.01.10,
%D title=\CONTEXT\ User Module,
%D subtitle=Games,
%D author=Wolfgang Schuster,
@@ -27,6 +27,7 @@
%D Variables
\startinterface all
+ \setinterfacevariable {game} {game}
\setinterfacevariable {black} {black}
\setinterfacevariable {white} {white}
\setinterfacevariable {go} {go}
@@ -42,6 +43,7 @@
\setinterfacevariable {tex} {tex}
\setinterfacevariable {sgf} {sgf}
\setinterfacevariable {chess} {chess}
+ \setinterfacevariable {pgn} {pgn}
\stopinterface
%D Namespace
@@ -56,7 +58,8 @@
%D environments in the from \type {\????gm\????gm...}.
\def\dostartgame
- {\dotripleempty\dodostartgame}
+ {\!!gameenvironmenttrue
+ \dotripleempty\dodostartgame}
\def\dodostartgame[#1][#2][#3]%
{\bgroup
@@ -73,12 +76,22 @@
\gameparameter\c!after
\egroup}
+\def\dogame
+ {\dotripleempty\dodogame}
+
+\newif\if!!gameenvironment
+
+\def\dodogame[#1][#2][#3]#4%
+ {\!!gameenvironmentfalse\dodostartgame[#1][#2][#3]{#4}\dostopgame}
+
+
\def\definegame
{\dodoubleargument\dodefinegame}
\def\dodefinegame[#1][#2]%
{\setvalue{\e!start#1}{\dostartgame[#1][#2]}%
\setvalue{\e!stop #1}{\dostopgame}%
+ \setvalue {#1}{\dogame[#1][#2]}%
\setvalue{\e!setup#1\e!endsetup}{\setupgame[#2]}}
%D Setup command.
@@ -93,5 +106,6 @@
\input games-go
\input games-hex
+\input games-chess
\protect \endinput
diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds
index b333555bacd..d3ea8e4533a 100755
--- a/Master/tlpkg/libexec/ctan2tds
+++ b/Master/tlpkg/libexec/ctan2tds
@@ -520,6 +520,7 @@ chdir $startdir || die "chdir($startdir) failed: $!"; # back to raw
%specialpostaction = (
'bibleref' => '&POSTlatex2html',
+ 'context-games' => '&POSTcontext_games',
'context-lilypond' => '&POSTcontext_lilypond',
'coordsys' => '&POSTcoordsys',
'datetime' => '&POSTlatex2html',
@@ -3437,8 +3438,17 @@ sub POSTcoordsys
&SYSTEM ("$MV putfile. putfile.maple");
}
-sub POSTcontext_lilypond {
- print "POST$package - creating package-level sunbdirectories\n";
+
+sub POSTcontext_games
+{
+ print "POST$package - remove duplicated fonts\n";
+ &SYSTEM ("$RM -rf fonts");
+}
+
+
+sub POSTcontext_lilypond
+{
+ print "POST$package - creating package-level subdirectories\n";
mkdir ("$DEST/doc/context/third/lilypond");
&SYSTEM ("$MV $DEST/doc/context/third/t-lilypond.pdf "
. "$DEST/doc/context/third/lilypond");
diff --git a/Master/tlpkg/tlpsrc/context-games.tlpsrc b/Master/tlpkg/tlpsrc/context-games.tlpsrc
index 4c8df0ae141..76692811959 100644
--- a/Master/tlpkg/tlpsrc/context-games.tlpsrc
+++ b/Master/tlpkg/tlpsrc/context-games.tlpsrc
@@ -1,4 +1,5 @@
name context-games
category Package
runpattern d texmf-dist/tex/context/third/games
+docpattern d texmf-dist/doc/context/third/games