Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Chinese+Xiangqi+Chessboard?V=57
QUERY_STRINGV=57
CONTENT_TYPE
DOCUMENT_URI/revision/Chinese+Xiangqi+Chessboard
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.70.130.93
REMOTE_PORT35414
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.133.147.252
HTTP_CF_RAY882257806f6686ec-ORD
HTTP_X_FORWARDED_PROTOhttps
HTTP_CF_VISITOR{"scheme":"https"}
HTTP_ACCEPT*/*
HTTP_USER_AGENTMozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; [email protected])
HTTP_CF_CONNECTING_IP3.133.147.252
HTTP_CDN_LOOPcloudflare
HTTP_CF_IPCOUNTRYUS

Body


Error

Unknow state transition: LINE -> END

-code

1

-level

0

-errorstack

INNER {returnImm {Unknow state transition: LINE -> END} {}} CALL {my render_wikit {Chinese Xiangqi Chessboard} **Chinese\ Xianqi\ Chessboard**\n\n----\ \ \ \nThis\ page\ is\ under\ development.\ Comments\ are\ welcome,\ but\ please\ load\ any\ comments\ in\ the\ comments\ section\ at\ the\ middle\ of\ the\ page.\ Thanks,\[gold\]\n\n----\n\[gold\]\ Here\ is\ some\ starter\ code\ for\ Chinese\ Xiangqi\ Chessboard.\ \n\ There\ are\ several\ avenues\ for\ a\ Xianqi\ chessboard.\ Literature\n\ search\ showed\ many\ chess\ programs\ relying\ on\ a\ gif\ of\ the\ chinese\n\ chessboard.\n\ Primarily\ looking\ at\ \[RS\]'s\ checkers.tcl\ on\ the\ wiki\ to\ get\n\ some\ primary\ movable\ pieces\ with\ the\ board.\ \ I\ installed\n\ a\ version\ of\ the\ code\ in\ the\ Simple\ Canvas\ Demo\ for\ some\ pictures.\n\ \ Also\ I\ made\ a\ lengthy\ list\ of\ 60\ line\ creations\ in\ TCLpaint,but\n\ \ we\ better\ rely\ on\ foreach\ or\ loop\ statements\ for\ compact\ code.\ \n\ \ \ http://wiki.tcl.tk/884\n\ \ \ http://wiki.tcl.tk/15073\n\n----\ \n\ \ \ The\ characters\ are\ generally\ stamped\ red\ and\ blue\ on\ round\ wooden\ pieces,\nwhich\ might\ be\ unicode\ characters\ in\ chinese.\n\ \ \ #\ probably\ need\ an\ if\ switch\ option\ for\ TCL\ lists\ \ \n\ \ \ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \{將士\ \ 士將\ \ 象\ 象\ 馬\ 馬\ 車\ 車\ \ \ 砲\ \ \ 砲\ \ \ \ 卒\ 卒卒\ \ \ 卒卒\ \ \ \]#trad.\ \ \ \ \n\ \ \ \ \n\ \ \ \ \ ***set\ redpieces\ \ \{\ \ 帥\ \ \ 仕\ \ 象\ 象\ \ 相\ \ \ 相\ 馬\ 馬\ 車\ 車\ 砲\ 砲\ \ \ 兵炮\ \ 炮\ \ 兵\ \ \ \ \ 兵\ \ \ \ \ 兵\ \ \ 兵\ \ \ \]\ #trad\n\ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \{王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\}***#simplified\n\ \ \ \ \ ***set\ redpieces\ \ \{王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\}***simplified\n\ \ \ \ \ set\ bluepieces\ \{K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\ \ \ \ \ set\ redpieces\ \ \{K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ \n\n\n\n----\n\n\ \n----\n**Screenshots\ Section**\n\n\[http://farm5.static.flickr.com/4136/4743183050_a37afc987d.jpg\]\ \n\n\[http://farm5.static.flickr.com/4096/4743212494_7b08112447.jpg\]\n\n----\n**Comments\ Section**\nPlease\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Changes.\n\n\[AMG\]:\ I\ suggest\ using\ a\ \[for\]\ loop\ to\ make\ \[\[chessboard\]\]\ more\ concise.\n\n\[gold\]\ Is\ there\ some\ way\ to\ multiply\ all\ numbers\ in\ a\ create\ statement,\ leaving\ the\nalpha\ characters\ unchanged?\ I\ tried\ but\ kept\ bombing,\ and\ wound\ up\ with\ this\ code.\n\n======\n\ set\ bee1\ \[\ list\ .c\ create\ poly\ \ -8\ 10\ \ -8\ 7\ \ -5\ 7\ \ -2\ -1\ \ -4\ -5\ \ -2\ -10\ \ 2\ -10\ \ 4\ -5\ \ 2\ -1\ \ 5\ 7\ \ 8\ 7\ \ 8\ 10\ \]\n\ \ \ \ \ \ set\ bee2\ \[\ list\ \ \ \ -8\ 10\ \ -8\ 7\ \ -5\ 7\ \ -2\ -1\ \ -4\ -5\ \ -2\ -10\ \ 2\ -10\ \ 4\ -5\ \ 2\ -1\ \ 5\ 7\ \ 8\ 7\ \ 8\ 10\ \]\n\ \ \ \ set\ check\ \"1\"\n\ \ \ \ \ foreach\ factor\ \[list\ \ 10\ 12\ 14\ 16\ 18\ 20\]\ \{\n\ \ \ \ \ set\ cat\ \[list\ \ \]\n\ \ \ \ \ foreach\ item\ \$bee1\ \{\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ >>\ 0\}\ \{lappend\ cat\ \ \$item\ \}\n\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ ==\ 0\ \}\ \{lappend\ cat\ \[\ expr\ 200*\$factor*.1\ +\ \$item\ *\ log(\$factor)\ \ \]\}\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \n\ \ \ \ \ \ eval\ \$cat\ -outline\ gray\ \ -fill\ \[lpick\ \$randomcolor\ \]\ \n\ \ \ \ \ \ \ \}\n======\n\n\[AMG\]:\ Yes,\ but\ it's\ very\ complex.\ \ You'd\ have\ to\ use\ \[\[\[regexp\]\ -indices\ -all\ \{\\d+\}\ \$string\]\]\ to\ find\ the\ start\ and\ end\ indices\ corresponding\ to\ the\ numbers,\ then\ you'd\ extract\ each\ number,\ multiply\ it,\ and\ replace\ it\ back\ into\ the\ string\ using\ \[\[\[string\ replace\]\]\].\ \ I\ don't\ recommend\ this\ approach,\ especially\ since\ it's\ liable\ to\ modify\ numbers\ you\ didn't\ intend\ to\ modify.\ \ Also,\ that\ regular\ expression\ I\ gave\ only\ works\ for\ integers\;\ detecting\ floating\ point\ numbers\ is\ even\ harder.\n\nWhat\ you\ need\ to\ do\ is\ have\ each\ creation\ parameter\ be\ a\ function\ of\ your\ \[for\]\ loop\ iterators.\ \ You\ say\ you\ have\ a\ \[Fortran\]\ background\;\ this\ concept\ should\ be\ familiar\ to\ you,\ except\ that\ Fortran\ says\ \"DO\"\ instead\ of\ \"for\".\ :^)\ \ More\ seriously,\ Tcl\ for\ loops\ are\ weird\ (in\ the\ same\ way\ that\ \[C\]\ for\ loops\ are\ weird).\ \ They\ take\ four\ arguments:\n\n\ \ \ 1.\ Initialization\ script.\ \ This\ is\ executed\ before\ the\ loop\ begins.\ \ It's\ normally\ used\ to\ create\ the\ iteration\ variable.\n\ \ \ 1.\ Termination\ test.\ \ This\ expression\ is\ tested\ before\ each\ iteration,\ and\ if\ it's\ false,\ the\ loop\ stops.\n\ \ \ 1.\ Advancement\ script.\ \ This\ is\ executed\ after\ each\ iteration\ of\ the\ loop.\ \ It's\ normally\ used\ to\ increment\ the\ iteration\ variable.\n\ \ \ 1.\ Iteration\ body\ script.\ \ This\ is\ executed\ each\ time\ the\ loop\ iterates,\ just\ before\ the\ advancement\ script.\ \ Your\ main\ code\ goes\ here.\n\nHere's\ code\ to\ make\ a\ grid\ similar\ to\ the\ one\ your\ program\ creates.\ \ It\ shows\ both\ for\ and\ \[foreach\].\ \ To\ be\ honest,\ foreach\ is\ simpler\ than\ for\ when\ there\ are\ a\ very\ small\ number\ of\ iterations.\ \ Here,\ replace\ the\ first\ for\ with\ \"`foreach\ i\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\}\ \{...\}`\"\ and\ the\ second\ for\ with\ \"`foreach\ i\ \{0\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\}\ \{...\}`\".\n\n======\nset\ dx\ 20\ \ \ \ \;#\ pixels\ between\ adjacent\ vertical\ grid\ lines\nset\ dy\ 20\ \ \ \ \;#\ pixels\ between\ adjacent\ horizontal\ grid\ lines\nset\ x0\ 30\ \ \ \ \;#\ pixels\ between\ left\ of\ canvas\ and\ left\ of\ grid\nset\ y0\ 30\ \ \ \ \;#\ pixels\ between\ top\ of\ canvas\ and\ top\ of\ grid\nset\ win\ .c\ \ \ \;#\ name\ of\ canvas\ widget\nforeach\ i\ \{0\ 8\}\ \{\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \$y0\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{9\ *\ \$dy\ +\ \$y0\}\]\n\}\nfor\ \{set\ i\ 1\}\ \{\$i\ <\ 8\}\ \{incr\ i\}\ \{\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \$y0\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{4\ *\ \$dy\ +\ \$y0\}\]\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{5\ *\ \$dy\ +\ \$y0\}\]\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{9\ *\ \$dy\ +\ \$y0\}\]\n\}\nfor\ \{set\ i\ 0\}\ \{\$i\ <\ 10\}\ \{incr\ i\}\ \{\n\ \ \ \ \$win\ create\ line\ \$x0\ \[expr\ \{\$i\ *\ \$dy\ +\ \$y0\}\]\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{8\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{\$i\ *\ \$dy\ +\ \$y0\}\]\n\}\n======\n\nThere's\ more\ work\ to\ be\ done,\ though.\ \ Hopefully\ this\ will\ get\ you\ started.\n\n----\n**References***\n\n\ \ \ *\ \[Simple\ Canvas\ Demo\]\n\ \ \ *\ http://www.goddesschess.com/chessays/gaddbabylon.html\n\ \ \ *\ http://skookumpete.com/chess_intro.htm\n\n\n\nhttp://mayoneez.1g.fi/hiddenlynx/index.html\nhttp://www.chessvariants.org/graphics.dir/big5/index.html\n\nhttp://geert.vanderkelen.org/2009/12/chessboard-in-mysql.html\n\n\n\ \ http://pinyin.info/tools/converter/chars2uninumbers.html\n\n\nhttp://en.wikipedia.org/wiki/Miscellaneous_Symbols_Unicode_block\n\n\n\n\n\n\n\nhttp://wiki.tcl.tk/884\nhttp://wiki.tcl.tk/9493\nhttp://wiki.tcl.tk/14255\nhttp://99.237.250.152/xq/book/xiangqi_printset.pdfunicode\n\n\n\nhttp://play.chessvariants.org/pbm/presets/chinese_chess.html\nhttp://www.yutopian.com/chinesechess/chrules.pdf\n\n**appendix\ TCL\ programs**\n\n***FIRST\ VERSION***\ \n\n======\n\ #start\ of\ deck#start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ \n\ \n\n\ set\ oscwidth\ 1000\ \n\ set\ oschorizontal\ 500\ \n\ proc\ loop\ \{from\ to\ body\}\ \{\n\ \ \ \ upvar\ 1\ i\ i\ \;#\ make\ index\ visible\ in\ body\n\ \ \ \ for\ \{set\ i\ \$from\}\ \{\$i<\$to\}\ \{incr\ i\}\ \{uplevel\ 1\ \$body\}\n\ \}\n\ \ \ #--\ And\ likewise,\ a\ shortcut\ for\ addition:\n\ proc\ +\ \{a\ b\}\ \{expr\ \{\$a+\$b\}\}\n\ \n\ pack\ \[canvas\ .cv\ -width\ 400\ -height\ 500\ \]\n\n\ focus\ .cv\ \n\ set\ state2\ 1\n\ proc\ refreshgrid\ \{\ .cv\ state2\}\ \{\n\ global\ oscwidth\ oschorizontal\ colorite\n\ global\ grid\n\ set\ colorite\ blue\ \n\ for\ \{set\ x\ 10\}\ \{\$x<\$oscwidth\}\ \{incr\ x\ 50\}\ \{.cv\ create\ line\ \$x\ 0\ \$x\ \$oschorizontal\ \ -fill\ blue\ -tag\ grid\ -\n\nwidth\ 4\}\n\ for\ \{set\ y\ 20\}\ \{\$y<\$oschorizontal\}\ \{incr\ y\ 50\}\ \{.cv\ create\ line\ 0\ \$y\ \$oschorizontal\ \$y\ -fill\ blue\ \ -tag\ grid\ \n\n-width\ 4\}\ \n\ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\n\ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\ \}\n\n\n\n\ \ refreshgrid\ \ .cv\ \$state2\ \n\ #\ next\ lines\ start\ withn\ periods,\ but\ hard\ to\ see\n\ .\ configure\ -borderwidth\ 0\ -highlightthickness\ 0\ -takefocus\ 0\ -background\ aquamarine4\n\ .\ configure\ -background\ palegreen\ -highlightcolor\ DarkOliveGreen\ -relief\ raised\ -border\ 30\n\n\ .\ configure\ -width\ 1000\ -height\ 2000\n\n\n\n\ \ \ \ \ .cv\ bind\ all\ <1>\ \{set\ p(X)\ \[.cv\ canvasx\ %x\]\;\ set\ p(Y)\ \[.cv\ canvasy\ %y\]\}\n\ .cv\ bind\ mv\ <B1-Motion>\ \{mv\ .cv\ %x\ %y\}\n\n\ \ \ \ \ \ proc\ mv\ \{w\ x\ y\}\ \{\n\ \ \ \ global\ p\n\ \ \ \ set\ x\ \ \[\$w\ canvasx\ \$x\]\n\ \ \ \ set\ y\ \ \[\$w\ canvasy\ \$y\]\n\ \ \ \ set\ id\ \[\$w\ find\ withtag\ current\]\n\ \ \ \ set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \n\ \ \ \ puts\ \"1\"\n\ \ \ \ puts\ \$numberx\n\ \ \ \ puts\ \$tilex\n\ \ \ \ puts\ \"\ with\ tag\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\"\n\ \ \ \ foreach\ item\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\ \{\n\ \ \ \ \$w\ move\ \$item\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ \}\n\ \ \ \ puts\ \"\ x\ y\ \$x\ \$y\"\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ #\ \$w\ move\ \[\$w\ find\ withtag\ \"\$tilex\"\]\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ #regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ set\ p(X)\ \$x\;\ set\ p(Y)\ \$y\n\ \}\n\n\ \n\ \n\n\n\ \ \ \n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ #black\ western\n\ \ \ \ \ set\ bluepieces\ \{\ \ \\u265A\ \\u265B\ \\u265C\ \\u265C\ \\u265D\ \\u265D\ \\u265E\ \\u265E\ \\u265F\ \\u265F\ \\u265F\ \\u265F\ \n\n\\u265F\ \\u265F\ \\u265F\ \\u265F\}\ \ \n\ \ \ \ \ #white\ western\n\ \ \ \ \ set\ redpieces\ \{\ \ \\u2654\ \\u2655\ \\u2655\ \\u2656\ \ \\u2656\ \\u2657\ \\u2657\ \ \\u2658\ \\u2658\ \\u2659\ \\u2659\ \\u2659\ \ \n\n\\u2659\ \\u2659\ \\u2659\ \\u2659\ \\u2659\}\ \ \n\ \ \ \ \ \ \ set\ bluepieces\ \{\\u5C07\ \\u58EB\ \ \\u58EB\ \ \\u8C61\ \\u8C61\ \\u99AC\ \\u99AC\ \\u8ECA\ \\u8ECA\ \ \ \\u7832\ \ \ \\u7832\ \ \ \ \n\n\\u5352\ \\u5352\ \\u5352\ \ \ \\u5352\ \\u5352\}\n\ set\ redpieces\ \ \{\ \ \\u5E25\ \ \ \\u4ED5\ \\u4ED5\ \ \ \\u76F8\ \ \ \\u76F8\ \\u99AC\ \\u99AC\ \\u8ECA\ \\u8ECA\ \\u7832\ \\u7832\ \ \ \ \ \n\n\\u70AE\ \ \\u70AE\ \ \\u5175\ \ \\u5175\ \ \ \ \\u5175\ \ \ \ \ \\u5175\ \ \ \\u5175\ \\u5E25\}\ \ \n\ \ \ \ \ \n\ \ \ \ \ set\ ind\ 0\n\ \ \ \ \ set\ indx\ 0\n\ \ \ \ \ set\ baseline\ \{list\ 1\}\n\ \ \ \ \ \ proc\ K\ \{\ x\ y\ \}\ \{\ set\ x\ \}\n\n\ \ \ \ \ proc\ xpop\ \{\ topper\ \}\ \{\n\ \ \ \ \ global\ liner\n\ \ \ \ \ global\ ind\ indx\n\ \ \ \ \ global\ bluepieces\ redpieces\n\ \ \ \ \ global\ baseline\n\ \ \ \ \ set\ topper\ \[\ lindex\ \$bluepieces\ \$ind\ \]\;\n\ \ \ \ \ if\ \{\ \$topper\ ==\ \"\"\ \}\ \{\ \n\ \ \ \ \ set\ topper\ \[\ lindex\ \$redpieces\ \$indx\ \]\n\ \ \ \ \ set\ indx\ \[\ expr\ \{\ \$indx\ +\ 1\}\]\n\ \ \ \ \ \ \ \}\ \n\ \ \ \ \ set\ ind\ \[\ expr\ \{\ \$ind\ +\ 1\}\]\n\ \ \ \ \ lappend\ \$baseline\ \$topper\;\n\ \ \ \ \ return\ \$topper\;\n\ \ \ \ \ \}\n\ \ \ \ \ \ proc\ populateCanvas\ \{w\ cols\ rows\ args\}\ \{\n\ \ \ \ global\ ind\ indx\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ set\ canvas\ \$w\n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 50\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{\ orange\ yellow\ green\ \ gray\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ #set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ #\ set\ text\ \[xpop\ topper\]\n\ \ \ \ \ \ \ \ \ set\ font2\ \[list\ Helvetica\ \[expr\ \$boxwidth/2\]\]\n\n\ \ \ \ \ \ \ \ \ #set\ text\ \"0\"\n\ \ \ \ \ \ \ \ \ #set\ text\ \"K\"\n\ \ \ \ \ \ \ \ \ set\ text\ \[xpop\ 1\ \]\n\ \ \ \ \ \ \ \ \ set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ oval\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ -tags\ \[concat\ mv\ rect\ \$args\ \ obj_\$tilename\]\\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ colorfo\ blue\n\ \ \ \ \ \ \ \ if\ \{\ \$indx\ >\ 1\ \}\ \{set\ colorfo\ red\}\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -font\ \$font2\ -fill\ \$colorfo\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\ -tags\ \[concat\ mv\ \ \$args\ \ obj_\$tilename\]\ \ \]\n\n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\ \ \n\ \ \ \ \ populateCanvas\ .cv\ 6\ 7\ \ \n\ \ console\ show\ \n\ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #statements\ for\ random\ names\ of\ objects\n\ \ \ \ \ \ \ \ #set\ numberx\ \[.c\ \ gettags\ current\]\;\n\ \ \ \ \ \ \ \ #\ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \ \ \ #.c\ delete\ \"obj_\$tilex+1\"\ \;\n\ \ \ \ \ \ #set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ #.c\ delete\ obj_\$tilex\ \;\n\n\n\n\ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n======\n\n****SECOND\ VERSION\ WITH\ ADDED\ HACKS\ ***\ \n\n\n======\ \n\n\ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\n\n\n\n\ \ set\ oscwidth\ 1000\ \n\ \ set\ oschorizontal\ 500\ \n\ \ proc\ loop\ \{from\ to\ body\}\ \{\n\ \ \ \ upvar\ 1\ i\ i\ \;#\ make\ index\ visible\ in\ body\n\ \ \ \ for\ \{set\ i\ \$from\}\ \{\$i<\$to\}\ \{incr\ i\}\ \{uplevel\ 1\ \$body\}\n\ \}\n\ #--\ And\ likewise,\ a\ shortcut\ for\ addition:\n\ \ proc\ +\ \{a\ b\}\ \{expr\ \{\$a+\$b\}\}\n\ \n\ \ pack\ \[canvas\ .cv\ -width\ 400\ -height\ 500\ \]\n\n\ focus\ .cv\ \n\ set\ state2\ 1\n\ proc\ refreshgrid\ \{\ .cv\ state2\}\ \{\n\ global\ oscwidth\ oschorizontal\ colorite\n\ global\ grid\n\ set\ colorite\ blue\ \n\ \ for\ \{set\ x\ 10\}\ \{\$x<\$oscwidth\}\ \{incr\ x\ 50\}\ \{.cv\ create\ line\ \$x\ 0\ \$x\ \$oschorizontal\ \ -fill\ blue\ -tag\ grid\ -\n\nwidth\ 4\}\n\ for\ \{set\ y\ 20\}\ \{\$y<\$oschorizontal\}\ \{incr\ y\ 50\}\ \{.cv\ create\ line\ 0\ \$y\ \$oschorizontal\ \$y\ -fill\ blue\ \ -tag\ grid\ \n\n-width\ 4\}\ \n\ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\ \n\ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\ \}\n\n\n\n\ \ refreshgrid\ \ .cv\ \$state2\ \n\ \ #\ next\ lines\ start\ withn\ periods,\ but\ hard\ to\ see\n\ \ .\ configure\ -borderwidth\ 0\ -highlightthickness\ 0\ -takefocus\ 0\ -background\ aquamarine4\n\ \ .\ configure\ -background\ palegreen\ -highlightcolor\ DarkOliveGreen\ -relief\ raised\ -border\ 30\n\n\ \ .\ configure\ -width\ 1000\ -height\ 2000\n\n\n\n\ \ .cv\ bind\ all\ <1>\ \{set\ p(X)\ \[.cv\ canvasx\ %x\]\;\ set\ p(Y)\ \[.cv\ canvasy\ %y\]\}\n\ \ .cv\ bind\ mv\ <B1-Motion>\ \{mv\ .cv\ %x\ %y\}\n\n\ \ \ proc\ mv\ \{w\ x\ y\}\ \{\n\ \ \ \ global\ p\n\ \ \ \ set\ x\ \ \[\$w\ canvasx\ \$x\]\n\ \ \ \ set\ y\ \ \[\$w\ canvasy\ \$y\]\n\ \ \ \ set\ id\ \[\$w\ find\ withtag\ current\]\n\ \ \ \ set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \n\ \ \ \ puts\ \"1\"\n\ \ \ \ puts\ \$numberx\n\ \ \ \ puts\ \$tilex\n\ \ \ \ puts\ \"\ with\ tag\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\"\n\ \ \ \ foreach\ item\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\ \{\n\ \ \ \ \$w\ move\ \$item\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ \}\n\ \ \ \ puts\ \"\ x\ y\ \$x\ \$y\"\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ #\ \$w\ move\ \[\$w\ find\ withtag\ \"\$tilex\"\]\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ #regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ set\ p(X)\ \$x\;\ set\ p(Y)\ \$y\n\ \ \}\n\n\ \n\ \n\n\n\ \ \ \n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ #black\n\ \ \ \ \ set\ bluepieces\ \{\ \ \\u265A\ \\u265B\ \\u265C\ \\u265C\ \\u265D\ \\u265D\ \\u265E\ \\u265E\ \\u265F\ \\u265F\ \\u265F\ \\u265F\ \n\n\\u265F\ \\u265F\ \\u265F\ \\u265F\}\ \ \n\ \ \ \ \ #white\n\ \ \ \ \ set\ redpieces\ \{\ \ \\u2654\ \\u2655\ \\u2656\ \ \\u2656\ \\u2657\ \\u2657\ \ \\u2658\ \\u2658\ \\u2659\ \\u2659\ \\u2659\ \ \\u2659\ \n\n\\u2659\ \\u2659\ \\u2659\ \\u2659\}\ \ \n\ \ \ \ \ \ \n\ \n\ \ \ \ \ \n\ \ \ \ \ set\ ind\ 0\n\ \ \ \ \ set\ indx\ 0\n\ \ \ \ \ set\ baseline\ \{list\ 1\}\n\ \ \ \ \ \ proc\ K\ \{\ x\ y\ \}\ \{\ set\ x\ \}\n\n\ \ \ \ \ proc\ xpop\ \{\ topper\ \}\ \{\n\ \ \ \ \ global\ liner\n\ \ \ \ \ global\ ind\ indx\n\ \ \ \ \ global\ bluepieces\ redpieces\n\ \ \ \ \ global\ baseline\n\ \ \ \ \ set\ topper\ \[\ lindex\ \$bluepieces\ \$ind\ \]\;\n\ \ \ \ \ if\ \{\ \$topper\ ==\ \"\"\ \}\ \{\ \n\ \ \ \ \ set\ topper\ \[\ lindex\ \$redpieces\ \$indx\ \]\n\ \ \ \ \ set\ indx\ \[\ expr\ \{\ \$indx\ +\ 1\}\]\n\ \ \ \ \ \ \ \}\ \n\ \ \ \ \ set\ ind\ \[\ expr\ \{\ \$ind\ +\ 1\}\]\n\ \ \ \ \ lappend\ \$baseline\ \$topper\;\n\ \ \ \ \ return\ \$topper\;\n\ \ \ \ \ \}\n\ \ \ \ \ proc\ populateCanvas\ \{w\ cols\ rows\ args\}\ \{\n\ \ \ \ global\ ind\ indx\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ set\ canvas\ \$w\n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 50\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{\ orange\ yellow\ green\ \ gray\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ #set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ #\ set\ text\ \[xpop\ topper\]\n\ \ \ \ \ \ \ \ \ set\ font2\ \[list\ Helvetica\ \[expr\ \$boxwidth/2\]\]\n\n\ \ \ \ \ \ \ \ \ #set\ text\ \"0\"\n\ \ \ \ \ \ \ \ \ #set\ text\ \"K\"\n\ \ \ \ \ \ \ \ \ set\ text\ \[xpop\ 1\ \]\n\ \ \ \ \ \ \ \ \ set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ oval\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ -tags\ \[concat\ mv\ rect\ \$args\ \ obj_\$tilename\]\\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ colorfo\ blue\n\ \ \ \ \ \ \ \ if\ \{\ \$indx\ >\ 1\ \}\ \{set\ colorfo\ red\}\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -font\ \$font2\ -fill\ \$colorfo\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\ -tags\ \[concat\ mv\ \ \$args\ \ obj_\$tilename\]\ \ \]\n\n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\ \ \n\ \ \ \ \ populateCanvas\ .cv\ 6\ 6\ \ \n\ \ console\ show\ \n\ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #statements\ for\ random\ names\ of\ objects\n\ \ \ \ \ \ \ \ #set\ numberx\ \[.c\ \ gettags\ current\]\;\n\ \ \ \ \ \ \ \ #\ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \ \ \ #.c\ delete\ \"obj_\$tilex+1\"\ \;\n\ \ \ \ \ \ #set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ #.c\ delete\ obj_\$tilex\ \;\n\n\n\n\n\ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\n\n\n\n\n\n\ \n======\ \ \n\n\n\n\n\n\n\n======\n\ \ \ \n----\n'''\[arjen\]\ -\ 2010-06-29\ 03:31:13'''\n\nJust\ a\ minor\ comment:\ the\ characters\ are\ simplified\ Chinese,\ I\ am\ not\ sure\ that\ is\ what\ you\ would\ encounter\ on\ a\ real\ chessboard.\n\n----\ \n\[gold\]#\ not\ sure\ script/Etcl\ addressed\ ch.\ characters\ correctly.\n\ \ May\ just\ use\ English\ letters\ initially\ and\ switch\ for\ \n\ option\ of\ simplified\ or\ traditional\ characters.\n\n----\n\[AMG\]:\ A\ note\ concerning\ the\ \[\[\[list\]\]\]\ command:\ It's\ not\ necessary\ to\ use\ \[\[list\]\]\ if\ none\ of\ the\ elements\ are\ the\ product\ of\ substitution.\ \ In\ other\ words,\ if\ the\ list\ will\ always\ have\ the\ same\ elements,\ you\ don't\ need\ the\ \[\[list\]\]\ command\ to\ construct\ the\ list.\ \ Instead\ simply\ surround\ the\ list\ with\ \{braces\}.\ \ Its\ internal\ representation\ will\ become\ list\ when\ it\ gets\ used\ as\ a\ list,\ since\ Tcl\ has\ \[duck\ typing\].\ \ Similar\ goes\ for\ \[\[\[dict\ create\]\]\].\ \ I\ mean,\ when\ you\ want\ a\ number,\ you\ just\ type\ the\ number,\ even\ though\ its\ initial\ internal\ representation\ will\ be\ string.\ \ It\ \"becomes\"\ a\ number\ when\ context\ shows\ that\ it\ is\ a\ number.\ \ You\ never\ see\ code\ that\ does\ this:\ `set\ var\ \[\[expr\ 5\]\]`\;\ only\ this:\ `set\ var\ 5`.\n\n\n\n\n\n\n\n\n\n***test\ on\ chess\ and\ xiangqi\ fonts***\n\n\n\n\ babelfish\ gives炮\n***国王一般普通话大象马运输车大炮战士典当***\n\ from\ \nking\ general\ mandarin\ elephant\nhorse\ chariot\ cannon\ soldier\ pawn,\n\ \ \ #\ probably\ need\ an\ if\ switch\ option\ for\ TCL\ lists\ \ \n\ \ \ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \[list\ \ 將士\ \ 士將\ \ 象\ 象\ 馬\ 馬\ 車\ 車\ \ \ 砲,\ \ 砲,\ \ \ 卒\ 卒卒\ \ \ 卒卒\ \ \ \]#trad.\ \ \ \ \n\ \ \ \ \n\ \ \ \ \ ***set\ redpieces\ \ \[list\ \ 帥\ \ \ 仕,\ 象\ 象\ \ 相\ \ \ 相\ 馬\ 馬\ 車\ 車\ 砲\ 砲\ \ \ 兵炮\ \ 炮\ \ 兵\ \ \ \ \ 兵\ \ \ \ \ 兵\ \ \ 兵\ \ \ \]\ #trad\n\ \ \ \ \n\n\ \ \ 將\ King\ \ \ 士\ 士Adviser\ 車\ 車chaRiot\ \ \  \ \ 馬\ 馬Horse\ \ \ 炮\ \ 炮Cannon \ \ \ \ \ 象象\ Elephant卒 卒\ 卒\ 卒\ 卒Pawn\n \ \ \ \ \ 帥\ \ \ King\ \ \ \ \ \ \ \  仕\  仕\ Adviser\ 車\ \ \ 車\ \ chaRiot\ \ \  馬\  馬\ \ \ Horse\ 炮\ 炮\ \ Cannon 仕\  仕\ \ \ \ \ \ Elephant 兵\ \ 兵兵兵兵\ Pawn\n\ \n\ \ \ \ \ ***set\ bluepieces\ \ \[list\ 王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\]***#simplified\n\ \ \ \ \ ***set\ redpieces\ \ \[list\ 王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\]***simplified\n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\n\n***♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'***\n\n\n\n\n\n\ \n\n\n<<categories>>\ Toys\ |\ Example\ |\ Games\ |\ Characters regexp2} CALL {my render {Chinese Xiangqi Chessboard} **Chinese\ Xianqi\ Chessboard**\n\n----\ \ \ \nThis\ page\ is\ under\ development.\ Comments\ are\ welcome,\ but\ please\ load\ any\ comments\ in\ the\ comments\ section\ at\ the\ middle\ of\ the\ page.\ Thanks,\[gold\]\n\n----\n\[gold\]\ Here\ is\ some\ starter\ code\ for\ Chinese\ Xiangqi\ Chessboard.\ \n\ There\ are\ several\ avenues\ for\ a\ Xianqi\ chessboard.\ Literature\n\ search\ showed\ many\ chess\ programs\ relying\ on\ a\ gif\ of\ the\ chinese\n\ chessboard.\n\ Primarily\ looking\ at\ \[RS\]'s\ checkers.tcl\ on\ the\ wiki\ to\ get\n\ some\ primary\ movable\ pieces\ with\ the\ board.\ \ I\ installed\n\ a\ version\ of\ the\ code\ in\ the\ Simple\ Canvas\ Demo\ for\ some\ pictures.\n\ \ Also\ I\ made\ a\ lengthy\ list\ of\ 60\ line\ creations\ in\ TCLpaint,but\n\ \ we\ better\ rely\ on\ foreach\ or\ loop\ statements\ for\ compact\ code.\ \n\ \ \ http://wiki.tcl.tk/884\n\ \ \ http://wiki.tcl.tk/15073\n\n----\ \n\ \ \ The\ characters\ are\ generally\ stamped\ red\ and\ blue\ on\ round\ wooden\ pieces,\nwhich\ might\ be\ unicode\ characters\ in\ chinese.\n\ \ \ #\ probably\ need\ an\ if\ switch\ option\ for\ TCL\ lists\ \ \n\ \ \ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \{將士\ \ 士將\ \ 象\ 象\ 馬\ 馬\ 車\ 車\ \ \ 砲\ \ \ 砲\ \ \ \ 卒\ 卒卒\ \ \ 卒卒\ \ \ \]#trad.\ \ \ \ \n\ \ \ \ \n\ \ \ \ \ ***set\ redpieces\ \ \{\ \ 帥\ \ \ 仕\ \ 象\ 象\ \ 相\ \ \ 相\ 馬\ 馬\ 車\ 車\ 砲\ 砲\ \ \ 兵炮\ \ 炮\ \ 兵\ \ \ \ \ 兵\ \ \ \ \ 兵\ \ \ 兵\ \ \ \]\ #trad\n\ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \{王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\}***#simplified\n\ \ \ \ \ ***set\ redpieces\ \ \{王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\}***simplified\n\ \ \ \ \ set\ bluepieces\ \{K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\ \ \ \ \ set\ redpieces\ \ \{K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ \n\n\n\n----\n\n\ \n----\n**Screenshots\ Section**\n\n\[http://farm5.static.flickr.com/4136/4743183050_a37afc987d.jpg\]\ \n\n\[http://farm5.static.flickr.com/4096/4743212494_7b08112447.jpg\]\n\n----\n**Comments\ Section**\nPlease\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Changes.\n\n\[AMG\]:\ I\ suggest\ using\ a\ \[for\]\ loop\ to\ make\ \[\[chessboard\]\]\ more\ concise.\n\n\[gold\]\ Is\ there\ some\ way\ to\ multiply\ all\ numbers\ in\ a\ create\ statement,\ leaving\ the\nalpha\ characters\ unchanged?\ I\ tried\ but\ kept\ bombing,\ and\ wound\ up\ with\ this\ code.\n\n======\n\ set\ bee1\ \[\ list\ .c\ create\ poly\ \ -8\ 10\ \ -8\ 7\ \ -5\ 7\ \ -2\ -1\ \ -4\ -5\ \ -2\ -10\ \ 2\ -10\ \ 4\ -5\ \ 2\ -1\ \ 5\ 7\ \ 8\ 7\ \ 8\ 10\ \]\n\ \ \ \ \ \ set\ bee2\ \[\ list\ \ \ \ -8\ 10\ \ -8\ 7\ \ -5\ 7\ \ -2\ -1\ \ -4\ -5\ \ -2\ -10\ \ 2\ -10\ \ 4\ -5\ \ 2\ -1\ \ 5\ 7\ \ 8\ 7\ \ 8\ 10\ \]\n\ \ \ \ set\ check\ \"1\"\n\ \ \ \ \ foreach\ factor\ \[list\ \ 10\ 12\ 14\ 16\ 18\ 20\]\ \{\n\ \ \ \ \ set\ cat\ \[list\ \ \]\n\ \ \ \ \ foreach\ item\ \$bee1\ \{\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ >>\ 0\}\ \{lappend\ cat\ \ \$item\ \}\n\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ ==\ 0\ \}\ \{lappend\ cat\ \[\ expr\ 200*\$factor*.1\ +\ \$item\ *\ log(\$factor)\ \ \]\}\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \n\ \ \ \ \ \ eval\ \$cat\ -outline\ gray\ \ -fill\ \[lpick\ \$randomcolor\ \]\ \n\ \ \ \ \ \ \ \}\n======\n\n\[AMG\]:\ Yes,\ but\ it's\ very\ complex.\ \ You'd\ have\ to\ use\ \[\[\[regexp\]\ -indices\ -all\ \{\\d+\}\ \$string\]\]\ to\ find\ the\ start\ and\ end\ indices\ corresponding\ to\ the\ numbers,\ then\ you'd\ extract\ each\ number,\ multiply\ it,\ and\ replace\ it\ back\ into\ the\ string\ using\ \[\[\[string\ replace\]\]\].\ \ I\ don't\ recommend\ this\ approach,\ especially\ since\ it's\ liable\ to\ modify\ numbers\ you\ didn't\ intend\ to\ modify.\ \ Also,\ that\ regular\ expression\ I\ gave\ only\ works\ for\ integers\;\ detecting\ floating\ point\ numbers\ is\ even\ harder.\n\nWhat\ you\ need\ to\ do\ is\ have\ each\ creation\ parameter\ be\ a\ function\ of\ your\ \[for\]\ loop\ iterators.\ \ You\ say\ you\ have\ a\ \[Fortran\]\ background\;\ this\ concept\ should\ be\ familiar\ to\ you,\ except\ that\ Fortran\ says\ \"DO\"\ instead\ of\ \"for\".\ :^)\ \ More\ seriously,\ Tcl\ for\ loops\ are\ weird\ (in\ the\ same\ way\ that\ \[C\]\ for\ loops\ are\ weird).\ \ They\ take\ four\ arguments:\n\n\ \ \ 1.\ Initialization\ script.\ \ This\ is\ executed\ before\ the\ loop\ begins.\ \ It's\ normally\ used\ to\ create\ the\ iteration\ variable.\n\ \ \ 1.\ Termination\ test.\ \ This\ expression\ is\ tested\ before\ each\ iteration,\ and\ if\ it's\ false,\ the\ loop\ stops.\n\ \ \ 1.\ Advancement\ script.\ \ This\ is\ executed\ after\ each\ iteration\ of\ the\ loop.\ \ It's\ normally\ used\ to\ increment\ the\ iteration\ variable.\n\ \ \ 1.\ Iteration\ body\ script.\ \ This\ is\ executed\ each\ time\ the\ loop\ iterates,\ just\ before\ the\ advancement\ script.\ \ Your\ main\ code\ goes\ here.\n\nHere's\ code\ to\ make\ a\ grid\ similar\ to\ the\ one\ your\ program\ creates.\ \ It\ shows\ both\ for\ and\ \[foreach\].\ \ To\ be\ honest,\ foreach\ is\ simpler\ than\ for\ when\ there\ are\ a\ very\ small\ number\ of\ iterations.\ \ Here,\ replace\ the\ first\ for\ with\ \"`foreach\ i\ \{1\ 2\ 3\ 4\ 5\ 6\ 7\}\ \{...\}`\"\ and\ the\ second\ for\ with\ \"`foreach\ i\ \{0\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ 9\}\ \{...\}`\".\n\n======\nset\ dx\ 20\ \ \ \ \;#\ pixels\ between\ adjacent\ vertical\ grid\ lines\nset\ dy\ 20\ \ \ \ \;#\ pixels\ between\ adjacent\ horizontal\ grid\ lines\nset\ x0\ 30\ \ \ \ \;#\ pixels\ between\ left\ of\ canvas\ and\ left\ of\ grid\nset\ y0\ 30\ \ \ \ \;#\ pixels\ between\ top\ of\ canvas\ and\ top\ of\ grid\nset\ win\ .c\ \ \ \;#\ name\ of\ canvas\ widget\nforeach\ i\ \{0\ 8\}\ \{\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \$y0\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{9\ *\ \$dy\ +\ \$y0\}\]\n\}\nfor\ \{set\ i\ 1\}\ \{\$i\ <\ 8\}\ \{incr\ i\}\ \{\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \$y0\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{4\ *\ \$dy\ +\ \$y0\}\]\n\ \ \ \ \$win\ create\ line\ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{5\ *\ \$dy\ +\ \$y0\}\]\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{\$i\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{9\ *\ \$dy\ +\ \$y0\}\]\n\}\nfor\ \{set\ i\ 0\}\ \{\$i\ <\ 10\}\ \{incr\ i\}\ \{\n\ \ \ \ \$win\ create\ line\ \$x0\ \[expr\ \{\$i\ *\ \$dy\ +\ \$y0\}\]\\\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \[expr\ \{8\ *\ \$dx\ +\ \$x0\}\]\ \[expr\ \{\$i\ *\ \$dy\ +\ \$y0\}\]\n\}\n======\n\nThere's\ more\ work\ to\ be\ done,\ though.\ \ Hopefully\ this\ will\ get\ you\ started.\n\n----\n**References***\n\n\ \ \ *\ \[Simple\ Canvas\ Demo\]\n\ \ \ *\ http://www.goddesschess.com/chessays/gaddbabylon.html\n\ \ \ *\ http://skookumpete.com/chess_intro.htm\n\n\n\nhttp://mayoneez.1g.fi/hiddenlynx/index.html\nhttp://www.chessvariants.org/graphics.dir/big5/index.html\n\nhttp://geert.vanderkelen.org/2009/12/chessboard-in-mysql.html\n\n\n\ \ http://pinyin.info/tools/converter/chars2uninumbers.html\n\n\nhttp://en.wikipedia.org/wiki/Miscellaneous_Symbols_Unicode_block\n\n\n\n\n\n\n\nhttp://wiki.tcl.tk/884\nhttp://wiki.tcl.tk/9493\nhttp://wiki.tcl.tk/14255\nhttp://99.237.250.152/xq/book/xiangqi_printset.pdfunicode\n\n\n\nhttp://play.chessvariants.org/pbm/presets/chinese_chess.html\nhttp://www.yutopian.com/chinesechess/chrules.pdf\n\n**appendix\ TCL\ programs**\n\n***FIRST\ VERSION***\ \n\n======\n\ #start\ of\ deck#start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ \n\ \n\n\ set\ oscwidth\ 1000\ \n\ set\ oschorizontal\ 500\ \n\ proc\ loop\ \{from\ to\ body\}\ \{\n\ \ \ \ upvar\ 1\ i\ i\ \;#\ make\ index\ visible\ in\ body\n\ \ \ \ for\ \{set\ i\ \$from\}\ \{\$i<\$to\}\ \{incr\ i\}\ \{uplevel\ 1\ \$body\}\n\ \}\n\ \ \ #--\ And\ likewise,\ a\ shortcut\ for\ addition:\n\ proc\ +\ \{a\ b\}\ \{expr\ \{\$a+\$b\}\}\n\ \n\ pack\ \[canvas\ .cv\ -width\ 400\ -height\ 500\ \]\n\n\ focus\ .cv\ \n\ set\ state2\ 1\n\ proc\ refreshgrid\ \{\ .cv\ state2\}\ \{\n\ global\ oscwidth\ oschorizontal\ colorite\n\ global\ grid\n\ set\ colorite\ blue\ \n\ for\ \{set\ x\ 10\}\ \{\$x<\$oscwidth\}\ \{incr\ x\ 50\}\ \{.cv\ create\ line\ \$x\ 0\ \$x\ \$oschorizontal\ \ -fill\ blue\ -tag\ grid\ -\n\nwidth\ 4\}\n\ for\ \{set\ y\ 20\}\ \{\$y<\$oschorizontal\}\ \{incr\ y\ 50\}\ \{.cv\ create\ line\ 0\ \$y\ \$oschorizontal\ \$y\ -fill\ blue\ \ -tag\ grid\ \n\n-width\ 4\}\ \n\ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\n\ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\ \}\n\n\n\n\ \ refreshgrid\ \ .cv\ \$state2\ \n\ #\ next\ lines\ start\ withn\ periods,\ but\ hard\ to\ see\n\ .\ configure\ -borderwidth\ 0\ -highlightthickness\ 0\ -takefocus\ 0\ -background\ aquamarine4\n\ .\ configure\ -background\ palegreen\ -highlightcolor\ DarkOliveGreen\ -relief\ raised\ -border\ 30\n\n\ .\ configure\ -width\ 1000\ -height\ 2000\n\n\n\n\ \ \ \ \ .cv\ bind\ all\ <1>\ \{set\ p(X)\ \[.cv\ canvasx\ %x\]\;\ set\ p(Y)\ \[.cv\ canvasy\ %y\]\}\n\ .cv\ bind\ mv\ <B1-Motion>\ \{mv\ .cv\ %x\ %y\}\n\n\ \ \ \ \ \ proc\ mv\ \{w\ x\ y\}\ \{\n\ \ \ \ global\ p\n\ \ \ \ set\ x\ \ \[\$w\ canvasx\ \$x\]\n\ \ \ \ set\ y\ \ \[\$w\ canvasy\ \$y\]\n\ \ \ \ set\ id\ \[\$w\ find\ withtag\ current\]\n\ \ \ \ set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \n\ \ \ \ puts\ \"1\"\n\ \ \ \ puts\ \$numberx\n\ \ \ \ puts\ \$tilex\n\ \ \ \ puts\ \"\ with\ tag\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\"\n\ \ \ \ foreach\ item\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\ \{\n\ \ \ \ \$w\ move\ \$item\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ \}\n\ \ \ \ puts\ \"\ x\ y\ \$x\ \$y\"\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ #\ \$w\ move\ \[\$w\ find\ withtag\ \"\$tilex\"\]\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ #regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ set\ p(X)\ \$x\;\ set\ p(Y)\ \$y\n\ \}\n\n\ \n\ \n\n\n\ \ \ \n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ #black\ western\n\ \ \ \ \ set\ bluepieces\ \{\ \ \\u265A\ \\u265B\ \\u265C\ \\u265C\ \\u265D\ \\u265D\ \\u265E\ \\u265E\ \\u265F\ \\u265F\ \\u265F\ \\u265F\ \n\n\\u265F\ \\u265F\ \\u265F\ \\u265F\}\ \ \n\ \ \ \ \ #white\ western\n\ \ \ \ \ set\ redpieces\ \{\ \ \\u2654\ \\u2655\ \\u2655\ \\u2656\ \ \\u2656\ \\u2657\ \\u2657\ \ \\u2658\ \\u2658\ \\u2659\ \\u2659\ \\u2659\ \ \n\n\\u2659\ \\u2659\ \\u2659\ \\u2659\ \\u2659\}\ \ \n\ \ \ \ \ \ \ set\ bluepieces\ \{\\u5C07\ \\u58EB\ \ \\u58EB\ \ \\u8C61\ \\u8C61\ \\u99AC\ \\u99AC\ \\u8ECA\ \\u8ECA\ \ \ \\u7832\ \ \ \\u7832\ \ \ \ \n\n\\u5352\ \\u5352\ \\u5352\ \ \ \\u5352\ \\u5352\}\n\ set\ redpieces\ \ \{\ \ \\u5E25\ \ \ \\u4ED5\ \\u4ED5\ \ \ \\u76F8\ \ \ \\u76F8\ \\u99AC\ \\u99AC\ \\u8ECA\ \\u8ECA\ \\u7832\ \\u7832\ \ \ \ \ \n\n\\u70AE\ \ \\u70AE\ \ \\u5175\ \ \\u5175\ \ \ \ \\u5175\ \ \ \ \ \\u5175\ \ \ \\u5175\ \\u5E25\}\ \ \n\ \ \ \ \ \n\ \ \ \ \ set\ ind\ 0\n\ \ \ \ \ set\ indx\ 0\n\ \ \ \ \ set\ baseline\ \{list\ 1\}\n\ \ \ \ \ \ proc\ K\ \{\ x\ y\ \}\ \{\ set\ x\ \}\n\n\ \ \ \ \ proc\ xpop\ \{\ topper\ \}\ \{\n\ \ \ \ \ global\ liner\n\ \ \ \ \ global\ ind\ indx\n\ \ \ \ \ global\ bluepieces\ redpieces\n\ \ \ \ \ global\ baseline\n\ \ \ \ \ set\ topper\ \[\ lindex\ \$bluepieces\ \$ind\ \]\;\n\ \ \ \ \ if\ \{\ \$topper\ ==\ \"\"\ \}\ \{\ \n\ \ \ \ \ set\ topper\ \[\ lindex\ \$redpieces\ \$indx\ \]\n\ \ \ \ \ set\ indx\ \[\ expr\ \{\ \$indx\ +\ 1\}\]\n\ \ \ \ \ \ \ \}\ \n\ \ \ \ \ set\ ind\ \[\ expr\ \{\ \$ind\ +\ 1\}\]\n\ \ \ \ \ lappend\ \$baseline\ \$topper\;\n\ \ \ \ \ return\ \$topper\;\n\ \ \ \ \ \}\n\ \ \ \ \ \ proc\ populateCanvas\ \{w\ cols\ rows\ args\}\ \{\n\ \ \ \ global\ ind\ indx\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ set\ canvas\ \$w\n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 50\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{\ orange\ yellow\ green\ \ gray\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ #set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ #\ set\ text\ \[xpop\ topper\]\n\ \ \ \ \ \ \ \ \ set\ font2\ \[list\ Helvetica\ \[expr\ \$boxwidth/2\]\]\n\n\ \ \ \ \ \ \ \ \ #set\ text\ \"0\"\n\ \ \ \ \ \ \ \ \ #set\ text\ \"K\"\n\ \ \ \ \ \ \ \ \ set\ text\ \[xpop\ 1\ \]\n\ \ \ \ \ \ \ \ \ set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ oval\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ -tags\ \[concat\ mv\ rect\ \$args\ \ obj_\$tilename\]\\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ colorfo\ blue\n\ \ \ \ \ \ \ \ if\ \{\ \$indx\ >\ 1\ \}\ \{set\ colorfo\ red\}\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -font\ \$font2\ -fill\ \$colorfo\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\ -tags\ \[concat\ mv\ \ \$args\ \ obj_\$tilename\]\ \ \]\n\n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\ \ \n\ \ \ \ \ populateCanvas\ .cv\ 6\ 7\ \ \n\ \ console\ show\ \n\ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #statements\ for\ random\ names\ of\ objects\n\ \ \ \ \ \ \ \ #set\ numberx\ \[.c\ \ gettags\ current\]\;\n\ \ \ \ \ \ \ \ #\ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \ \ \ #.c\ delete\ \"obj_\$tilex+1\"\ \;\n\ \ \ \ \ \ #set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ #.c\ delete\ obj_\$tilex\ \;\n\n\n\n\ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n======\n\n****SECOND\ VERSION\ WITH\ ADDED\ HACKS\ ***\ \n\n\n======\ \n\n\ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\n\n\n\n\ \ set\ oscwidth\ 1000\ \n\ \ set\ oschorizontal\ 500\ \n\ \ proc\ loop\ \{from\ to\ body\}\ \{\n\ \ \ \ upvar\ 1\ i\ i\ \;#\ make\ index\ visible\ in\ body\n\ \ \ \ for\ \{set\ i\ \$from\}\ \{\$i<\$to\}\ \{incr\ i\}\ \{uplevel\ 1\ \$body\}\n\ \}\n\ #--\ And\ likewise,\ a\ shortcut\ for\ addition:\n\ \ proc\ +\ \{a\ b\}\ \{expr\ \{\$a+\$b\}\}\n\ \n\ \ pack\ \[canvas\ .cv\ -width\ 400\ -height\ 500\ \]\n\n\ focus\ .cv\ \n\ set\ state2\ 1\n\ proc\ refreshgrid\ \{\ .cv\ state2\}\ \{\n\ global\ oscwidth\ oschorizontal\ colorite\n\ global\ grid\n\ set\ colorite\ blue\ \n\ \ for\ \{set\ x\ 10\}\ \{\$x<\$oscwidth\}\ \{incr\ x\ 50\}\ \{.cv\ create\ line\ \$x\ 0\ \$x\ \$oschorizontal\ \ -fill\ blue\ -tag\ grid\ -\n\nwidth\ 4\}\n\ for\ \{set\ y\ 20\}\ \{\$y<\$oschorizontal\}\ \{incr\ y\ 50\}\ \{.cv\ create\ line\ 0\ \$y\ \$oschorizontal\ \$y\ -fill\ blue\ \ -tag\ grid\ \n\n-width\ 4\}\ \n\ .cv\ itemconfigure\ grid\ -fill\ blue\ \n\ \n\ if\ \{\ \$state2\ ==\ 1\ \}\ \{\ .cv\ raise\ grid\ \;\}\ \n\ if\ \{\ \$state2\ ==\ 2\ \}\ \{\ .cv\ lower\ grid\ \;\}\ \n\ \}\n\n\n\n\ \ refreshgrid\ \ .cv\ \$state2\ \n\ \ #\ next\ lines\ start\ withn\ periods,\ but\ hard\ to\ see\n\ \ .\ configure\ -borderwidth\ 0\ -highlightthickness\ 0\ -takefocus\ 0\ -background\ aquamarine4\n\ \ .\ configure\ -background\ palegreen\ -highlightcolor\ DarkOliveGreen\ -relief\ raised\ -border\ 30\n\n\ \ .\ configure\ -width\ 1000\ -height\ 2000\n\n\n\n\ \ .cv\ bind\ all\ <1>\ \{set\ p(X)\ \[.cv\ canvasx\ %x\]\;\ set\ p(Y)\ \[.cv\ canvasy\ %y\]\}\n\ \ .cv\ bind\ mv\ <B1-Motion>\ \{mv\ .cv\ %x\ %y\}\n\n\ \ \ proc\ mv\ \{w\ x\ y\}\ \{\n\ \ \ \ global\ p\n\ \ \ \ set\ x\ \ \[\$w\ canvasx\ \$x\]\n\ \ \ \ set\ y\ \ \[\$w\ canvasy\ \$y\]\n\ \ \ \ set\ id\ \[\$w\ find\ withtag\ current\]\n\ \ \ \ set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \n\ \ \ \ puts\ \"1\"\n\ \ \ \ puts\ \$numberx\n\ \ \ \ puts\ \$tilex\n\ \ \ \ puts\ \"\ with\ tag\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\"\n\ \ \ \ foreach\ item\ \[\$w\ find\ withtag\ obj_\$tilex\ \]\ \{\n\ \ \ \ \$w\ move\ \$item\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ \}\n\ \ \ \ puts\ \"\ x\ y\ \$x\ \$y\"\n\ \ \ \ #\$w\ raise\ \$id\n\ \ \ \ #\ \$w\ move\ \[\$w\ find\ withtag\ \"\$tilex\"\]\ \[expr\ \{\$x-\$p(X)\}\]\ \[expr\ \{\$y-\$p(Y)\}\]\n\ \ \ \ #set\ numberx\ \[\$w\ \ gettags\ current\]\n\ \ \ \ #regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ set\ p(X)\ \$x\;\ set\ p(Y)\ \$y\n\ \ \}\n\n\ \n\ \n\n\n\ \ \ \n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]\n\ \ \ \ \ #black\n\ \ \ \ \ set\ bluepieces\ \{\ \ \\u265A\ \\u265B\ \\u265C\ \\u265C\ \\u265D\ \\u265D\ \\u265E\ \\u265E\ \\u265F\ \\u265F\ \\u265F\ \\u265F\ \n\n\\u265F\ \\u265F\ \\u265F\ \\u265F\}\ \ \n\ \ \ \ \ #white\n\ \ \ \ \ set\ redpieces\ \{\ \ \\u2654\ \\u2655\ \\u2656\ \ \\u2656\ \\u2657\ \\u2657\ \ \\u2658\ \\u2658\ \\u2659\ \\u2659\ \\u2659\ \ \\u2659\ \n\n\\u2659\ \\u2659\ \\u2659\ \\u2659\}\ \ \n\ \ \ \ \ \ \n\ \n\ \ \ \ \ \n\ \ \ \ \ set\ ind\ 0\n\ \ \ \ \ set\ indx\ 0\n\ \ \ \ \ set\ baseline\ \{list\ 1\}\n\ \ \ \ \ \ proc\ K\ \{\ x\ y\ \}\ \{\ set\ x\ \}\n\n\ \ \ \ \ proc\ xpop\ \{\ topper\ \}\ \{\n\ \ \ \ \ global\ liner\n\ \ \ \ \ global\ ind\ indx\n\ \ \ \ \ global\ bluepieces\ redpieces\n\ \ \ \ \ global\ baseline\n\ \ \ \ \ set\ topper\ \[\ lindex\ \$bluepieces\ \$ind\ \]\;\n\ \ \ \ \ if\ \{\ \$topper\ ==\ \"\"\ \}\ \{\ \n\ \ \ \ \ set\ topper\ \[\ lindex\ \$redpieces\ \$indx\ \]\n\ \ \ \ \ set\ indx\ \[\ expr\ \{\ \$indx\ +\ 1\}\]\n\ \ \ \ \ \ \ \}\ \n\ \ \ \ \ set\ ind\ \[\ expr\ \{\ \$ind\ +\ 1\}\]\n\ \ \ \ \ lappend\ \$baseline\ \$topper\;\n\ \ \ \ \ return\ \$topper\;\n\ \ \ \ \ \}\n\ \ \ \ \ proc\ populateCanvas\ \{w\ cols\ rows\ args\}\ \{\n\ \ \ \ global\ ind\ indx\n\ \ \ \ variable\ ids\ \;#\ links\ text\ ids\ with\ respective\ rect\ ids\n\ \ \ \ variable\ boxes\ \;#\ lists\ text\ id\ and\ text\ associated\ with\ each\ rect\ id\n\ \ \ \ catch\ \{unset\ ids\ boxes\}\n\ \ \ \ set\ canvas\ \$w\n\ \ \ \ #\ parameters\ for\ drawing\ boxes\n\ \ \ \ set\ boxwidth\ 50\n\ \ \ \ set\ boxheight\ 50\n\ \ \ \ set\ padx\ 3\n\ \ \ \ set\ pady\ 3\n\ \ \ \ set\ colors\ \{\ orange\ yellow\ green\ \ gray\}\n\ \ \ \ set\ labels\ \{one\ two\ three\ four\}\n\n\ \ \ \ #\ draw\ the\ boxes\n\ \ \ \ for\ \{set\ row\ 0\}\ \{\$row\ <\ \$rows\}\ \{incr\ row\}\ \{\n\ \ \ \ \ \ for\ \{set\ col\ 0\}\ \{\$col\ <\ \$cols\}\ \{incr\ col\}\ \{\n\n\ \ \ \ \ \ \ \ #\ calculate\ coordinates\n\ \ \ \ \ \ \ \ set\ x1\ \[expr\ \{\$col\ *\ (\$boxwidth\ +\ \$padx)\ +\ \$padx\}\]\n\ \ \ \ \ \ \ \ set\ x2\ \[expr\ \{\$x1\ +\ \$boxwidth\}\]\n\ \ \ \ \ \ \ \ set\ x3\ \[expr\ \{\$x1\ +\ (\$boxwidth\ /\ 2)\}\]\n\ \ \ \ \ \ \ \ set\ y1\ \[expr\ \{\$row\ *\ (\$boxheight\ +\ \$pady)\ +\ \$pady\}\]\n\ \ \ \ \ \ \ \ set\ y2\ \[expr\ \{\$y1\ +\ \$boxheight\}\]\n\ \ \ \ \ \ \ \ set\ y3\ \[expr\ \{\$y1\ +\ (\$boxheight\ /\ 2)\}\]\n\n\ \ \ \ \ \ \ \ #\ choose\ color\ and\ text\n\ \ \ \ \ \ \ \ set\ color\ \[lindex\ \$colors\ \[expr\ \{int(rand()\ *\ \[llength\ \$colors\])\}\]\]\n\ \ \ \ \ \ \ \ #set\ text\ \[lindex\ \$labels\ \[expr\ \{int(rand()\ *\ \[llength\ \$labels\])\}\]\]\n\ \ \ \ \ \ \ \ #\ set\ text\ \[xpop\ topper\]\n\ \ \ \ \ \ \ \ \ set\ font2\ \[list\ Helvetica\ \[expr\ \$boxwidth/2\]\]\n\n\ \ \ \ \ \ \ \ \ #set\ text\ \"0\"\n\ \ \ \ \ \ \ \ \ #set\ text\ \"K\"\n\ \ \ \ \ \ \ \ \ set\ text\ \[xpop\ 1\ \]\n\ \ \ \ \ \ \ \ \ set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ \ \ \ #\ create\ the\ boxes\n\ \ \ \ \ \ \ \ set\ boxid\ \[\$canvas\ create\ oval\ \$x1\ \$y1\ \$x2\ \$y2\ \\\n\ \ \ \ \ \ \ \ \ \ -fill\ \$color\ -tags\ \[concat\ mv\ rect\ \$args\ \ obj_\$tilename\]\\\n\ \ \ \ \ \ \ \ \ \ -outline\ black\]\n\ \ \ \ \ \ \ \ set\ colorfo\ blue\n\ \ \ \ \ \ \ \ if\ \{\ \$indx\ >\ 1\ \}\ \{set\ colorfo\ red\}\n\ \ \ \ \ \ \ \ set\ textid\ \[\$canvas\ create\ text\ \$x3\ \$y3\ -font\ \$font2\ -fill\ \$colorfo\ \\\n\ \ \ \ \ \ \ \ \ \ -text\ \$text\ -tags\ \[concat\ mv\ \ \$args\ \ obj_\$tilename\]\ \ \]\n\n\ \ \ \ \ \ \ \ #\ remember\ which\ text\ item\ goes\ with\ which\ box\ and\ what\ the\ text\ says\n\ \ \ \ \ \ \ \ set\ boxes(\$boxid)\ \[list\ \$textid\ \$text\]\n\ \ \ \ \ \ \ \ set\ ids(\$textid)\ \$boxid\n\ \ \ \ \ \ \ \ set\ ids(\$boxid)\ \$boxid\n\ \ \ \ \ \ \}\n\ \ \ \ \}\n\ \ \}\ \ \n\ \ \ \ \ populateCanvas\ .cv\ 6\ 6\ \ \n\ \ console\ show\ \n\ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #statements\ for\ random\ names\ of\ objects\n\ \ \ \ \ \ \ \ #set\ numberx\ \[.c\ \ gettags\ current\]\;\n\ \ \ \ \ \ \ \ #\ regexp\ \{obj_(\\d+)\}\ \$numberx\ ->\ tilex\n\ \ \ \ \ \ \ #.c\ delete\ \"obj_\$tilex+1\"\ \;\n\ \ \ \ \ \ #set\ tilename\ \ \[expr\ \{int(rand()*1000000000.)\}\]\n\ \ \ \ \ #.c\ delete\ obj_\$tilex\ \;\n\n\n\n\n\ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \ \ \ \ \ \n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ #end\ of\ deck\n\n\n\n\n\n\n\ \n======\ \ \n\n\n\n\n\n\n\n======\n\ \ \ \n----\n'''\[arjen\]\ -\ 2010-06-29\ 03:31:13'''\n\nJust\ a\ minor\ comment:\ the\ characters\ are\ simplified\ Chinese,\ I\ am\ not\ sure\ that\ is\ what\ you\ would\ encounter\ on\ a\ real\ chessboard.\n\n----\ \n\[gold\]#\ not\ sure\ script/Etcl\ addressed\ ch.\ characters\ correctly.\n\ \ May\ just\ use\ English\ letters\ initially\ and\ switch\ for\ \n\ option\ of\ simplified\ or\ traditional\ characters.\n\n----\n\[AMG\]:\ A\ note\ concerning\ the\ \[\[\[list\]\]\]\ command:\ It's\ not\ necessary\ to\ use\ \[\[list\]\]\ if\ none\ of\ the\ elements\ are\ the\ product\ of\ substitution.\ \ In\ other\ words,\ if\ the\ list\ will\ always\ have\ the\ same\ elements,\ you\ don't\ need\ the\ \[\[list\]\]\ command\ to\ construct\ the\ list.\ \ Instead\ simply\ surround\ the\ list\ with\ \{braces\}.\ \ Its\ internal\ representation\ will\ become\ list\ when\ it\ gets\ used\ as\ a\ list,\ since\ Tcl\ has\ \[duck\ typing\].\ \ Similar\ goes\ for\ \[\[\[dict\ create\]\]\].\ \ I\ mean,\ when\ you\ want\ a\ number,\ you\ just\ type\ the\ number,\ even\ though\ its\ initial\ internal\ representation\ will\ be\ string.\ \ It\ \"becomes\"\ a\ number\ when\ context\ shows\ that\ it\ is\ a\ number.\ \ You\ never\ see\ code\ that\ does\ this:\ `set\ var\ \[\[expr\ 5\]\]`\;\ only\ this:\ `set\ var\ 5`.\n\n\n\n\n\n\n\n\n\n***test\ on\ chess\ and\ xiangqi\ fonts***\n\n\n\n\ babelfish\ gives炮\n***国王一般普通话大象马运输车大炮战士典当***\n\ from\ \nking\ general\ mandarin\ elephant\nhorse\ chariot\ cannon\ soldier\ pawn,\n\ \ \ #\ probably\ need\ an\ if\ switch\ option\ for\ TCL\ lists\ \ \n\ \ \ \ \ \n\ \ \ \ \ ***set\ bluepieces\ \ \[list\ \ 將士\ \ 士將\ \ 象\ 象\ 馬\ 馬\ 車\ 車\ \ \ 砲,\ \ 砲,\ \ \ 卒\ 卒卒\ \ \ 卒卒\ \ \ \]#trad.\ \ \ \ \n\ \ \ \ \n\ \ \ \ \ ***set\ redpieces\ \ \[list\ \ 帥\ \ \ 仕,\ 象\ 象\ \ 相\ \ \ 相\ 馬\ 馬\ 車\ 車\ 砲\ 砲\ \ \ 兵炮\ \ 炮\ \ 兵\ \ \ \ \ 兵\ \ \ \ \ 兵\ \ \ 兵\ \ \ \]\ #trad\n\ \ \ \ \n\n\ \ \ 將\ King\ \ \ 士\ 士Adviser\ 車\ 車chaRiot\ \ \  \ \ 馬\ 馬Horse\ \ \ 炮\ \ 炮Cannon \ \ \ \ \ 象象\ Elephant卒 卒\ 卒\ 卒\ 卒Pawn\n \ \ \ \ \ 帥\ \ \ King\ \ \ \ \ \ \ \  仕\  仕\ Adviser\ 車\ \ \ 車\ \ chaRiot\ \ \  馬\  馬\ \ \ Horse\ 炮\ 炮\ \ Cannon 仕\  仕\ \ \ \ \ \ Elephant 兵\ \ 兵兵兵兵\ Pawn\n\ \n\ \ \ \ \ ***set\ bluepieces\ \ \[list\ 王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\]***#simplified\n\ \ \ \ \ ***set\ redpieces\ \ \[list\ 王\ 王\ 王\ 象\ 象\ 马\ 马\ 车\ 车\ \ 炮\ 炮\ \ 典\ 典\ 典\ 典\ 典\ 典\]***simplified\n\ \ \ \ \ set\ bluepieces\ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\ \ \ \ \ set\ redpieces\ \ \[list\ K\ A\ A\ E\ E\ H\ H\ R\ R\ C\ C\ P\ P\ P\ P\ P\]#english\ letters\n\n\n***♔','♕','♖','♗','♘','♙','♚','♛','♜','♝','♞','♟'***\n\n\n\n\n\n\ \n\n\n<<categories>>\ Toys\ |\ Example\ |\ Games\ |\ Characters} CALL {my revision {Chinese Xiangqi Chessboard}} CALL {::oo::Obj1140013 process revision/Chinese+Xiangqi+Chessboard} CALL {::oo::Obj1140011 process}

-errorcode

NONE

-errorinfo

Unknow state transition: LINE -> END
    while executing
"error $msg"
    (class "::Wiki" method "render_wikit" line 6)
    invoked from within
"my render_$default_markup $N $C $mkup_rendering_engine"
    (class "::Wiki" method "render" line 8)
    invoked from within
"my render $name $C"
    (class "::Wiki" method "revision" line 31)
    invoked from within
"my revision $page"
    (class "::Wiki" method "process" line 56)
    invoked from within
"$server process [string trim $uri /]"

-errorline

4