Error processing request

Parameters

CONTENT_LENGTH0
REQUEST_METHODGET
REQUEST_URI/revision/Game+kingdom+of+strategy?V=111
QUERY_STRINGV=111
CONTENT_TYPE
DOCUMENT_URI/revision/Game+kingdom+of+strategy
DOCUMENT_ROOT/var/www/nikit/nikit/nginx/../docroot
SCGI1
SERVER_PROTOCOLHTTP/1.1
HTTPSon
REMOTE_ADDR172.69.6.47
REMOTE_PORT42278
SERVER_PORT4443
SERVER_NAMEwiki.tcl-lang.org
HTTP_HOSTwiki.tcl-lang.org
HTTP_CONNECTIONKeep-Alive
HTTP_ACCEPT_ENCODINGgzip, br
HTTP_X_FORWARDED_FOR3.147.61.242
HTTP_CF_RAY88557ad4cb80618b-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.147.61.242
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 {Game kingdom of strategy} **Game\ kingdom\ of\ Strategy**\n\n\ \ \ \ \ \ This\ page\ is\ under\ development.\ Comments\ are\ welcome,\n\ \ \ \ \ \ but\ please\ load\ any\ comments\ in\ the\ comments\ section\n\ \ \ \ \ \ at\ the\ middle\ of\ the\ page.\ Thanks,\[gold\]\n\n----\n----\n\ \ \ Here\ is\ some\ starter\ code\ for\n\ \ \ Game\ kingdom\ of\ Strategy.\n\ \ \ There\ is\ a\ post\ on\ wiki\ asking\ \n\ \ \ for\ a\ TCL\ version\ of\n\ \ \ a\ text\ and\ strategy\ game,\n\ \ \ originally\ in\ basic\ language.\n\ \ \ See\ Ideas\ for\ Projects\ in\ Tcl/Tk,\n\ \ \ http://wiki.tcl.tk/14335.\n\ \ \ I\ am\ trying\ to\ find\ out\n\ \ \ the\ status\ of\ the\ old\ game.\n\ \ \ A\ strategy\ game\ can\ be\ cobbled\ from\n\ \ \ older\ scraps\ of\ Iching\ code.\n\ \ \ Using\ the\ Iching\ code,\ this\ page\n\ \ \ presents\ a\ trial\ console\ version\n\ \ \ for\ testing\ the\ concept,\ \n\ \ \ a\ console\ version,\ and\ \ \n\ \ \ a\ canvas\ version\ with\ some\ graphics,\n\ \ \ The\ Iching\ has\ a\ good\ handle\ on\ the\n\ \ \ actions\ of\ an\ ancient\ kingdom,\ though\n\ \ \ in\ a\ random\ scattered\ pattern.\n\ \ \ The\ elements\ in\ most\ adventure\n\ \ \ games\ are\ random\ generators,\n\ \ \ castles,\ tiled\ game\ boards,\ mazes,\ wildcards,\n\ \ \ gamepieces,\ and\ strategy\ situation.\n\ \ \ \n\ \ \ \ \ \ \ \ \n----\n\ \ \ \ \ \ The\ canvas\ and\ buttons\ presented\ here\n\ are\ largely\ based\ on\ the\ \n\ Simple\ Canvas\ Demo\ by\ \[HJG\].\n\ See\ http://wiki.tcl.tk/15073\ \ \ \n\ The\ random\ pick\ algorithm\ was\ posted\ by\ Suchenworth\ \[RS\]\n\ on\ Horseracing\ in\ Tcl,http://wiki.tcl.tk/3467.\n\ \ Another\ source\ of\ randomness\ was\n\ \ \ A\ funny\ cookbook,http://wiki.tcl.tk/9213\n\ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n----\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ In\ pseudocode,\ the\ text\ adventure\ game\n\ \ is\ essentially\ a\ three\ line\ program\n\ \ in\ the\ old\ style\ unix\ wish.\ In\ etcl\ and\n\ \ windows,\ some\ buffering\ may\ be\ necessary.\n\ \ One\ display\ for\ response\ and\ one\ display\ for\n\ \ input\ would\ be\ easier\ in\ windows.\ \n\ \ \ \ \n\ \ \ \ 1)puts\ stdout\ \"Please\ enter\ your\ name:\"\n\ \ \ \ \ \ \ \ 2)gets\ stdin\ \ name\n\ \ \ \ \ \ \ \ \ \ \ \ \ 3)puts\ stdout\ \"Hello\ \$name\"\n\ \ \ \ \ \n\ \ \ \ \ pseudocode.The\ user\ is\ directed\ into\ various\ possibilities.\ \n\ \ \ 2)\ 3)\ and\ 4)\ are\ looped.\n\ \ \ \ \ \ console\ show\ \ \n\ \ \ \ \ 1)puts\ stdout\ \"Please\ enter\ your\ name:\"\n\ \ \ \ \ 2)gets\ stdin\ \ \ \n\ \ \ \ \ pseudocode:\ analyze\ name\ and\ internal-references\n\ \ \ \ \ pseudocode\ :\ set\ random\ situation.\n\ \ \ \ \ pseudocode\ :\ game\ closes\ after\ 5\ trials\ or\ 5\ situations.\n\ \ \ \ \ 3)puts\ stdout\ \"action\ \$name\"\n\ \ \ \ \ 4)\ \ pseudocode.\ \ \ \ \ \ return\ to\ 2)\ stdin\ \n\ \ \ \ \n\ \ \ \ \ \n\ ----\ \n\ ----\n\ \ \ \ \ \n\ \ \ \n\n\ \n----\n\ \ \ \ \ \ \ \n----\n\ \ \ \ \ In\ the\ trial\ deck\ for\ console,\n\ \ \ \ \ the\ advisor\ would\ present\ the\ situation\n\ \ \ \ \ and\ the\ king's\ responses\ would\ have\ to\n\ \ \ \ \ be\ a\ table\ of\ abbreviated\ commands,\n\ \ \ \ \ like\ buy\ 200\ ,\ sell\ 300\ ,\ .\n\ \ \ \ \ Otherwise,\ there\ would\ be\ a\ lot\ difficult\ \n\ \ \ \ \ parsing,\ like\ the\ human\ language\ command\n\ \ \ \ \ of\ computers.\ The\ trial\ deck\ could\n\ \ \ \ \ call\ the\ procedure\ \"advisor\"\ to\ present\ \n\ \ \ \ \ the\ situation\ derived\ from\ random\ circumstances.\n\ \ \ \ \ The\ trial\ deck\ \n\ \ \ \ \ could\ call\ the\ procedure\ \"king\",\ so\n\ \ \ \ \ the\ command\ on\ the\ console\ window\ \n\ \ \ \ \ would\ be\ king\ sell\ 20\ or\n\ \ \ \ \ king\ buy\ 50.\ This\ have\ the\ advantage\ \n\ \ \ \ \ of\ looking\ as\ a\ typical\ English\ sentence:\n\ \ \ \ \ subject\ verb\ object.\ In\ a\ loop,\ the\n\ \ \ \ \ king\ procedure\ calls\ on\ the\ advisor\ procedure,\n\ \ \ \ \ which\ presents\ a\ new\ situation.\n\ \ \ \ \ The\ king\ wins\ or\ loses\ based\ on\ his\ responses\n\ \ \ \ \ to\ the\ random\ situation.\ The\ game\ can\ be\n\ \ \ \ \ closed\ after\ a\ certain\ number\ of\ situation\n\ \ \ \ \ trials\ by\ a\ limiting\ statement\ in\ the\ advisor\n\ \ \ \ \ procedure.\ The\ major\ subroutines\ or\ procedures\n\ \ \ \ \ were\ diagramed\ with\ TKpaint\ in\ the\ flowchart\ below.\n\ \ \ \ \ Those\ interested\ in\ flowcharting\ programs\ should\n\ \ \ \ \ be\ able\ to\ load\ the\ flowchart\ file\ into\ TKpaint\n\ \ \ \ \ or\ else\ load\ the\ file\ into\ eTCL\ with\ a\ few\n\ \ \ \ \ canvas\ display\ statements.\n\n\ \ \ \ \ \n----\n\ \ session\ \ \ from\ trial\ console\ script\n\ \ \ \ buy\ or\ sell,\ my\ lord?\ \n\ \ \ \ starts\ with\ 1000\ units\ \n\ \ \ \ answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \n\ \ \ 1%\ king\ buy\ 20\n\ \ \ \ decision\ was\ buy\ 20,\ total\ was\ 1020.0\ \n\ \n\ \ \ advisor:\ \ new\ situation\ \n\ \ \ need\ 10\ liters\ of\ grain.\n\ \ \ need\ 60\ hectares\ of\ land.\n\ \ \ predict\ rain.\n\ \ \ subjects\ from\ census\ 5000.\ \n\n\ \ \ \ advisor:\ buy\ or\ sell,\ my\ lord?\ \n\ \ \ \ 2%\ king\ sell\ 500\n\ \ \ \ decision\ was\ sell\ 500,\ total\ was\ 520.0\ \n\ \n\ \ \ \ advisor:\ \ new\ situation\ \n\ \ \ need\ 10\ liters\ of\ grain.\n\ \ \ need\ 100\ hectares\ of\ land.\n\ \ \ predict\ cold.\n\ \ \ subjects\ from\ census\ 3000.\ \n\n\ \ \ \ \ advisor:\ buy\ or\ sell,\ my\ lord?\ \n----\n\n----\n**\ canvas\ button\ operation\ \n\ \ \ \ \ So\ the\ order\ of\ button\ actions\ should\ be:\n\ \ \ \ \ push\ castle\n\ \ \ \ \ push\ situation,\ read\ advisors'\ comment\n\ \ \ \ \ type\ in\ king's\ responce\ in\ upper\ entry\ field\n\ \ \ \ \ push\ console\n\ \ \ \ \ push\ record,\ should\ see\ record\ of\ play\ on\ console.\n\ \ \ \ %quit\ day\ job\n\ \ \ \ %\{advisor:buy\ or\ sell,\ my\ lord?\}\ \{king:get\ lost\}\n\ \ \ \ \ \ \ \ \ note:\ pass\ or\ veto\ should\ be\ option\n\ \ \ \ clear\ to\ resume\ play\n\ \ \ \ \ \n\n\ \ \ \ Commands\ from\ the\ king\ on\ the\ eTCL\ console\ \ \n\ \ \ \ or\ commands\ in\ the\ king\ entry\ field\ (canvas)\n\ \ \ \ vary\ on\ versions,\ but\ here\ are\ some\ samples.\n\ \ \ \ \ \ initial\ land\ is\ 1000\ barleyfields\n\ \ \ \ \ \ initial\ barley\ is\ 1000\ measures\n\ \ \ \ \ \ king\ buy\ 22\n\ \ \ \ \ \ king\ sell\ 100\n\ \ \ \ \ \ \ else\ \n\ \ \ \ \ \ king\ buy\ 100\ land\n\ \ \ \ \ \ king\ sell\ 33\ land\n\ \ \ \ \ \ king\ buy\ 222\ barley\n\ \ \ \ \ \ king\ sell\ 33\ barley\n\ \ \ \ conditions\ for\ winner\ are\ very\ liberal.\n\ \ \ \ pseudocode:\ game\ is\ halted\ after\ 5\ trials,\ count\ >\ 5,\n\ \ \ \ and\ estimate\ if\ (winner)\ conditions\ prevail.\n\ \ \ \ pseudocode:\ \ if\ barleyfields\ >\ 500\ ,\ winner\ declared\n\ \ \ \ pseudocode:\ \ if\ barley\ \ >\ 500\ winner\ declared\n\ \ \ \ pseudocode:\ \ clear\ resets\ counter\ to\ zero\n\ \ \ \ pseudocode:\ \ clear\ zeros\ king\ &\ advisor\ entry\ fields,\ \n\ \ \ \ pseudocode:\ \ &\ zeros\ canvas\n\n\ \ \ \ \ \n\ \ \ \ Note.\ On\ 27Jul2010,\ there\ was\ a\ challenge\ posted\ on\n\ \ \ converting\ Hamurabi.bas\ to\ \"modern\"\ computer\ language.\n\ \ \ The\ turn-around\ from\ other\ languages\ (not\ me!)\ is\ fairly\n\ \ \ impressive.\ There\ was\ a\ Lua\ program\ posted\ on\ 28Jul2010,\n\ \ \ Java\ on\ 28Jul2010,\n\ \ \ common\ Lisp\ program\ on\ 31Jul210,\ and\ Factor\ program\ by\ 3Aug2010.\ \ \ \n\ \ \ The\ original\ basic\ code\ was\ fairly\ terse,\ so\n\ \ \ there\ has\ been\ some\ real\ hoofing\ on\ the\ contributions.\n\ \ \ As\ a\ fortran\ programmer,\ I\ remember\ basic\ envy\n\ \ \ on\ the\ basic\ string\ addition,\ let\ it\$\ =\ \"be\"+\"so\"\n----\ \ \ \n\ \ \ Note:\ Quite\ possible\ to\ add\ the\ Eliza\ namespace\ \n\ \ \ to\ the\ game.\ This\ will\ get\ some\ context\ sensitive\n\ \ \ analysis/quirks\ \ into\ the\ game.\ \n\ \ \ Refer\ to\ A\ simple\ version\ of\ Eliza,\n\ \ \ http://wiki.tcl.tk/9235.\n\ \ \ \ \n\ \ \ \ \ \ Console:\ \ king\ sell\ 11\ barley\ \n\ \ \ \ \ 1%\ ::Talk::replyto\ \{\ barley\ \}\n\ \ \ \ \ \ advisor\ says\ :\ Shall\ we\ continue?\ \n\ \ \ \ \ 2%\ ::Talk::replyto\ \{\ king\ sell\ barley\ \}\n\ \ \ \ \ \ \ advisor\ says\ worried\ about\ total\ \ barleyfields.\ ?\ \n\ \ \ \ \ 3%\ ::Talk::replyto\ \{\ king\ sell\ 11\ barley\ \}\n\ \ \ \ \ \ \ advisor\ says\ :\ worried\ about\ total\ barleyfields.\ ?\ \n\ \ \ \ \ 4%\ king\ sell\ 11\ barley\n\ \ \ \ \ decision\ was\ sell\ 11,\ total\ was\ \ \ land\ 1000,\ barley\ 989.0\ \n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \n----\n**Screenshots\ Section**\n\n\[http://farm5.static.flickr.com/4122/4866853039_0a6798b1f8.jpg\]\n\ \n\n\n\[http://farm5.static.flickr.com/4120/4854141292_07b57692b7.jpg\]\n\n\n\[http://farm5.static.flickr.com/4096/4857240469_6d23f1b62c.jpg\]\ \n\n\n\n----\n**Comments\ Section**\n\ \ \ \ \ \ \ \ \ Please\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Changes.\n\n----\n**References**\n\n\ \ \ *\ \[Simple\ Canvas\ Demo\]\n\ \ \n\ \ \ http://wiki.tcl.tk/14617\n\n\ \ \ \ Ideas\ for\ Projects\ in\ Tcl/Tk\n\ \ \ \ http://wiki.tcl.tk/14335\n\n\n\ \ \ \ A\ funny\ cookbook\n\ \ \ \ http://wiki.tcl.tk/7801\n\ \ \ \ Tkpaint\n\ \ \ \ http://mars.netanya.ac.il/~samy/tkpaint.html\n\ \ \ \ \ \n\ \ \ \ http://wiki.tcl.tk/9213\n\ \ \ \ The\ older\ tkpaint\ \ 1.5\ executable\ that\ I\ used\ was\ loaded\ here.\n\ \ \ \ \ ftp://ftp.procplace.com/pub/tcl/sorted/packages-8.0/graphics/tkpaint/1.51/TKPAINT-1.5.3.TAR.GZ\n\ \ \ \ \ ftp://ftp.procplace.com/pub/tcl/sorted/packages-8.0/graphics/tkpaint/1.52/tkpaint.zip\n\n\n\n\n\ \ \ \ http://en.wikipedia.org/wiki/Hamurabi\n\n\ \ \ \ http://www.dunnington.u-net.com/public/basicgames/HMRABI\n\n\ \ \ \ http://www.apollowebworks.com/russell/samples/hamurabi.html\n\n\n\n\ \ \ \ http://www.cse.lehigh.edu/~munoz/ComputerGameDesignClass/classes/GameTheory.pptx.\n\ \ \ \ http://en.wikipedia.org/wiki/Hamurabihttp://en.wikipedia.org/wiki/List_of_games_in_game_theory\n\ \ \ \ http://en.wikipedia.org/wiki/Game_theory\n\ \ \ \ http://www.dallasuu.org/re/adult/huumanist/TitTatSagan.pdf\n\ \ \ \ http://en.wikipedia.org/wiki/Dictator_game\n\n\ \ \ \ http://www.hammurabigame.com/hammurabi-game.php\n\n\ \ \ \ http://www.codeproject.com/KB/game/Hammurabi.aspx\n\n\n\n\ \ \ \ http://www.esajournals.org/doi/abs/10.1890/1540-9295(2003)001%5B0367%3AMRAPTB%5D2.0.CO%3B2\n\ \ \ \ http://ipsnews.net/fao_magazine/indian.shtml\n\ \ \ \ http://biology.clc.uc.edu/courses/bio104/sci_meth.htm\n\ \ \ \ http://programmingpraxis.com/2010/07/27/hamurabi-bas/\n\ \ \ \ http://www.pbs.org/wgbh/nova/nature/plant-vs-predator.html\n\ \ \ \ http://lisp.pastebin.com/r1gL4zYT\n\ \ \ \ http://codepad.org/pc8FSfnQ\n\ \ \ \ http://www.econ.umn.edu/~foster/Handouts%20Games.pdf\n\ \ \ \ http://re-factor.blogspot.com/2010/08/hamurabi.html\n\n\n\ \ \ \ http://www.moorecad.com/classicbasic/basic/creative/hamurabi.bas\n\ \ \ \ http://www.cis.upenn.edu/~matuszek/cit590-2010/Assignments/02-hammurabi.html\n\ \ \ \ \ http://playtechs.blogspot.com/2009/06/charlemagne-disraeli-and-jefferson.html\n\ \ \ \ \ http://www.econ.cam.ac.uk/seminars/Marshall_Lecture/09/marshall_lecture_2_Oct_21.pdf\n\ \ \ \ \ http://roseindia.net/java/java-tips/oop/q-hammurabi/q-pr-hammurabi-1.shtml\n\ \ \ \ http://en.wikipedia.org/wiki/Hammurabi\n**appendix\ TCL\ programs**\n\n----\n\ \ #start\n\ \ #start\n\ \ #start\n\ \ #start\n\ \ #:by\ gold,\ \ \ trial\ console\ operation\n\n\ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ if\ 0\ \{This\ is\ used\ several\ times\ in:\}\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ liters\ of\ grains\}\ \{20\ liters\ of\ grain\}\ \{10\ liters\ of\ grain\}\n\ \ \ \ \ \{10\ liters\ of\ grain\}\ \{50\ liters\ of\ grain\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ hectares\ of\ land\}\ \{60\ hectares\ of\ land\}\ \{50\ hectares\ of\ land\}\n\ \ \ \ \ \{100\ hectares\ of\ land\}\ \{20\ hectares\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 1000\}\ \{census\ 3000\}\ \{census\ 2000\}\ \{census\ 5000\}\ \{census\ 8000\}\ \{census\ 4000\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \\n\"\n\ \ \ \ \ \}\n\ \ set\ sumit\ 1000\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ \}\ \{\n\ \ global\ sumit\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ set\ sumit\ \[\ expr\ \{\ \$sumit\ +\ \$token\ \}\ \]\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \$sumit\ \"\n\ \ advisorx\ 50\ 50\ \ \ \n\ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ \"\n\ \ \ puts\ \"answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \"\n\n\n\n\ \ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \n\n----\n\ \n***FIRST\ VERSION***\ \n\n======\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \ \n\ \ \ \ \ \ \ \ #start\ of\ deck\n\n\n\ #:by\ gold,\ \ \ Game\ kingdom\ of\ strategy\n\n\ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\ \ \n\ \ package\ require\ Tk\n\ \ \ \ \ \n\ \ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ if\ 0\ \{This\ is\ used\ several\ times\ in:\}\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ measures\ of\ barleys\}\ \{20\ measures\ of\ barley\}\ \{10\ measures\ of\ barley\}\n\ \ \ \ \ \{10\ measures\ of\ barley\}\ \{50\ measures\ of\ barley\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ barleyfields\ of\ land\}\ \{60\ barleyfields\ of\ land\}\ \{50\ barleyfields\ of\ land\}\n\ \ \ \ \ \{100\ barleyfields\ of\ land\}\ \{20\ barleyfields\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 99\}\ \{census\ 100\}\ \{census\ 120\}\ \{census\ 110\}\ \{census\ 120\}\ \{census\ 80\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \ \n\ \ \ ans.form:king\ buy\ 20\ land\ \ \\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ \}\n\ \ \ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ #proc\ poly\ args\ \{eval\ .cv\ create\ polygon\ \$args\}\n\ \ \ \ set\ lister\ \{\ 5\ 5\ 6\ 6\ 6\ 6\ 6\ 6\ 7\ 7\ 7\ 7\ 8\ 8\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ \}\n\ \ \ \ proc\ transnumber\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \\u3024\}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \\u3024\}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\ \ \n\ \ set\ loser5\ 0\n\ \ set\ counter\ 0\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\ \ proc\ winnerx\ \{aa\ bb\}\ \{\n\ \ global\ sumit\ sumitland\ sumitbarley\n\ \ global\ sumarians\ liters\ winner5\n\ \ global\ loser5\n\ \ puts\ \"\ \ \ end\ of\ game\ \ \"\n\ \ .zzz\ delete\ 0\ end\n\ \ .xxx\ delete\ 0\ end\n\ \ .t\ delete\ 1.0\ end\n\ \ .t\ insert\ 1.0\ \"\ \ end\ of\ game\ \ \"\n\ \ .zzz\ insert\ 0\ \"\ \ end\ of\ game\ \ \"\n\ \ .xxx\ insert\ 0\ \"\ \ end\ of\ game\ \ \"\n\ \ \ if\ \{\ \$sumarians\ >=\ 120\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"\ king\ is\ winner\ declared\ \"\n\ \ .xxx\ insert\ 0\ \"\ king\ is\ winner\ declared\ \"\n\ \ .t\ insert\ 1.0\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitland\ >=\ 700\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"king\ is\ winner\ declared\"\n\ \ .xxx\ insert\ 0\ \"king\ is\ winner\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"king\ is\ winner\ declared\"\n\ \ \ puts\ \"king\ is\ winner\ declared\"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \n\ \ if\ \{\ \$sumarians\ <=\ 40\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"loser\ declared\"\n\ \ .xxx\ insert\ 0\ \"loser\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"loser\ declared\"\n\ \ \ puts\ \"loser\ declared\"\n\ \ \ \ set\ loser5\ 1\n\ \ \}\n\n\ \ \ if\ \{\ \$sumitbarley\ <=\ 300\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"loser\ declared\"\n\ \ .xxx\ insert\ 0\ \"loser\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"loser\ declared\"\n\ \ \ puts\ \"loser\ declared\"\n\ \ set\ loser5\ 1\n\ \ \}\n\ \ \}\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ \ \ global\ counter\n\ \ if\ \{\ \$counter\ >=\ 5\ \}\ \{winnerx\ \$aa\ \$bb\ \}\n\ \ .t\ delete\ 1.0\ end\ \ \n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ if\ \{\ \$counter\ <=\ 6\ \}\ \{\ \n\ \ \ \ \ .t\ insert\ 1.0\ \[\ tidings\ \]\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ set\ bl\ \"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ .zzz\ insert\ \ end\ \"advisor:buy\ or\ sell,\ my\ lord?\ \$bl\ \\(for\ year\ \$counter\ \\)\"\n\ \ \ \ \}\ \n\ \ \n\ \ \ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ \n\ \ \ \ \ .t\ delete\ 1.0\ end\ \}\ \n\n\ \ \n\ \ \ puts\ \ \[.t\ get\ 1.0\ end\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \\(for\ year\ \$counter\ \\)\ \"\n\ \ \ incr\ counter\n\ \ \}\n\n\ \ \ \n\ set\ sumarians\ \ 100\n\n\ \ proc\ calculation\ \{\ aa\ bb\ cc\ dd\ ee\ \}\ \{\n\ \ global\ counter\ fieldsdisplay\n\ \ global\ \ sumitland\ sumitbarley\ \n\ \ global\ \ buyland\ \ buybarley\ sumarians\n\ \ set\ annum\ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ set\ provisions\ \ \ \ 1000\ \ \ \ \ \ \ \ \n\ \ set\ liters\ 5000\ \ \ \n\ \ set\ land\ \ \ \ 1000\ \ \ \ \ \ \n\ \ set\ barleyfields\ \ \ 1000\n\ \ set\ landprice\ 26\n\ \ set\ litersperacre\ \ 3\ \n\ \ set\ totalmortality\ \ \ 10\n\ \ set\ mortalrateer\ \ 10\ \n\ \ set\ ratliters\ 1\n\ \ set\ citymortal\ 5\n\ \ set\ landfraction\ .1\n\ \ set\ sumariansgain\ 5\n\ \ set\ produce\ 4\n\ \ set\ buyland\ 1\n\ \ set\ buybarley\ 1\n\ \ set\ plaguethisyear\ 0\n\ \ set\ ratinfestthisyear\ 0\n\ \ set\ famineyear\ 0\n\ \ set\ immigrantyear\ 0\n\ \ set\ fieldsdisplay\ 20\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ immigrantyear\ \ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ plaguethisyear\ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .41\ \}\ \{set\ ratinfestthisyear\ 1\ \}\n\ \ set\ ratliters\ \ \[\ expr\ \{\ \$liters*.1*rand()\ \ \ \}\ \]\n\ \ set\ ratliters\ \[\ expr\ \{\ int(\$ratliters)\ \}\ \]\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ \$sumarians*.02*rand()\ \ \ \}\ \]\n\ \ set\ landfraction\ \ \[\ expr\ \{\ \ \ rand()\ \}\ \]\ \n\ \ if\ \{\ \$immigrantyear\ ==\ 1\ \}\ \{\n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ \$sumarians\ \ *\ .05\ \}\ \]\ \}\ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ int(\$sumariansgain)\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ \$sumarians\ +\ \$sumariansgain\ \ \ \}\ \]\n\ \ set\ produce\ \[\ expr\ \{\ \ \$land\ *\ 3\ \}\ \]\n\ \ set\ landprice\ \[\ lpick\ \{\ 26\ 25\ 24\ 23\ 22\ 21\ 20\ 19\ 18\ 17\ 16\ \}\ \]\ \n\ \ set\ landprice\ \[\ expr\ \{\ int(\$landprice)\ \}\ \]\ \n\ \ set\ liters\ \$sumitbarley\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ +\ \$sumitland*.8\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$landprice*\ \$buyland\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$sumarians*\ 7\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$liters*.1*\$ratinfestthisyear\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ int(\$liters)\ \}\ \]\ \n\ \ set\ foodrequire\ \[\ expr\ \{\$sumarians*7\ \}\]\n\ \ if\ \{\ \ \ \$liters\ <=\ \$foodrequire\ \ \ \}\ \{\n\ \ set\ sumariansstarved\ \[expr\ \{\$sumarians*.2\ \ \}\ \]\ \n\ \ set\ famineyear\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ int(\$sumariansstarved)\ \ \}\ \]\n\ \ set\ sumitbarley\ \$liters\n\ \ set\ sumitland\ \ \[\ expr\ \{\ int(\$sumitland)\ \ \}\ \]\n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ +\ \$sumarians*.1\ -\$sumariansstarved\}\ \]\ \n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ -\ \$sumarians*.5*\$plaguethisyear\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ int(\$sumarians)\ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ (\$sumitland/1000.)*100.\ \ \ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ int(\$percentfields)\ \}\ \]\n\ \ set\ fieldsdisplay\ \[\ expr\ \{\ 35*\$percentfields*.01\ \}\ \]\n\ \ \ set\ fieldsdisplay\ \[\ expr\ \{int(\$fieldsdisplay)\ \ \}\ \]\n\ \ if\ \{\ \ \$fieldsdisplay\ <=\ 1\ \ \ \}\ \{\ set\ fieldsdisplay\ 1\ \}\n\ \ if\ \{\ \ \$fieldsdisplay\ >=\ 35\ \ \ \}\ \{\ set\ fieldsdisplay\ 35\ \}\n\ \ .cv\ delete\ landbarley\n\ \ barley\ .cv\ \$fieldsdisplay\n\ \ puts\ \ \"annum\ \$counter\ \"\n\ \ puts\ \ \"\$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \"\n\ \ puts\ \ \"\$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\"\n\ \ puts\ \"\$percentfields\ percent\ fields\ \"\n\ \ puts\ \"\ \$fieldsdisplay\ \ fieldsdisplay\ \"\n\ \ puts\ \"\$sumariansstarved\ sumarians\ starved\"\n\ \ puts\ \"\$sumariansgain\ immigrated\ to\ city.\"\n\ \ puts\ \"census\ \$sumarians\ \ \"\n\ \ puts\ \"total\ \ \$sumitland\ barleyfields.\"\n\ \ puts\ \"yielded\ 3\ measures\ per\ barleyfield\"\n\ \ puts\ \"rats\ devoured\ \$ratliters\ measures.\"\n\ \ puts\ \ \"\$liters\ \ measures\ in\ palace.\"\n\ \ puts\ \"land\ \$landprice\ measures\ per\ barleyfield\"\n\ \ puts\ \"how\ many\ barleyfields\ do\ you\ wish\ to\ buy?\"\ \n\ \ set\ listx\ \ \"\n\ \ \ \ \ \ \ annum\ \$counter,\ \ \ \$liters\ \ measures\ \ \ \n\ \ \ \ \ \ \ census\ \$sumarians,\ \ \$sumitland\ barleyfields.\ \ \ \n\ \ \ \ \ \ \ \$landprice\ landprice\ measures\n\ \ \ \ \ \ \$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$famineyear\ \ famineyear\ ,0\ or\ 1\n\ \ \ \ \ \ \ \$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$sumariansstarved\ sumarians\ starved\ \n\ \ \ \ \ \ \$sumariansgain\ immigrated\ to\ city.\ \n\ \ \ \ \ \ census\ \$sumarians\ \ \ \n\ \ \ \ \ \ total\ \ \$sumitland\ barleyfields.\ \n\ \ \ \ \ \ yielded\ 3\ measures\ per\ barleyfield\ \n\ \ \ \ \ \ rats\ devoured\ \$ratliters\ measures.\ \n\ \ \ \ \ \ \ \$liters\ \ measures\ in\ palace.\ \n\ \ \ \ \ \ land\ \$landprice\ measures\ per\ barleyfield\ \"\n\ \ \ \ \ \ return\ \"\ \$listx\ \"\n\n\n\ \ \}\n\n\ \ \n\ \ proc\ king\ \{\ aa\ bb\ cc\}\ \{\n\ \ global\ \ sumitland\ sumitbarley\ \n\ \ global\ buyland\ buybarley\n\ \ global\ counter\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ sumitland\ \[\ expr\ \{\ \$sumitland\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ sumitbarley\ \[\ expr\ \{\ \$sumitbarley\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ buyland\ \ \$token\ \ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ buybarley\ \ \$token\ \ \}\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \ land\ \$sumitland,\ barley\ \$sumitbarley\ \"\n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ \n\ \ advisorx\ 50\ 50\n\n\ \ \n\ \ \}\n\ \ \ \ set\ listx\ \[\ transnumber\ \$lister\ \]\n\ \ \ \ proc\ tactics\ \ \{w\}\ \{\n\ \ \ \ global\ listx\n\ \ \ \ set\ yy\ 100\n\ \ \ \ set\ font3\ \{Hevetica\ 20\}\n\ \ \ \ set\ font5\ \{Hevetica\ 150\}\n\ \ \ \ set\ lister\ \{\ 5\ 5\ 6\ 6\ 6\ 6\ 6\ 6\ 7\ 7\ 7\ 7\ 8\ 8\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ \}\n\ \ \ \ \$w\ create\ rect\ 150\ 50\ 250\ 400\ -fill\ gold\ \n\ \ \ \ \$w\ create\ polygon\ \ -80\ 100\ \ -80\ 70\ \ -50\ 70\ \ -20\ -10\ \ -40\ -50\ \ -20\ -100\ \ 20\ -100\ \ 40\ -50\ \ 20\ -10\ \ 50\ 70\ \ 80\ 70\ \ 80\ 100\ -fill\ gold\ -tags\ figure\n\ \ \ \ \$w\ move\ figure\ 150\ 150\n\ \ \ \ #\ \$w\ create\ text\ 200\ 400\ -text\ \\u2617\ \ -tags\ \"text\"\ -fill\ tan\ -font\ \$font5\n\ \ \ \ foreach\ i\ \{1\ 2\ 3\ 4\ 5\ 6\ \}\ \{\n\ \ \ \ \$w\ create\ text\ 200\ \$yy\ -text\ \[lpick\ \$listx\ \]\ \ -tags\ \"text\"\ \ -font\ \$font3\n\ \ \ \ incr\ yy\ 50\n\ \ \ \ \}\n\ \ \ \ \}\n\n\n\n\n\n\n\n\n\ \ \ \ \ \ proc\ clrcanvas\ \{w\}\ \{\n\ \ \ \ global\ counter\ winner5\n\ \ \ \$w\ delete\ \ \"all\"\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ .xxx\ delete\ \ 0\ end\ \ \n\ \ \ .t\ delete\ 1.0\ end\n\ \ \ \ set\ counter\ 0\n\ \ \ \ set\ winner5\ 0\n\ \ \ \ set\ loser5\ 0\n\ \ \}\n\n\ \n\ \ proc\ leave\ \{w\}\ \{\n\ \ \ \ \ exit\n\ \ \}\n\n\ \ \ proc\ board\ \{w\}\ \{\n\ \ \ \ #set\ state3\ 1\n\ \ \ \ set\ state2\ 1\n\ \ \ \ clrcanvas\ \$w\n\ \ \ \ .\ configure\ -background\ orange\ -highlightcolor\ brown\ -relief\ raised\ -border\ 30\n\ \ \ \ \$w\ configure\ -bg\ tan\n\ \ \ \ \ \n\ \ \ \ \}\n\ \ \n\ \ \ proc\ \ replyit\ \{w\}\ \{\n\ \ \ \ global\ counter\n\ \ \ .t\ delete\ 1.0\ end\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ .xxx\ delete\ \ 0\ end\ \ \n\ \ \ .zzz\ insert\ \ end\ \"advisor:buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ .xxx\ insert\ \ end\ \"king\ \"\n\ \ \ \}\n\n\n\n\n\ \ \ \ set\ keeperer\ \{\ 1\ 2\ 3\ \}\n\ \ \ \ proc\ \ record\ \{w\}\ \{\n\ \ \ \ \ global\ side2\ side1\ buy\ sell\ \n\ \ \ \ \ global\ winner5\ loser5\n\ \ \ \ \ \ \n\ \ \ lappend\ keeperer\ \$side2\n\ \ \ lappend\ keeperer\ \$side1\n\ \ \ puts\ \$keeperer\n\ \ \ eval\ \[\ split\ \ \$side1\ \"\ \"\ \]\n\ \ \ \n\ \ \ set\ results\ \ \[\ calculation\ 10\ 10\ 10\ 10\ 10\ \]\n\ \ \ puts\ \$results\n\ \ \ \n\ \ \ \ .t\ delete\ 1.0\ end\n\ \ \ \ .t\ insert\ 1.0\ \$results\n\ \ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ \ .zzz\ insert\ \ end\ \"advisor\ says:\ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\"\n\ \ \ \ if\ \{\ \$winner5\ ==\ 1\}\ \{\n\ \ \ \ .zzz\ delete\ \ 0\ end\ \n\ \ \ \ .zzz\ insert\ \ end\ \"advisor\ says:\ king\ is\ winner\ \"\ \}\n\ \ \ \n\ \ \ \ \ \}\n\n\ \ \ proc\ \ reportx\ \{w\}\ \{\n\ \ \ console\ show\n\ \ \ \ puts\ \"fifth\ rate\"\n\ \ \ \ puts\ \"performance\ comparable\ to\ bonzo\"\n\ \ \ \ puts\ \"surving\ inhabitants\ have\ fled\"\n\ \ \ \ puts\ \"mandated\ poll\ results\"\n\ \ \ \ puts\ \"lacking\ any\ sense\"\n\ \ \ \ puts\ \"second\ rate\"\;\n\ \ \ \ puts\ \"no\ bread\ left\"\n\ \ \ \ puts\ \"third\ rate\"\n\ \ \ \ puts\ \"quit\ day\ job\"\n\ \ \ \}\n\n\ \ \ \ proc\ castle\ \{w\}\ \{\n\ \ \ \ \ \ global\ dx\ dy\ fieldsdisplay\n\ \ \ \ \ \ set\ dx\ 50\n\ \ \ \ \ \ set\ dy\ 30\n\ \ \ \ \ \ set\ gualisting\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ second_hexagram\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ colorx\ black\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 20\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ brown\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 50\}\ \{\$j<3\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ brown\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ tan\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ brown\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ tan\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ brown\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \$x\ \$y\ \[expr\ \{\$x+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dx\ 50\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dy\ 30\n\ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 20\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 50\}\ \{\$j<3\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ tan\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ blue\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ tan\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ blue\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \[expr\ \$x\ +\ 180\]\ \$y\ \[expr\ \{\[expr\ \$x\ +180\ \]+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\n\ \ \ \ \ \}\n\ \ \ \n\ \ \ proc\ barley\ \{w\ fieldsdisplay\ \}\ \{\n\ \ \ \ \ \ global\ dx\ dy\ \n\ \ \ \ \ \ set\ dx\ 5\n\ \ \ \ \ \ set\ dy\ 10\n\ \ \ \ \ \ set\ gualisting\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ second_hexagram\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ colorx\ black\;\n\ \ \ \ \ \ \$w\ delete\ landbarley\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 220\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 30\}\ \{\$j<\$fieldsdisplay\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ green\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \$x\ \$y\ \[expr\ \{\$x+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\ -tag\ landbarley\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dx\ 5\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dy\ 10\n\ \ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 220\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 30\}\ \{\$j<\$fieldsdisplay\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ green\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \[expr\ \$x\ +\ 180\]\ \$y\ \[expr\ \{\[expr\ \$x\ +180\ \]+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\ -tag\ landbarley\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\n\ \ \ \ \ \}\n\n\n\ \ \ \ proc\ about\ \{w\}\ \{\n\ \ \ \ set\ msg\ \"Game\ kingdom\ of\ strategy.\n\ \ \ \ \ \ \ \ \ \ from\ TCL\ WIKI,\n\ \ \ \ \ \ \ \ \ \ written\ on\ eTCL\n\ \ \ cmds\ take\ form\n\ \ \ king\ buy\ 33\ land\n\ \ \ king\ sell\ 11\ land\n\ \ \ king\ sell\ 55\ barley\n\ \ \ king\ buy\ 33\ barley\ \"\n\ \ \ \ \n\ \ \ \ tk_messageBox\ -title\ \"About\"\ -message\ \$msg\n\ \ \ \ \}\n\n\ \ #:\ Main\ :\n\ \ frame\ .f1\n\ \ frame\ .f2\n\ \ frame\ .f3\n\ \ pack\ \ .f1\ .f2\ .f3\n\n\ \ set\ maxX\ 400\n\ \ set\ maxY\ 300\n\ \ set\ y\ \ \ \ \ \ 0\n\n\ \ set\ x1\ 120\n\ \ set\ x2\ 150\n\ \ set\ y1\ \ 50\n\ \ set\ y2\ \ 80\n\n\ \ canvas\ \ .cv\ -width\ \$maxX\ -height\ \$maxY\ \ -bg\ tan\n\ \ pack\ \ \ \ .cv\ -in\ .f1\n\ \ \n\ \ \ #set\ side2\ 2\n\ \ button\ \ .b0\ -text\ \"clear\"\ -command\ \{\ clrcanvas\ .cv\ \}\n\ \ button\ \ .b3\ -text\ \"castle\"\ \ \ -command\ \{clrcanvas\ .cv\;barley\ .cv\ 20\;\ castle\ \ .cv\;\ \}\n\ \ button\ \ .b5\ -text\ \"wildcard\"\ \ \ -command\ \{clrcanvas\ .cv\;\ tactics\ \ \ .cv\ \}\n\ \ \ \ \ \n\ \ \ \ \ \ button\ \ .b6\ -text\ \"record\"\ \ \ -command\ \{\ record\ \ .cv\ \}\n\ \ \ \ \ \ button\ \ .b7\ -text\ \"situation\"\ \ \ -command\ \{castle\ .cv\;replyit\ .cv\;\ advisorx\ 50\ 50\ \ \}\n\ \ \ \ \ \ button\ .b4\ -text\ \"console\"\ \ \ -command\ \{reportx\ .cv\ \ \}\n\ \ \ \ \ \ button\ \ .b8\ -text\ \"exit\"\ \ \ -command\ \{leave\ \ \ .cv\ \}\ \n\ \ \ \ \ \ button\ \ .b9\ -text\ \"about\"\ \ \ -command\ \{about\ \ \ .cv\ \}\ \n\ \ \ \ \ \ text\ .t\ -width\ 40\ -height\ 5\ -bg\ bisque\n\ \ \ \ \ \ entry\ .xxx\ -width\ 50\ \ -bg\ bisque\ -textvariable\ side1\n\ \ \ \ \ \ entry\ .zzz\ -width\ 50\ -textvariable\ side2\ -bg\ bisque\n\ \ \ \ \ pack\ .b0\ .b3\ .b5\ \ .b6\ .b7\ .b7\ .b4\ .b9\ .b8\ \ -in\ .f2\ \ -side\ left\ -padx\ 2\n\ \ .f2\ configure\ \ -bg\ orange\n\ \ \ \ \ \ label\ .kingx\ \ -text\ \"king\"\ \n\ \ \ \ \ \ label\ .advisora\ \ -text\ \"advisor\"\ \n\ \ \ \ \ \ pack\ \ .advisora\ .zzz\ .t\ \ \ .kingx\ \ .xxx\ -in\ .f3\ \ -side\ bottom\ -padx\ 2\n\ \ \ \ \ \ focus\ .xxx\n\ \ \ \ \ \ focus\ .zzz\n\ \ \ \ \ \ board\ \ \ .cv\n\ \ \ \n\ \ \ \ \ bind\ .\ <Motion>\ \{wm\ title\ .\ \"\ Game\ kingdom\ of\ strategy\ \"\}\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***Version\ with\ added\ hacks\ ***\n\n\n\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ 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***Version\ console\ operation***\n\n======\n\n\n\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \n\ #:by\ gold,\ \ \ \ \ console\ operation\n\n\ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ \ \n\n\ \ proc\ winnerx\ \{aa\ \}\ \{\n\ \ global\ sumit\ sumitland\ sumitbarley\n\ \ global\ sumarians\ liters\ winner5\n\ \ global\ loser5\n\ \ puts\ \"\ \ \ end\ of\ game\ \ \"\ \n\ \ \ if\ \{\ \$sumarians\ >=\ 120\ \}\ \{\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitland\ >=\ 700\ \}\ \{\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"king\ is\ winner\ declared\"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \n\ \ if\ \{\ \$sumarians\ <=\ 40\ \}\ \{\n\ \ \ \ puts\ \"loser\ declared\"\n\ \ \ \ set\ loser5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitbarley\ <=\ 300\ \}\ \{\n\ \ \ puts\ \"loser\ declared\"\n\ \ set\ loser5\ 1\n\ \ \}\n\ \ \}\n\n\n\ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ measures\ of\ barleys\}\ \{20\ measures\ of\ barley\}\ \{10\ measures\ of\ barley\}\n\ \ \ \ \ \{10\ measures\ of\ barley\}\ \{50\ measures\ of\ barley\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ barleyfields\ of\ land\}\ \{60\ barleyfields\ of\ land\}\ \{50\ barleyfields\ of\ land\}\n\ \ \ \ \ \{100\ barleyfields\ of\ land\}\ \{20\ barleyfields\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 99\}\ \{census\ 100\}\ \{census\ 120\}\ \{census\ 110\}\ \{census\ 120\}\ \{census\ 80\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \ \n\ \ \ ans.form:king\ buy\ 20\ land\ \ \\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ \}\n\n\ \ set\ sumarians\ \ 100\n\ \ set\ counter\ 0\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\ \ proc\ calculation\ \{\ aa\ \}\ \{\n\ \ global\ counter\ percentfields\n\ \ global\ sumit\ sumitland\ sumitbarley\ \n\ \ global\ \ buyland\ \ buybarley\ sumarians\n\ \ set\ annum\ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ set\ provisions\ \ \ \ 1000\ \ \ \ \ \ \ \ \n\ \ set\ liters\ 5000\ \ \ \n\ \ set\ land\ \ \ \ 1000\ \ \ \ \ \ \n\ \ set\ barleyfields\ \ \ 1000\n\ \ set\ landprice\ 26\n\ \ set\ litersperacre\ \ 3\ \n\ \ set\ totalmortality\ \ \ 10\n\ \ set\ mortalrateer\ \ 10\ \n\ \ set\ ratliters\ 1\n\ \ set\ citymortal\ 5\n\ \ set\ landfraction\ .1\n\ \ set\ sumariansgain\ 5\n\ \ set\ produce\ 4\n\ \ set\ buyland\ 1\n\ \ set\ buybarley\ 1\n\ \ set\ plaguethisyear\ 0\n\ \ set\ ratinfestthisyear\ 0\n\ \ set\ famineyear\ 0\n\ \ set\ immigrantyear\ 0\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .90\ \}\ \{set\ immigrantyear\ \ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ plaguethisyear\ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .41\ \}\ \{set\ ratinfestthisyear\ 1\ \}\n\ \ set\ ratliters\ \ \[\ expr\ \{\ \$liters*.1*rand()\ \ \ \}\ \]\n\ \ set\ ratliters\ \[\ expr\ \{\ int(\$ratliters)\ \}\ \]\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ \$sumarians*.02*rand()\ \ \ \}\ \]\n\ \ set\ landfraction\ \ \[\ expr\ \{\ \ \ rand()\ \}\ \]\ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ \$sumarians\ \ *\ .10\ *\ rand()\ \}\ \]\ \ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ int(\$sumariansgain)\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ \$sumarians\ +\ \$sumariansgain\ \ \ \}\ \]\n\ \ set\ produce\ \[\ expr\ \{\ \ \$land\ *\ 3\ \}\ \]\n\ \ set\ landprice\ \[\ lpick\ \{\ 26\ 25\ 24\ 23\ 22\ 21\ 20\ 19\ 18\ 17\ 16\ \}\ \]\ \n\ \ set\ landprice\ \[\ expr\ \{\ int(\$landprice)\ \}\ \]\ \n\ \ set\ liters\ \$sumitbarley\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ +\ \$sumitland*.8\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$landprice*\ \$buyland\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$sumarians*\ 7\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$liters*.1*\$ratinfestthisyear\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ int(\$liters)\ \}\ \]\ \n\ \ set\ foodrequire\ \[\ expr\ \{\$sumarians*7\ \}\]\n\ \ if\ \{\ \ \ \$liters\ <=\ \$foodrequire\ \ \ \}\ \{\n\ \ set\ sumariansstarved\ \[expr\ \{\$sumarians*.2\ \ \}\ \]\ \n\ \ set\ famineyear\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ int(\$sumariansstarved)\ \ \}\ \]\n\ \ set\ sumitbarley\ \$liters\n\ \ set\ sumitland\ \ \[\ expr\ \{\ int(\$sumitland)\ \ \}\ \]\n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ +\ \$sumarians*.1\ -\$sumariansstarved\}\ \]\ \n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ -\ \$sumarians*.5*\$plaguethisyear\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ int(\$sumarians)\ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ (\$sumitland/1000.)*100.\ \ \ \}\ \]\n\ \ if\ \{\ \ \$percentfields\ <=\ 1\ \ \ \}\ \{\ set\ percentfields\ 1\ \}\n\ \ if\ \{\ \ \$percentfields\ >=\ 100\ \ \ \}\ \{\ set\ percentfields\ 100\ \}\n\ \ set\ percentfields\ \[\ expr\ \{\ int(\$percentfields)\ \}\ \]\n\ \ puts\ \ \"annum\ \$counter\ \"\n\ \ puts\ \ \"\$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \"\n\ \ puts\ \ \"\$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\"\n\ \ puts\ \"\$percentfields\ percent\ \"\n\ \ puts\ \"\$sumariansstarved\ sumarians\ starved\"\n\ \ puts\ \"\$sumariansgain\ immigrated\ to\ city.\"\n\ \ puts\ \"census\ \$sumarians\ \ \"\n\ \ puts\ \"total\ \ \$sumitland\ barleyfields.\"\n\ \ puts\ \"yielded\ 3\ measures\ per\ barleyfield\"\n\ \ puts\ \"rats\ devoured\ \$ratliters\ measures.\"\n\ \ puts\ \ \"\$liters\ \ measures\ in\ palace.\"\n\ \ puts\ \"land\ \$landprice\ measures\ per\ barleyfield\"\n\ \ puts\ \"how\ many\ barleyfields\ do\ you\ wish\ to\ buy?\"\ \n\ \ set\ listx\ \ \"\n\ \ \ \ \ \ \ annum\ \$counter,\ \ \ \$liters\ \ measures\ \ \ \n\ \ \ \ \ \ \ census\ \$sumarians,\ \ \$sumitland\ barleyfields.\ \ \ \n\ \ \ \ \ \ \ \$landprice\ landprice\ measures\n\ \ \ \ \ \ \$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$famineyear\ \ famineyear\ ,0\ or\ 1\n\ \ \ \ \ \ \ \$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$sumariansstarved\ sumarians\ starved\ \n\ \ \ \ \ \ \$sumariansgain\ immigrated\ to\ city.\ \n\ \ \ \ \ \ census\ \$sumarians\ \ \ \n\ \ \ \ \ \ total\ \ \$sumitland\ barleyfields.\ \n\ \ \ \ \ \ yielded\ 3\ measures\ per\ barleyfield\ \n\ \ \ \ \ \ rats\ devoured\ \$ratliters\ measures.\ \n\ \ \ \ \ \ \ \$liters\ \ measures\ in\ palace.\ \n\ \ \ \ \ \ land\ \$landprice\ measures\ per\ barleyfield\ \"\n\ \ \ \ \ \ incr\ counter\n\ \ \ \ \ \ return\ \"\ \$listx\ \"\n\n\n\ \ \}\n\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ global\ counter\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ if\ \{\ \$counter\ <=\ 5\ \}\ \{puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ puts\ \"update:\ game\ ends\"\ \}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ \ winnerx\ 1\ \}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ puts\ \"for\ new\ game,\ enter\ reset\ 1\ \"\ \}\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ cc\ \}\ \{\n\ \ \n\ \ global\ sumitland\ sumitbarley\ \n\ \ global\ buyland\ buybarley\n\ \ global\ counter\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ sumitland\ \[\ expr\ \{\ \$sumitland\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ sumitbarley\ \[\ expr\ \{\ \$sumitbarley\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ buyland\ \ \$token\ \ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ buybarley\ \ \$token\ \ \}\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \ \ land\ \$sumitland,\ barley\ \$sumitbarley\ \"\n\ \ \ \n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ record\ 1\ \n\ \ advisorx\ 50\ 50\n\ \ \n\ \ \n\ \ \}\n\ \ \ proc\ record\ aa\ \{\n\ \ \ set\ results\ \ \[\ calculation\ 10\ \ \]\n\ \ \ puts\ \$results\n\ \ \ return\ 1\ \}\n\ \ \ proc\ reset\ aa\ \{\n\ \ \ global\ counter\n\ \ \ set\ counter\ 0\n\ \ \ \ set\ sumitland\ 1000\n\ \ \ \ set\ sumitbarley\ 1000\ \n\ \ \ \ set\ sumarians\ \ 100\ \n\ \ \ advisorx\ 1\ 2\ \n\ \ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ land\ \"\n\ \ \ puts\ \"\ can\ cut\ &\ paste\ from\ console\"\n\ \ \ puts\ \"answer\ has\ form:\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ buy\ 20\ land\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ sell\ 30\ land\ \ \"\n\ \ \ puts\ \"eg.\ \ \ king\ buy\ 33\ barley\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ sell\ 11\ barley\ \"\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\ \ \ \ \ \ #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\ \ \ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 17Jul2010\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\ \n======\n***Extra\ Program***\ \n======\n\ \ \ \ ======\n\ \n***Real\ TEST\ on\ \ trial\ code\ trial\ code***\n\n\ #note:\ this\ Tkpaint\ diagram\ \n\ #\ script\ is\ *correct*\ in\ the\ wiki\ editor.\n\ #\ It\ is\ rewrapping\ on\ the\ Wiki\ display\ page.\n\ \ set\ maxX\ 400\n\ \ set\ maxY\ 400\n\ \ set\ y\ \ \ \ \ \ 0\n\n\ \ set\ x1\ 120\n\ \ set\ x2\ 150\n\ \ set\ y1\ \ 50\n\ \ set\ y2\ \ 80\n\n\ pack\ \[\ canvas\ \ .c\ \ -width\ \$maxX\ -height\ \$maxY\ \ -bg\ bisque\ \]\nset\ Graphics(arrowshape)\ \{8\ 10\ 4\}\nset\ Graphics(fill,color)\ \{\}\nset\ Graphics(fill,style)\ \{\}\nset\ Graphics(font,bold)\ 1\nset\ Graphics(font,color)\ black\nset\ Graphics(font,italic)\ 0\nset\ Graphics(font,normal)\ 0\nset\ Graphics(font,overstrike)\ 0\nset\ Graphics(font,roman)\ 0\nset\ Graphics(font,size)\ 10\nset\ Graphics(font,stipple)\ \{\}\nset\ Graphics(font,style)\ bold\nset\ Graphics(font,type)\ Arial\nset\ Graphics(font,underline)\ 0\nset\ Graphics(grid,on)\ 0\nset\ Graphics(grid,size)\ 10m\nset\ Graphics(grid,snap)\ 1\nset\ Graphics(line,arrow)\ none\nset\ Graphics(line,capstyle)\ butt\nset\ Graphics(line,color)\ black\nset\ Graphics(line,joinstyle)\ miter\nset\ Graphics(line,smooth)\ 0\nset\ Graphics(line,style)\ \{\}\nset\ Graphics(line,width)\ 1\nset\ Graphics(mode)\ NULL\nset\ Graphics(shape)\ circle\nset\ Graphics(snap,on)\ 0\nset\ Graphics(snap,size)\ 1\nset\ Graphics(splinesteps)\ 20\nset\ Graphics(text,anchor)\ c\nset\ Graphics(ticks,on)\ 0\nset\ Graphics(mode)\ NULL\n###\ End\ of\ Graphics\ parameters\n\n\nset\ Zoom(button,text)\ 100%\nset\ Zoom(caller)\ \{\}\nset\ Zoom(factor)\ 1\nset\ Zoom(font,size)\ 10\nset\ Zoom(selected,button)\ 1\nset\ utagCounter\ 62\n\n\nset\ Image(ctr)\ 0\n\n\nset\ Canv(H)\ 368\nset\ Canv(W)\ 610\nset\ Canv(SH)\ 1500\nset\ Canv(SW)\ 1500\nset\ Canv(bg)\ white\n.c\ config\ -width\ \$Canv(W)\ \ -height\ \$Canv(H)\ \ -bg\ \$Canv(bg)\ \ -scrollregion\ \"0\ 0\ \$Canv(SW)\ \$Canv(SH)\"\nwm\ geometry\ .\ \"\"\n.c\ xview\ moveto\ 0\n.c\ yview\ moveto\ 0\nset\ TextInfo(utag52)\ \{Game\ \ kingdom\ \ of\ \ strategy\}\nset\ TextInfo(utag34)\ \{\}\nset\ TextInfo(utag16)\ initial\nset\ TextInfo(utag53)\ \{\}\nset\ TextInfo(utag17)\ \{random\nsituation\}\nset\ TextInfo(utag54)\ \{TCL\ \ WIKI\}\nset\ TextInfo(utag18)\ \{\}\nset\ TextInfo(utag19)\ stop\nset\ TextInfo(utag20)\ \{\}\nset\ TextInfo(utag56)\ \{\}\nset\ TextInfo(utag21)\ \{\}\nset\ TextInfo(utag57)\ LOOP\nset\ TextInfo(utag39)\ stop\nset\ TextInfo(utag22)\ \{winner\ declared\}\nset\ TextInfo(utag58)\ \{COUNTER\ \ >\ \ 5\}\nset\ TextInfo(utag23)\ \{\}\nset\ TextInfo(utag60)\ \{\}\nset\ TextInfo(utag42)\ \{set\ \ counter\}\nset\ TextInfo(utag61)\ \{call\ \ records\}\nset\ TextInfo(utag43)\ \{call\ first\ \ situation\}\nset\ TextInfo(utag25)\ records\nset\ TextInfo(utag62)\ \{incr\ \ counter\}\nset\ TextInfo(utag26)\ \{\}\nset\ TextInfo(utag27)\ ratings\nset\ TextInfo(utag28)\ \{\ \ \ \ \ \ \ counts\}\nset\ TextInfo(utag47)\ totals\nset\ TextInfo(utag29)\ \{\}\nset\ TextInfo(utag12)\ \{new\ situation\}\nset\ TextInfo(utag48)\ \{\}\nset\ TextInfo(utag13)\ \{\}\nset\ TextInfo(utag50)\ \{\}\nset\ TextInfo(utag49)\ \{\}\nset\ TextInfo(utag14)\ king\nset\ TextInfo(utag51)\ \{\}\nset\ TextInfo(utag15)\ advisor\n.c\ create\ line\ 387.0\ 140.0\ 409.0\ 192.0\ 449.0\ 139.0\ 385.0\ 140.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag2\}\n.c\ create\ line\ 210.0\ 37.0\ 232.0\ 89.0\ 272.0\ 36.0\ 208.0\ 37.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag3\}\n.c\ create\ line\ 195.0\ 140.0\ 217.0\ 192.0\ 257.0\ 139.0\ 193.0\ 140.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag6\}\n.c\ create\ line\ 43.0\ 274.0\ 65.0\ 326.0\ 105.0\ 273.0\ 41.0\ 274.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag5\}\n.c\ create\ line\ 52.0\ 146.0\ 74.0\ 198.0\ 114.0\ 145.0\ 50.0\ 146.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag4\}\n.c\ create\ oval\ 126.0\ 214.0\ 294.0\ 276.0\ -tags\ \{Ellipse\ obj\ utag11\}\n.c\ create\ oval\ 332.0\ 287.0\ 500.0\ 349.0\ -tags\ \{Ellipse\ obj\ utag9\}\n.c\ create\ text\ 206.0\ 240.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{new\ situation\}\ -tags\ \{text\ obj\ utag12\}\n.c\ create\ text\ 68.0\ 286.0\ -font\ \{Arial\ 10\ bold\}\ -text\ king\ -tags\ \{text\ obj\ utag14\}\n.c\ create\ text\ 81.0\ 155.0\ -font\ \{Arial\ 10\ bold\}\ -text\ advisor\ -tags\ \{text\ obj\ utag15\}\n.c\ create\ text\ 238.0\ 47.0\ -font\ \{Arial\ 10\ bold\}\ -text\ initial\ -tags\ \{text\ obj\ utag16\}\n.c\ create\ text\ 216.0\ 155.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{random\nsituation\}\ -tags\ \{text\ obj\ utag17\}\n.c\ create\ text\ 416.0\ 317.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{winner\ declared\}\ -tags\ \{text\ obj\ utag22\}\n.c\ create\ rectangle\ 347.0\ 220.0\ 482.0\ 267.0\ -tags\ \{Rectangle\ obj\ utag24\}\n.c\ create\ text\ 419.0\ 241.0\ -font\ \{Arial\ 10\ bold\}\ -text\ records\ -tags\ \{text\ obj\ utag25\}\n.c\ create\ text\ 481.0\ 146.0\ -font\ \{Arial\ 10\ bold\}\ -text\ ratings\ -tags\ \{text\ obj\ utag27\}\n.c\ create\ text\ 466.0\ 165.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{\ \ \ \ \ \ \ counts\}\ -tags\ \{text\ obj\ utag28\}\n.c\ create\ line\ 232.0\ 95.0\ 233.0\ 127.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag31\}\n.c\ create\ line\ 264.0\ 153.0\ 377.0\ 151.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag32\}\n.c\ create\ line\ 72.0\ 207.0\ 74.0\ 262.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag33\}\n.c\ create\ line\ 120.0\ 156.0\ 177.0\ 155.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag35\}\n.c\ create\ line\ 146.0\ 275.0\ 102.0\ 289.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag36\}\n.c\ create\ line\ 410.0\ 197.0\ 410.0\ 213.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag37\}\n.c\ create\ line\ 416.0\ 272.0\ 416.0\ 283.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag38\}\n.c\ create\ text\ 555.0\ 319.0\ -font\ \{Arial\ 10\ bold\}\ -text\ stop\ -tags\ \{text\ obj\ utag39\}\n.c\ create\ line\ 506.0\ 318.0\ 522.0\ 318.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag40\}\n.c\ create\ line\ 217.0\ 195.0\ 217.0\ 208.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag41\}\n.c\ create\ text\ 320.0\ 66.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{set\ \ counter\}\ -tags\ \{text\ obj\ utag42\}\n.c\ create\ text\ 339.0\ 47.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{call\ first\ \ situation\}\ -tags\ \{text\ obj\ utag43\}\n.c\ create\ text\ 416.0\ 151.0\ -font\ \{Arial\ 10\ bold\}\ -text\ totals\ -tags\ \{text\ obj\ utag47\}\n.c\ create\ text\ 218.0\ 18.0\ -font\ \{Arial\ 18\ bold\}\ -text\ \{Game\ \ kingdom\ \ of\ \ strategy\}\ -tags\ \{text\ obj\ utag52\}\n.c\ create\ text\ 224.0\ 339.0\ -font\ \{Arial\ 18\ bold\}\ -text\ \{TCL\ \ WIKI\}\ -tags\ \{text\ obj\ utag54\}\n.c\ create\ line\ 32.000\ \ 177.0\ 29.67\ \ 23.999\ \ \ \ -arrow\ first\ -arrowshape\ \{8\ 10\ 4\}\ -smooth\ 1\ -tags\ \{arc\ arc\ obj\ utag55\ spline\}\n.c\ create\ text\ 44.0\ 224.0\ -font\ \{Arial\ 10\ bold\}\ -text\ LOOP\ -tags\ \{text\ obj\ utag57\}\n.c\ create\ text\ 322.0\ 134.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{COUNTER\ \ >\ \ 5\}\ -tags\ \{text\ obj\ utag58\}\n.c\ create\ oval\ 529.0\ 296.0\ 577.0\ 344.0\ -tags\ \{Circle\ obj\ utag59\}\n.c\ create\ text\ 501.0\ 185.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{call\ \ records\}\ -tags\ \{text\ obj\ utag61\}\n.c\ create\ text\ 278.0\ 183.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{incr\ \ counter\}\ -tags\ \{text\ obj\ utag62\}\n\n\n\n\ \ \n----\n\n\n----\n\n***test\ on\ \ trial\ code\ trial\ code***\nWe\ could\ bust\ up\ or\ split\n\ \ \ \ \ phrases\ looking\ for\ words\ buy\ or\ sell\ ,\n\ \ \ \ \ and\ no\ not\ sell.\n\ \ \ \ \ set\ answer\ \[split\ \$lister\ \"\"\ \]\n\ \ \ \ \ llength\ \$answer\n\ \ \ \ \ foreach\ item\ \{buy\ sell\ no\ not\ nay\ \}\ \{\n\ \ \ \ \ lsearch\ all\ \$answer\ \$item\n\ \ \ \ \ \ \}\ \ \ \ \n\ \ \ \ \ if\ we\ find\ one\ of\ the\ command\ words\ in\ list,\n\ \ \ \ \ does\ it\ operate\ on\ the\ next\ number\ found?\n\ \ \ \ \ Better\ check\ on\ how\ to\ identify\ a\ number\ element?\n\ \ \ \ \ say\ if\ \{\ catch\{\ expr\ \{\ 1.*\$element\}\ !=\ 1\ \}\n\ \ \ \ \ \ \ \ \ foreach\ item\ \$bee1\ \{\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ >>\ 0\}\ \{lappend\ cat\ \ \$item\ \}\n\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ ==\ 0\ \}\ \{lappend\ bat\ \[\ expr\ 200*\$factor*.1\ +\ \$item\ *\ log(\$factor)\ \ \]\}\n\ \ \ \ \ \ \ \}\n\n\ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \n\ #:by\ gold,\ \ \ trial\ console\ operation\n\n\ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ \ \n\n\n\n\n\n\n\n\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ liters\ of\ grains\}\ \{20\ liters\ of\ grain\}\ \{10\ liters\ of\ grain\}\n\ \ \ \ \ \{10\ liters\ of\ grain\}\ \{50\ liters\ of\ grain\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ hectares\ of\ land\}\ \{60\ hectares\ of\ land\}\ \{50\ hectares\ of\ land\}\n\ \ \ \ \ \{100\ hectares\ of\ land\}\ \{20\ hectares\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 1000\}\ \{census\ 3000\}\ \{census\ 2000\}\ \{census\ 5000\}\ \{census\ 8000\}\ \{census\ 4000\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \\n\"\n\ \ \ \ \ \}\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ \}\ \{\n\ \ global\ sumit\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ set\ sumit\ \[\ expr\ \{\ \$sumit\ +\ \$token\ \}\ \]\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \$sumit\ \"\n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ advisorx\ 50\ 50\n\ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ \"\n\ \ \ puts\ \"answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \"\n\n\n\n\ \ \ \ \ \ \ \n<<categories>>\ Toys\ |\ Example\ |\ Games\ |\ Characters\ |\ Math\ \ |\ Math\ | regexp2} CALL {my render {Game kingdom of strategy} **Game\ kingdom\ of\ Strategy**\n\n\ \ \ \ \ \ This\ page\ is\ under\ development.\ Comments\ are\ welcome,\n\ \ \ \ \ \ but\ please\ load\ any\ comments\ in\ the\ comments\ section\n\ \ \ \ \ \ at\ the\ middle\ of\ the\ page.\ Thanks,\[gold\]\n\n----\n----\n\ \ \ Here\ is\ some\ starter\ code\ for\n\ \ \ Game\ kingdom\ of\ Strategy.\n\ \ \ There\ is\ a\ post\ on\ wiki\ asking\ \n\ \ \ for\ a\ TCL\ version\ of\n\ \ \ a\ text\ and\ strategy\ game,\n\ \ \ originally\ in\ basic\ language.\n\ \ \ See\ Ideas\ for\ Projects\ in\ Tcl/Tk,\n\ \ \ http://wiki.tcl.tk/14335.\n\ \ \ I\ am\ trying\ to\ find\ out\n\ \ \ the\ status\ of\ the\ old\ game.\n\ \ \ A\ strategy\ game\ can\ be\ cobbled\ from\n\ \ \ older\ scraps\ of\ Iching\ code.\n\ \ \ Using\ the\ Iching\ code,\ this\ page\n\ \ \ presents\ a\ trial\ console\ version\n\ \ \ for\ testing\ the\ concept,\ \n\ \ \ a\ console\ version,\ and\ \ \n\ \ \ a\ canvas\ version\ with\ some\ graphics,\n\ \ \ The\ Iching\ has\ a\ good\ handle\ on\ the\n\ \ \ actions\ of\ an\ ancient\ kingdom,\ though\n\ \ \ in\ a\ random\ scattered\ pattern.\n\ \ \ The\ elements\ in\ most\ adventure\n\ \ \ games\ are\ random\ generators,\n\ \ \ castles,\ tiled\ game\ boards,\ mazes,\ wildcards,\n\ \ \ gamepieces,\ and\ strategy\ situation.\n\ \ \ \n\ \ \ \ \ \ \ \ \n----\n\ \ \ \ \ \ The\ canvas\ and\ buttons\ presented\ here\n\ are\ largely\ based\ on\ the\ \n\ Simple\ Canvas\ Demo\ by\ \[HJG\].\n\ See\ http://wiki.tcl.tk/15073\ \ \ \n\ The\ random\ pick\ algorithm\ was\ posted\ by\ Suchenworth\ \[RS\]\n\ on\ Horseracing\ in\ Tcl,http://wiki.tcl.tk/3467.\n\ \ Another\ source\ of\ randomness\ was\n\ \ \ A\ funny\ cookbook,http://wiki.tcl.tk/9213\n\ \n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n----\n\ \ \ \ \ \ \ \n\ \ \ \ \ \ In\ pseudocode,\ the\ text\ adventure\ game\n\ \ is\ essentially\ a\ three\ line\ program\n\ \ in\ the\ old\ style\ unix\ wish.\ In\ etcl\ and\n\ \ windows,\ some\ buffering\ may\ be\ necessary.\n\ \ One\ display\ for\ response\ and\ one\ display\ for\n\ \ input\ would\ be\ easier\ in\ windows.\ \n\ \ \ \ \n\ \ \ \ 1)puts\ stdout\ \"Please\ enter\ your\ name:\"\n\ \ \ \ \ \ \ \ 2)gets\ stdin\ \ name\n\ \ \ \ \ \ \ \ \ \ \ \ \ 3)puts\ stdout\ \"Hello\ \$name\"\n\ \ \ \ \ \n\ \ \ \ \ pseudocode.The\ user\ is\ directed\ into\ various\ possibilities.\ \n\ \ \ 2)\ 3)\ and\ 4)\ are\ looped.\n\ \ \ \ \ \ console\ show\ \ \n\ \ \ \ \ 1)puts\ stdout\ \"Please\ enter\ your\ name:\"\n\ \ \ \ \ 2)gets\ stdin\ \ \ \n\ \ \ \ \ pseudocode:\ analyze\ name\ and\ internal-references\n\ \ \ \ \ pseudocode\ :\ set\ random\ situation.\n\ \ \ \ \ pseudocode\ :\ game\ closes\ after\ 5\ trials\ or\ 5\ situations.\n\ \ \ \ \ 3)puts\ stdout\ \"action\ \$name\"\n\ \ \ \ \ 4)\ \ pseudocode.\ \ \ \ \ \ return\ to\ 2)\ stdin\ \n\ \ \ \ \n\ \ \ \ \ \n\ ----\ \n\ ----\n\ \ \ \ \ \n\ \ \ \n\n\ \n----\n\ \ \ \ \ \ \ \n----\n\ \ \ \ \ In\ the\ trial\ deck\ for\ console,\n\ \ \ \ \ the\ advisor\ would\ present\ the\ situation\n\ \ \ \ \ and\ the\ king's\ responses\ would\ have\ to\n\ \ \ \ \ be\ a\ table\ of\ abbreviated\ commands,\n\ \ \ \ \ like\ buy\ 200\ ,\ sell\ 300\ ,\ .\n\ \ \ \ \ Otherwise,\ there\ would\ be\ a\ lot\ difficult\ \n\ \ \ \ \ parsing,\ like\ the\ human\ language\ command\n\ \ \ \ \ of\ computers.\ The\ trial\ deck\ could\n\ \ \ \ \ call\ the\ procedure\ \"advisor\"\ to\ present\ \n\ \ \ \ \ the\ situation\ derived\ from\ random\ circumstances.\n\ \ \ \ \ The\ trial\ deck\ \n\ \ \ \ \ could\ call\ the\ procedure\ \"king\",\ so\n\ \ \ \ \ the\ command\ on\ the\ console\ window\ \n\ \ \ \ \ would\ be\ king\ sell\ 20\ or\n\ \ \ \ \ king\ buy\ 50.\ This\ have\ the\ advantage\ \n\ \ \ \ \ of\ looking\ as\ a\ typical\ English\ sentence:\n\ \ \ \ \ subject\ verb\ object.\ In\ a\ loop,\ the\n\ \ \ \ \ king\ procedure\ calls\ on\ the\ advisor\ procedure,\n\ \ \ \ \ which\ presents\ a\ new\ situation.\n\ \ \ \ \ The\ king\ wins\ or\ loses\ based\ on\ his\ responses\n\ \ \ \ \ to\ the\ random\ situation.\ The\ game\ can\ be\n\ \ \ \ \ closed\ after\ a\ certain\ number\ of\ situation\n\ \ \ \ \ trials\ by\ a\ limiting\ statement\ in\ the\ advisor\n\ \ \ \ \ procedure.\ The\ major\ subroutines\ or\ procedures\n\ \ \ \ \ were\ diagramed\ with\ TKpaint\ in\ the\ flowchart\ below.\n\ \ \ \ \ Those\ interested\ in\ flowcharting\ programs\ should\n\ \ \ \ \ be\ able\ to\ load\ the\ flowchart\ file\ into\ TKpaint\n\ \ \ \ \ or\ else\ load\ the\ file\ into\ eTCL\ with\ a\ few\n\ \ \ \ \ canvas\ display\ statements.\n\n\ \ \ \ \ \n----\n\ \ session\ \ \ from\ trial\ console\ script\n\ \ \ \ buy\ or\ sell,\ my\ lord?\ \n\ \ \ \ starts\ with\ 1000\ units\ \n\ \ \ \ answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \n\ \ \ 1%\ king\ buy\ 20\n\ \ \ \ decision\ was\ buy\ 20,\ total\ was\ 1020.0\ \n\ \n\ \ \ advisor:\ \ new\ situation\ \n\ \ \ need\ 10\ liters\ of\ grain.\n\ \ \ need\ 60\ hectares\ of\ land.\n\ \ \ predict\ rain.\n\ \ \ subjects\ from\ census\ 5000.\ \n\n\ \ \ \ advisor:\ buy\ or\ sell,\ my\ lord?\ \n\ \ \ \ 2%\ king\ sell\ 500\n\ \ \ \ decision\ was\ sell\ 500,\ total\ was\ 520.0\ \n\ \n\ \ \ \ advisor:\ \ new\ situation\ \n\ \ \ need\ 10\ liters\ of\ grain.\n\ \ \ need\ 100\ hectares\ of\ land.\n\ \ \ predict\ cold.\n\ \ \ subjects\ from\ census\ 3000.\ \n\n\ \ \ \ \ advisor:\ buy\ or\ sell,\ my\ lord?\ \n----\n\n----\n**\ canvas\ button\ operation\ \n\ \ \ \ \ So\ the\ order\ of\ button\ actions\ should\ be:\n\ \ \ \ \ push\ castle\n\ \ \ \ \ push\ situation,\ read\ advisors'\ comment\n\ \ \ \ \ type\ in\ king's\ responce\ in\ upper\ entry\ field\n\ \ \ \ \ push\ console\n\ \ \ \ \ push\ record,\ should\ see\ record\ of\ play\ on\ console.\n\ \ \ \ %quit\ day\ job\n\ \ \ \ %\{advisor:buy\ or\ sell,\ my\ lord?\}\ \{king:get\ lost\}\n\ \ \ \ \ \ \ \ \ note:\ pass\ or\ veto\ should\ be\ option\n\ \ \ \ clear\ to\ resume\ play\n\ \ \ \ \ \n\n\ \ \ \ Commands\ from\ the\ king\ on\ the\ eTCL\ console\ \ \n\ \ \ \ or\ commands\ in\ the\ king\ entry\ field\ (canvas)\n\ \ \ \ vary\ on\ versions,\ but\ here\ are\ some\ samples.\n\ \ \ \ \ \ initial\ land\ is\ 1000\ barleyfields\n\ \ \ \ \ \ initial\ barley\ is\ 1000\ measures\n\ \ \ \ \ \ king\ buy\ 22\n\ \ \ \ \ \ king\ sell\ 100\n\ \ \ \ \ \ \ else\ \n\ \ \ \ \ \ king\ buy\ 100\ land\n\ \ \ \ \ \ king\ sell\ 33\ land\n\ \ \ \ \ \ king\ buy\ 222\ barley\n\ \ \ \ \ \ king\ sell\ 33\ barley\n\ \ \ \ conditions\ for\ winner\ are\ very\ liberal.\n\ \ \ \ pseudocode:\ game\ is\ halted\ after\ 5\ trials,\ count\ >\ 5,\n\ \ \ \ and\ estimate\ if\ (winner)\ conditions\ prevail.\n\ \ \ \ pseudocode:\ \ if\ barleyfields\ >\ 500\ ,\ winner\ declared\n\ \ \ \ pseudocode:\ \ if\ barley\ \ >\ 500\ winner\ declared\n\ \ \ \ pseudocode:\ \ clear\ resets\ counter\ to\ zero\n\ \ \ \ pseudocode:\ \ clear\ zeros\ king\ &\ advisor\ entry\ fields,\ \n\ \ \ \ pseudocode:\ \ &\ zeros\ canvas\n\n\ \ \ \ \ \n\ \ \ \ Note.\ On\ 27Jul2010,\ there\ was\ a\ challenge\ posted\ on\n\ \ \ converting\ Hamurabi.bas\ to\ \"modern\"\ computer\ language.\n\ \ \ The\ turn-around\ from\ other\ languages\ (not\ me!)\ is\ fairly\n\ \ \ impressive.\ There\ was\ a\ Lua\ program\ posted\ on\ 28Jul2010,\n\ \ \ Java\ on\ 28Jul2010,\n\ \ \ common\ Lisp\ program\ on\ 31Jul210,\ and\ Factor\ program\ by\ 3Aug2010.\ \ \ \n\ \ \ The\ original\ basic\ code\ was\ fairly\ terse,\ so\n\ \ \ there\ has\ been\ some\ real\ hoofing\ on\ the\ contributions.\n\ \ \ As\ a\ fortran\ programmer,\ I\ remember\ basic\ envy\n\ \ \ on\ the\ basic\ string\ addition,\ let\ it\$\ =\ \"be\"+\"so\"\n----\ \ \ \n\ \ \ Note:\ Quite\ possible\ to\ add\ the\ Eliza\ namespace\ \n\ \ \ to\ the\ game.\ This\ will\ get\ some\ context\ sensitive\n\ \ \ analysis/quirks\ \ into\ the\ game.\ \n\ \ \ Refer\ to\ A\ simple\ version\ of\ Eliza,\n\ \ \ http://wiki.tcl.tk/9235.\n\ \ \ \ \n\ \ \ \ \ \ Console:\ \ king\ sell\ 11\ barley\ \n\ \ \ \ \ 1%\ ::Talk::replyto\ \{\ barley\ \}\n\ \ \ \ \ \ advisor\ says\ :\ Shall\ we\ continue?\ \n\ \ \ \ \ 2%\ ::Talk::replyto\ \{\ king\ sell\ barley\ \}\n\ \ \ \ \ \ \ advisor\ says\ worried\ about\ total\ \ barleyfields.\ ?\ \n\ \ \ \ \ 3%\ ::Talk::replyto\ \{\ king\ sell\ 11\ barley\ \}\n\ \ \ \ \ \ \ advisor\ says\ :\ worried\ about\ total\ barleyfields.\ ?\ \n\ \ \ \ \ 4%\ king\ sell\ 11\ barley\n\ \ \ \ \ decision\ was\ sell\ 11,\ total\ was\ \ \ land\ 1000,\ barley\ 989.0\ \n\ \ \ \ \ \ \ \n\ \ \ \ \ \ \ \ \ \ \ \n----\n**Screenshots\ Section**\n\n\[http://farm5.static.flickr.com/4122/4866853039_0a6798b1f8.jpg\]\n\ \n\n\n\[http://farm5.static.flickr.com/4120/4854141292_07b57692b7.jpg\]\n\n\n\[http://farm5.static.flickr.com/4096/4857240469_6d23f1b62c.jpg\]\ \n\n\n\n----\n**Comments\ Section**\n\ \ \ \ \ \ \ \ \ Please\ place\ any\ comments\ here,\ Thanks.\n\n\[gold\]\ Changes.\n\n----\n**References**\n\n\ \ \ *\ \[Simple\ Canvas\ Demo\]\n\ \ \n\ \ \ http://wiki.tcl.tk/14617\n\n\ \ \ \ Ideas\ for\ Projects\ in\ Tcl/Tk\n\ \ \ \ http://wiki.tcl.tk/14335\n\n\n\ \ \ \ A\ funny\ cookbook\n\ \ \ \ http://wiki.tcl.tk/7801\n\ \ \ \ Tkpaint\n\ \ \ \ http://mars.netanya.ac.il/~samy/tkpaint.html\n\ \ \ \ \ \n\ \ \ \ http://wiki.tcl.tk/9213\n\ \ \ \ The\ older\ tkpaint\ \ 1.5\ executable\ that\ I\ used\ was\ loaded\ here.\n\ \ \ \ \ ftp://ftp.procplace.com/pub/tcl/sorted/packages-8.0/graphics/tkpaint/1.51/TKPAINT-1.5.3.TAR.GZ\n\ \ \ \ \ ftp://ftp.procplace.com/pub/tcl/sorted/packages-8.0/graphics/tkpaint/1.52/tkpaint.zip\n\n\n\n\n\ \ \ \ http://en.wikipedia.org/wiki/Hamurabi\n\n\ \ \ \ http://www.dunnington.u-net.com/public/basicgames/HMRABI\n\n\ \ \ \ http://www.apollowebworks.com/russell/samples/hamurabi.html\n\n\n\n\ \ \ \ http://www.cse.lehigh.edu/~munoz/ComputerGameDesignClass/classes/GameTheory.pptx.\n\ \ \ \ http://en.wikipedia.org/wiki/Hamurabihttp://en.wikipedia.org/wiki/List_of_games_in_game_theory\n\ \ \ \ http://en.wikipedia.org/wiki/Game_theory\n\ \ \ \ http://www.dallasuu.org/re/adult/huumanist/TitTatSagan.pdf\n\ \ \ \ http://en.wikipedia.org/wiki/Dictator_game\n\n\ \ \ \ http://www.hammurabigame.com/hammurabi-game.php\n\n\ \ \ \ http://www.codeproject.com/KB/game/Hammurabi.aspx\n\n\n\n\ \ \ \ http://www.esajournals.org/doi/abs/10.1890/1540-9295(2003)001%5B0367%3AMRAPTB%5D2.0.CO%3B2\n\ \ \ \ http://ipsnews.net/fao_magazine/indian.shtml\n\ \ \ \ http://biology.clc.uc.edu/courses/bio104/sci_meth.htm\n\ \ \ \ http://programmingpraxis.com/2010/07/27/hamurabi-bas/\n\ \ \ \ http://www.pbs.org/wgbh/nova/nature/plant-vs-predator.html\n\ \ \ \ http://lisp.pastebin.com/r1gL4zYT\n\ \ \ \ http://codepad.org/pc8FSfnQ\n\ \ \ \ http://www.econ.umn.edu/~foster/Handouts%20Games.pdf\n\ \ \ \ http://re-factor.blogspot.com/2010/08/hamurabi.html\n\n\n\ \ \ \ http://www.moorecad.com/classicbasic/basic/creative/hamurabi.bas\n\ \ \ \ http://www.cis.upenn.edu/~matuszek/cit590-2010/Assignments/02-hammurabi.html\n\ \ \ \ \ http://playtechs.blogspot.com/2009/06/charlemagne-disraeli-and-jefferson.html\n\ \ \ \ \ http://www.econ.cam.ac.uk/seminars/Marshall_Lecture/09/marshall_lecture_2_Oct_21.pdf\n\ \ \ \ \ http://roseindia.net/java/java-tips/oop/q-hammurabi/q-pr-hammurabi-1.shtml\n\ \ \ \ http://en.wikipedia.org/wiki/Hammurabi\n**appendix\ TCL\ programs**\n\n----\n\ \ #start\n\ \ #start\n\ \ #start\n\ \ #start\n\ \ #:by\ gold,\ \ \ trial\ console\ operation\n\n\ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ if\ 0\ \{This\ is\ used\ several\ times\ in:\}\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ liters\ of\ grains\}\ \{20\ liters\ of\ grain\}\ \{10\ liters\ of\ grain\}\n\ \ \ \ \ \{10\ liters\ of\ grain\}\ \{50\ liters\ of\ grain\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ hectares\ of\ land\}\ \{60\ hectares\ of\ land\}\ \{50\ hectares\ of\ land\}\n\ \ \ \ \ \{100\ hectares\ of\ land\}\ \{20\ hectares\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 1000\}\ \{census\ 3000\}\ \{census\ 2000\}\ \{census\ 5000\}\ \{census\ 8000\}\ \{census\ 4000\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \\n\"\n\ \ \ \ \ \}\n\ \ set\ sumit\ 1000\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ \}\ \{\n\ \ global\ sumit\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ set\ sumit\ \[\ expr\ \{\ \$sumit\ +\ \$token\ \}\ \]\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \$sumit\ \"\n\ \ advisorx\ 50\ 50\ \ \ \n\ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ \"\n\ \ \ puts\ \"answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \"\n\n\n\n\ \ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\n\ \ \ \ \ \ #end\ of\ deck\ \n\n----\n\ \n***FIRST\ VERSION***\ \n\n======\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \ \n\ \ \ \ \ \ \ \ #start\ of\ deck\n\n\n\ #:by\ gold,\ \ \ Game\ kingdom\ of\ strategy\n\n\ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\ \ \n\ \ package\ require\ Tk\n\ \ \ \ \ \n\ \ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ \ \ \ if\ 0\ \{This\ is\ used\ several\ times\ in:\}\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ measures\ of\ barleys\}\ \{20\ measures\ of\ barley\}\ \{10\ measures\ of\ barley\}\n\ \ \ \ \ \{10\ measures\ of\ barley\}\ \{50\ measures\ of\ barley\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ barleyfields\ of\ land\}\ \{60\ barleyfields\ of\ land\}\ \{50\ barleyfields\ of\ land\}\n\ \ \ \ \ \{100\ barleyfields\ of\ land\}\ \{20\ barleyfields\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 99\}\ \{census\ 100\}\ \{census\ 120\}\ \{census\ 110\}\ \{census\ 120\}\ \{census\ 80\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \ \n\ \ \ ans.form:king\ buy\ 20\ land\ \ \\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ \}\n\ \ \ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ #proc\ poly\ args\ \{eval\ .cv\ create\ polygon\ \$args\}\n\ \ \ \ set\ lister\ \{\ 5\ 5\ 6\ 6\ 6\ 6\ 6\ 6\ 7\ 7\ 7\ 7\ 8\ 8\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ \}\n\ \ \ \ proc\ transnumber\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \\u3024\}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \\u4E00\}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \\u3024\}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\ \ \n\ \ set\ loser5\ 0\n\ \ set\ counter\ 0\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\ \ proc\ winnerx\ \{aa\ bb\}\ \{\n\ \ global\ sumit\ sumitland\ sumitbarley\n\ \ global\ sumarians\ liters\ winner5\n\ \ global\ loser5\n\ \ puts\ \"\ \ \ end\ of\ game\ \ \"\n\ \ .zzz\ delete\ 0\ end\n\ \ .xxx\ delete\ 0\ end\n\ \ .t\ delete\ 1.0\ end\n\ \ .t\ insert\ 1.0\ \"\ \ end\ of\ game\ \ \"\n\ \ .zzz\ insert\ 0\ \"\ \ end\ of\ game\ \ \"\n\ \ .xxx\ insert\ 0\ \"\ \ end\ of\ game\ \ \"\n\ \ \ if\ \{\ \$sumarians\ >=\ 120\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"\ king\ is\ winner\ declared\ \"\n\ \ .xxx\ insert\ 0\ \"\ king\ is\ winner\ declared\ \"\n\ \ .t\ insert\ 1.0\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitland\ >=\ 700\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"king\ is\ winner\ declared\"\n\ \ .xxx\ insert\ 0\ \"king\ is\ winner\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"king\ is\ winner\ declared\"\n\ \ \ puts\ \"king\ is\ winner\ declared\"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \n\ \ if\ \{\ \$sumarians\ <=\ 40\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"loser\ declared\"\n\ \ .xxx\ insert\ 0\ \"loser\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"loser\ declared\"\n\ \ \ puts\ \"loser\ declared\"\n\ \ \ \ set\ loser5\ 1\n\ \ \}\n\n\ \ \ if\ \{\ \$sumitbarley\ <=\ 300\ \}\ \{\n\ \ .zzz\ insert\ 0\ \"loser\ declared\"\n\ \ .xxx\ insert\ 0\ \"loser\ declared\"\n\ \ \ .t\ insert\ 1.0\ \"loser\ declared\"\n\ \ \ puts\ \"loser\ declared\"\n\ \ set\ loser5\ 1\n\ \ \}\n\ \ \}\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ \ \ global\ counter\n\ \ if\ \{\ \$counter\ >=\ 5\ \}\ \{winnerx\ \$aa\ \$bb\ \}\n\ \ .t\ delete\ 1.0\ end\ \ \n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ if\ \{\ \$counter\ <=\ 6\ \}\ \{\ \n\ \ \ \ \ .t\ insert\ 1.0\ \[\ tidings\ \]\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ set\ bl\ \"\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ .zzz\ insert\ \ end\ \"advisor:buy\ or\ sell,\ my\ lord?\ \$bl\ \\(for\ year\ \$counter\ \\)\"\n\ \ \ \ \}\ \n\ \ \n\ \ \ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ \n\ \ \ \ \ .t\ delete\ 1.0\ end\ \}\ \n\n\ \ \n\ \ \ puts\ \ \[.t\ get\ 1.0\ end\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \\(for\ year\ \$counter\ \\)\ \"\n\ \ \ incr\ counter\n\ \ \}\n\n\ \ \ \n\ set\ sumarians\ \ 100\n\n\ \ proc\ calculation\ \{\ aa\ bb\ cc\ dd\ ee\ \}\ \{\n\ \ global\ counter\ fieldsdisplay\n\ \ global\ \ sumitland\ sumitbarley\ \n\ \ global\ \ buyland\ \ buybarley\ sumarians\n\ \ set\ annum\ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ set\ provisions\ \ \ \ 1000\ \ \ \ \ \ \ \ \n\ \ set\ liters\ 5000\ \ \ \n\ \ set\ land\ \ \ \ 1000\ \ \ \ \ \ \n\ \ set\ barleyfields\ \ \ 1000\n\ \ set\ landprice\ 26\n\ \ set\ litersperacre\ \ 3\ \n\ \ set\ totalmortality\ \ \ 10\n\ \ set\ mortalrateer\ \ 10\ \n\ \ set\ ratliters\ 1\n\ \ set\ citymortal\ 5\n\ \ set\ landfraction\ .1\n\ \ set\ sumariansgain\ 5\n\ \ set\ produce\ 4\n\ \ set\ buyland\ 1\n\ \ set\ buybarley\ 1\n\ \ set\ plaguethisyear\ 0\n\ \ set\ ratinfestthisyear\ 0\n\ \ set\ famineyear\ 0\n\ \ set\ immigrantyear\ 0\n\ \ set\ fieldsdisplay\ 20\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ immigrantyear\ \ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ plaguethisyear\ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .41\ \}\ \{set\ ratinfestthisyear\ 1\ \}\n\ \ set\ ratliters\ \ \[\ expr\ \{\ \$liters*.1*rand()\ \ \ \}\ \]\n\ \ set\ ratliters\ \[\ expr\ \{\ int(\$ratliters)\ \}\ \]\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ \$sumarians*.02*rand()\ \ \ \}\ \]\n\ \ set\ landfraction\ \ \[\ expr\ \{\ \ \ rand()\ \}\ \]\ \n\ \ if\ \{\ \$immigrantyear\ ==\ 1\ \}\ \{\n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ \$sumarians\ \ *\ .05\ \}\ \]\ \}\ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ int(\$sumariansgain)\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ \$sumarians\ +\ \$sumariansgain\ \ \ \}\ \]\n\ \ set\ produce\ \[\ expr\ \{\ \ \$land\ *\ 3\ \}\ \]\n\ \ set\ landprice\ \[\ lpick\ \{\ 26\ 25\ 24\ 23\ 22\ 21\ 20\ 19\ 18\ 17\ 16\ \}\ \]\ \n\ \ set\ landprice\ \[\ expr\ \{\ int(\$landprice)\ \}\ \]\ \n\ \ set\ liters\ \$sumitbarley\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ +\ \$sumitland*.8\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$landprice*\ \$buyland\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$sumarians*\ 7\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$liters*.1*\$ratinfestthisyear\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ int(\$liters)\ \}\ \]\ \n\ \ set\ foodrequire\ \[\ expr\ \{\$sumarians*7\ \}\]\n\ \ if\ \{\ \ \ \$liters\ <=\ \$foodrequire\ \ \ \}\ \{\n\ \ set\ sumariansstarved\ \[expr\ \{\$sumarians*.2\ \ \}\ \]\ \n\ \ set\ famineyear\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ int(\$sumariansstarved)\ \ \}\ \]\n\ \ set\ sumitbarley\ \$liters\n\ \ set\ sumitland\ \ \[\ expr\ \{\ int(\$sumitland)\ \ \}\ \]\n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ +\ \$sumarians*.1\ -\$sumariansstarved\}\ \]\ \n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ -\ \$sumarians*.5*\$plaguethisyear\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ int(\$sumarians)\ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ (\$sumitland/1000.)*100.\ \ \ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ int(\$percentfields)\ \}\ \]\n\ \ set\ fieldsdisplay\ \[\ expr\ \{\ 35*\$percentfields*.01\ \}\ \]\n\ \ \ set\ fieldsdisplay\ \[\ expr\ \{int(\$fieldsdisplay)\ \ \}\ \]\n\ \ if\ \{\ \ \$fieldsdisplay\ <=\ 1\ \ \ \}\ \{\ set\ fieldsdisplay\ 1\ \}\n\ \ if\ \{\ \ \$fieldsdisplay\ >=\ 35\ \ \ \}\ \{\ set\ fieldsdisplay\ 35\ \}\n\ \ .cv\ delete\ landbarley\n\ \ barley\ .cv\ \$fieldsdisplay\n\ \ puts\ \ \"annum\ \$counter\ \"\n\ \ puts\ \ \"\$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \"\n\ \ puts\ \ \"\$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\"\n\ \ puts\ \"\$percentfields\ percent\ fields\ \"\n\ \ puts\ \"\ \$fieldsdisplay\ \ fieldsdisplay\ \"\n\ \ puts\ \"\$sumariansstarved\ sumarians\ starved\"\n\ \ puts\ \"\$sumariansgain\ immigrated\ to\ city.\"\n\ \ puts\ \"census\ \$sumarians\ \ \"\n\ \ puts\ \"total\ \ \$sumitland\ barleyfields.\"\n\ \ puts\ \"yielded\ 3\ measures\ per\ barleyfield\"\n\ \ puts\ \"rats\ devoured\ \$ratliters\ measures.\"\n\ \ puts\ \ \"\$liters\ \ measures\ in\ palace.\"\n\ \ puts\ \"land\ \$landprice\ measures\ per\ barleyfield\"\n\ \ puts\ \"how\ many\ barleyfields\ do\ you\ wish\ to\ buy?\"\ \n\ \ set\ listx\ \ \"\n\ \ \ \ \ \ \ annum\ \$counter,\ \ \ \$liters\ \ measures\ \ \ \n\ \ \ \ \ \ \ census\ \$sumarians,\ \ \$sumitland\ barleyfields.\ \ \ \n\ \ \ \ \ \ \ \$landprice\ landprice\ measures\n\ \ \ \ \ \ \$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$famineyear\ \ famineyear\ ,0\ or\ 1\n\ \ \ \ \ \ \ \$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$sumariansstarved\ sumarians\ starved\ \n\ \ \ \ \ \ \$sumariansgain\ immigrated\ to\ city.\ \n\ \ \ \ \ \ census\ \$sumarians\ \ \ \n\ \ \ \ \ \ total\ \ \$sumitland\ barleyfields.\ \n\ \ \ \ \ \ yielded\ 3\ measures\ per\ barleyfield\ \n\ \ \ \ \ \ rats\ devoured\ \$ratliters\ measures.\ \n\ \ \ \ \ \ \ \$liters\ \ measures\ in\ palace.\ \n\ \ \ \ \ \ land\ \$landprice\ measures\ per\ barleyfield\ \"\n\ \ \ \ \ \ return\ \"\ \$listx\ \"\n\n\n\ \ \}\n\n\ \ \n\ \ proc\ king\ \{\ aa\ bb\ cc\}\ \{\n\ \ global\ \ sumitland\ sumitbarley\ \n\ \ global\ buyland\ buybarley\n\ \ global\ counter\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ sumitland\ \[\ expr\ \{\ \$sumitland\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ sumitbarley\ \[\ expr\ \{\ \$sumitbarley\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ buyland\ \ \$token\ \ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ buybarley\ \ \$token\ \ \}\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \ land\ \$sumitland,\ barley\ \$sumitbarley\ \"\n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ \n\ \ advisorx\ 50\ 50\n\n\ \ \n\ \ \}\n\ \ \ \ set\ listx\ \[\ transnumber\ \$lister\ \]\n\ \ \ \ proc\ tactics\ \ \{w\}\ \{\n\ \ \ \ global\ listx\n\ \ \ \ set\ yy\ 100\n\ \ \ \ set\ font3\ \{Hevetica\ 20\}\n\ \ \ \ set\ font5\ \{Hevetica\ 150\}\n\ \ \ \ set\ lister\ \{\ 5\ 5\ 6\ 6\ 6\ 6\ 6\ 6\ 7\ 7\ 7\ 7\ 8\ 8\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ 1\ \}\n\ \ \ \ \$w\ create\ rect\ 150\ 50\ 250\ 400\ -fill\ gold\ \n\ \ \ \ \$w\ create\ polygon\ \ -80\ 100\ \ -80\ 70\ \ -50\ 70\ \ -20\ -10\ \ -40\ -50\ \ -20\ -100\ \ 20\ -100\ \ 40\ -50\ \ 20\ -10\ \ 50\ 70\ \ 80\ 70\ \ 80\ 100\ -fill\ gold\ -tags\ figure\n\ \ \ \ \$w\ move\ figure\ 150\ 150\n\ \ \ \ #\ \$w\ create\ text\ 200\ 400\ -text\ \\u2617\ \ -tags\ \"text\"\ -fill\ tan\ -font\ \$font5\n\ \ \ \ foreach\ i\ \{1\ 2\ 3\ 4\ 5\ 6\ \}\ \{\n\ \ \ \ \$w\ create\ text\ 200\ \$yy\ -text\ \[lpick\ \$listx\ \]\ \ -tags\ \"text\"\ \ -font\ \$font3\n\ \ \ \ incr\ yy\ 50\n\ \ \ \ \}\n\ \ \ \ \}\n\n\n\n\n\n\n\n\n\ \ \ \ \ \ proc\ clrcanvas\ \{w\}\ \{\n\ \ \ \ global\ counter\ winner5\n\ \ \ \$w\ delete\ \ \"all\"\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ .xxx\ delete\ \ 0\ end\ \ \n\ \ \ .t\ delete\ 1.0\ end\n\ \ \ \ set\ counter\ 0\n\ \ \ \ set\ winner5\ 0\n\ \ \ \ set\ loser5\ 0\n\ \ \}\n\n\ \n\ \ proc\ leave\ \{w\}\ \{\n\ \ \ \ \ exit\n\ \ \}\n\n\ \ \ proc\ board\ \{w\}\ \{\n\ \ \ \ #set\ state3\ 1\n\ \ \ \ set\ state2\ 1\n\ \ \ \ clrcanvas\ \$w\n\ \ \ \ .\ configure\ -background\ orange\ -highlightcolor\ brown\ -relief\ raised\ -border\ 30\n\ \ \ \ \$w\ configure\ -bg\ tan\n\ \ \ \ \ \n\ \ \ \ \}\n\ \ \n\ \ \ proc\ \ replyit\ \{w\}\ \{\n\ \ \ \ global\ counter\n\ \ \ .t\ delete\ 1.0\ end\n\ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ .xxx\ delete\ \ 0\ end\ \ \n\ \ \ .zzz\ insert\ \ end\ \"advisor:buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ .xxx\ insert\ \ end\ \"king\ \"\n\ \ \ \}\n\n\n\n\n\ \ \ \ set\ keeperer\ \{\ 1\ 2\ 3\ \}\n\ \ \ \ proc\ \ record\ \{w\}\ \{\n\ \ \ \ \ global\ side2\ side1\ buy\ sell\ \n\ \ \ \ \ global\ winner5\ loser5\n\ \ \ \ \ \ \n\ \ \ lappend\ keeperer\ \$side2\n\ \ \ lappend\ keeperer\ \$side1\n\ \ \ puts\ \$keeperer\n\ \ \ eval\ \[\ split\ \ \$side1\ \"\ \"\ \]\n\ \ \ \n\ \ \ set\ results\ \ \[\ calculation\ 10\ 10\ 10\ 10\ 10\ \]\n\ \ \ puts\ \$results\n\ \ \ \n\ \ \ \ .t\ delete\ 1.0\ end\n\ \ \ \ .t\ insert\ 1.0\ \$results\n\ \ \ \ .zzz\ delete\ \ 0\ end\ \ \n\ \ \ \ .zzz\ insert\ \ end\ \"advisor\ says:\ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\"\n\ \ \ \ if\ \{\ \$winner5\ ==\ 1\}\ \{\n\ \ \ \ .zzz\ delete\ \ 0\ end\ \n\ \ \ \ .zzz\ insert\ \ end\ \"advisor\ says:\ king\ is\ winner\ \"\ \}\n\ \ \ \n\ \ \ \ \ \}\n\n\ \ \ proc\ \ reportx\ \{w\}\ \{\n\ \ \ console\ show\n\ \ \ \ puts\ \"fifth\ rate\"\n\ \ \ \ puts\ \"performance\ comparable\ to\ bonzo\"\n\ \ \ \ puts\ \"surving\ inhabitants\ have\ fled\"\n\ \ \ \ puts\ \"mandated\ poll\ results\"\n\ \ \ \ puts\ \"lacking\ any\ sense\"\n\ \ \ \ puts\ \"second\ rate\"\;\n\ \ \ \ puts\ \"no\ bread\ left\"\n\ \ \ \ puts\ \"third\ rate\"\n\ \ \ \ puts\ \"quit\ day\ job\"\n\ \ \ \}\n\n\ \ \ \ proc\ castle\ \{w\}\ \{\n\ \ \ \ \ \ global\ dx\ dy\ fieldsdisplay\n\ \ \ \ \ \ set\ dx\ 50\n\ \ \ \ \ \ set\ dy\ 30\n\ \ \ \ \ \ set\ gualisting\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ second_hexagram\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ colorx\ black\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 20\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ brown\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 50\}\ \{\$j<3\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ brown\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ tan\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ brown\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ tan\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ brown\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \$x\ \$y\ \[expr\ \{\$x+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dx\ 50\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dy\ 30\n\ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 20\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 50\}\ \{\$j<3\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ tan\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ blue\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ tan\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ blue\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \[expr\ \$x\ +\ 180\]\ \$y\ \[expr\ \{\[expr\ \$x\ +180\ \]+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\n\ \ \ \ \ \}\n\ \ \ \n\ \ \ proc\ barley\ \{w\ fieldsdisplay\ \}\ \{\n\ \ \ \ \ \ global\ dx\ dy\ \n\ \ \ \ \ \ set\ dx\ 5\n\ \ \ \ \ \ set\ dy\ 10\n\ \ \ \ \ \ set\ gualisting\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ second_hexagram\ \{\ 8\ 8\ 8\ 8\ 8\ 7\ \}\n\ \ \ \ \ \ set\ colorx\ black\;\n\ \ \ \ \ \ \$w\ delete\ landbarley\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 220\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 30\}\ \{\$j<\$fieldsdisplay\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ green\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$gualisting\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \$x\ \$y\ \[expr\ \{\$x+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\ -tag\ landbarley\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dx\ 5\n\ \ \ \ \ \ \ \ \ \ \ \ set\ dy\ 10\n\ \ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ for\ \{set\ i\ 0\;\ set\ y\ 220\}\ \{\$i<6\}\ \{incr\ i\;\ incr\ y\ \$dy\}\ \{\n\ \ \ \ \ \ \ \ \ \ \ set\ colorx\ blue\;\n\ \ \ \ \ \ \ for\ \{set\ j\ 0\;\ set\ x\ 30\}\ \{\$j<\$fieldsdisplay\}\ \{incr\ j\;\ incr\ x\ \$dx\}\ \{\n\ \ \ \ \ \ \ \ \ set\ colorx\ green\;\n\ \ \ \ \ \ \ \ \ if\ \{\ \$j\ ==\ 1\}\ \{\n\ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 6\}\ \{set\ colorx\ green\}\n\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 7\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 8\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ if\ \{\ \[lindex\ \$second_hexagram\ \$i\ \]\ ==\ 9\}\ \{set\ colorx\ green\}\n\ \ \ \ \ \ \ \ \ \}\n\n\ \ \ \ \ \ \ \ \ \ \$w\ create\ rectangle\ \[expr\ \$x\ +\ 180\]\ \$y\ \[expr\ \{\[expr\ \$x\ +180\ \]+\$dx\}\]\ \[expr\ \{\$y+\$dy\}\]\ \\\n\ \ \ \ \ \ \ \ \ \ \ \ -fill\ \$colorx\ -tag\ landbarley\n\n\ \ \ \ \ \ \ \ \ \ \}\}\n\n\ \ \ \ \ \}\n\n\n\ \ \ \ proc\ about\ \{w\}\ \{\n\ \ \ \ set\ msg\ \"Game\ kingdom\ of\ strategy.\n\ \ \ \ \ \ \ \ \ \ from\ TCL\ WIKI,\n\ \ \ \ \ \ \ \ \ \ written\ on\ eTCL\n\ \ \ cmds\ take\ form\n\ \ \ king\ buy\ 33\ land\n\ \ \ king\ sell\ 11\ land\n\ \ \ king\ sell\ 55\ barley\n\ \ \ king\ buy\ 33\ barley\ \"\n\ \ \ \ \n\ \ \ \ tk_messageBox\ -title\ \"About\"\ -message\ \$msg\n\ \ \ \ \}\n\n\ \ #:\ Main\ :\n\ \ frame\ .f1\n\ \ frame\ .f2\n\ \ frame\ .f3\n\ \ pack\ \ .f1\ .f2\ .f3\n\n\ \ set\ maxX\ 400\n\ \ set\ maxY\ 300\n\ \ set\ y\ \ \ \ \ \ 0\n\n\ \ set\ x1\ 120\n\ \ set\ x2\ 150\n\ \ set\ y1\ \ 50\n\ \ set\ y2\ \ 80\n\n\ \ canvas\ \ .cv\ -width\ \$maxX\ -height\ \$maxY\ \ -bg\ tan\n\ \ pack\ \ \ \ .cv\ -in\ .f1\n\ \ \n\ \ \ #set\ side2\ 2\n\ \ button\ \ .b0\ -text\ \"clear\"\ -command\ \{\ clrcanvas\ .cv\ \}\n\ \ button\ \ .b3\ -text\ \"castle\"\ \ \ -command\ \{clrcanvas\ .cv\;barley\ .cv\ 20\;\ castle\ \ .cv\;\ \}\n\ \ button\ \ .b5\ -text\ \"wildcard\"\ \ \ -command\ \{clrcanvas\ .cv\;\ tactics\ \ \ .cv\ \}\n\ \ \ \ \ \n\ \ \ \ \ \ button\ \ .b6\ -text\ \"record\"\ \ \ -command\ \{\ record\ \ .cv\ \}\n\ \ \ \ \ \ button\ \ .b7\ -text\ \"situation\"\ \ \ -command\ \{castle\ .cv\;replyit\ .cv\;\ advisorx\ 50\ 50\ \ \}\n\ \ \ \ \ \ button\ .b4\ -text\ \"console\"\ \ \ -command\ \{reportx\ .cv\ \ \}\n\ \ \ \ \ \ button\ \ .b8\ -text\ \"exit\"\ \ \ -command\ \{leave\ \ \ .cv\ \}\ \n\ \ \ \ \ \ button\ \ .b9\ -text\ \"about\"\ \ \ -command\ \{about\ \ \ .cv\ \}\ \n\ \ \ \ \ \ text\ .t\ -width\ 40\ -height\ 5\ -bg\ bisque\n\ \ \ \ \ \ entry\ .xxx\ -width\ 50\ \ -bg\ bisque\ -textvariable\ side1\n\ \ \ \ \ \ entry\ .zzz\ -width\ 50\ -textvariable\ side2\ -bg\ bisque\n\ \ \ \ \ pack\ .b0\ .b3\ .b5\ \ .b6\ .b7\ .b7\ .b4\ .b9\ .b8\ \ -in\ .f2\ \ -side\ left\ -padx\ 2\n\ \ .f2\ configure\ \ -bg\ orange\n\ \ \ \ \ \ label\ .kingx\ \ -text\ \"king\"\ \n\ \ \ \ \ \ label\ .advisora\ \ -text\ \"advisor\"\ \n\ \ \ \ \ \ pack\ \ .advisora\ .zzz\ .t\ \ \ .kingx\ \ .xxx\ -in\ .f3\ \ -side\ bottom\ -padx\ 2\n\ \ \ \ \ \ focus\ .xxx\n\ \ \ \ \ \ focus\ .zzz\n\ \ \ \ \ \ board\ \ \ .cv\n\ \ \ \n\ \ \ \ \ bind\ .\ <Motion>\ \{wm\ title\ .\ \"\ Game\ kingdom\ of\ strategy\ \"\}\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***Version\ with\ added\ hacks\ ***\n\n\n\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ 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***Version\ console\ operation***\n\n======\n\n\n\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \n\ #:by\ gold,\ \ \ \ \ console\ operation\n\n\ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ \ \n\n\ \ proc\ winnerx\ \{aa\ \}\ \{\n\ \ global\ sumit\ sumitland\ sumitbarley\n\ \ global\ sumarians\ liters\ winner5\n\ \ global\ loser5\n\ \ puts\ \"\ \ \ end\ of\ game\ \ \"\ \n\ \ \ if\ \{\ \$sumarians\ >=\ 120\ \}\ \{\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitland\ >=\ 700\ \}\ \{\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"\ king\ is\ winner\ declared\ \"\n\ \ \ puts\ \"king\ is\ winner\ declared\"\n\ \ \ set\ winner5\ 1\n\ \ \}\n\ \ \n\ \ if\ \{\ \$sumarians\ <=\ 40\ \}\ \{\n\ \ \ \ puts\ \"loser\ declared\"\n\ \ \ \ set\ loser5\ 1\n\ \ \}\n\ \ \ if\ \{\ \$sumitbarley\ <=\ 300\ \}\ \{\n\ \ \ puts\ \"loser\ declared\"\n\ \ set\ loser5\ 1\n\ \ \}\n\ \ \}\n\n\n\ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ measures\ of\ barleys\}\ \{20\ measures\ of\ barley\}\ \{10\ measures\ of\ barley\}\n\ \ \ \ \ \{10\ measures\ of\ barley\}\ \{50\ measures\ of\ barley\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ barleyfields\ of\ land\}\ \{60\ barleyfields\ of\ land\}\ \{50\ barleyfields\ of\ land\}\n\ \ \ \ \ \{100\ barleyfields\ of\ land\}\ \{20\ barleyfields\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 99\}\ \{census\ 100\}\ \{census\ 120\}\ \{census\ 110\}\ \{census\ 120\}\ \{census\ 80\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \ \n\ \ \ ans.form:king\ buy\ 20\ land\ \ \\n\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \"\n\ \ \ \ \ \}\n\n\ \ set\ sumarians\ \ 100\n\ \ set\ counter\ 0\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\ \ proc\ calculation\ \{\ aa\ \}\ \{\n\ \ global\ counter\ percentfields\n\ \ global\ sumit\ sumitland\ sumitbarley\ \n\ \ global\ \ buyland\ \ buybarley\ sumarians\n\ \ set\ annum\ \ \ \ 0\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \n\ \ set\ provisions\ \ \ \ 1000\ \ \ \ \ \ \ \ \n\ \ set\ liters\ 5000\ \ \ \n\ \ set\ land\ \ \ \ 1000\ \ \ \ \ \ \n\ \ set\ barleyfields\ \ \ 1000\n\ \ set\ landprice\ 26\n\ \ set\ litersperacre\ \ 3\ \n\ \ set\ totalmortality\ \ \ 10\n\ \ set\ mortalrateer\ \ 10\ \n\ \ set\ ratliters\ 1\n\ \ set\ citymortal\ 5\n\ \ set\ landfraction\ .1\n\ \ set\ sumariansgain\ 5\n\ \ set\ produce\ 4\n\ \ set\ buyland\ 1\n\ \ set\ buybarley\ 1\n\ \ set\ plaguethisyear\ 0\n\ \ set\ ratinfestthisyear\ 0\n\ \ set\ famineyear\ 0\n\ \ set\ immigrantyear\ 0\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .90\ \}\ \{set\ immigrantyear\ \ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .15\ \}\ \{set\ plaguethisyear\ 1\ \}\n\ \ if\ \{\ \[\ expr\ \{\ rand()\ \}\ \]\ <=\ .41\ \}\ \{set\ ratinfestthisyear\ 1\ \}\n\ \ set\ ratliters\ \ \[\ expr\ \{\ \$liters*.1*rand()\ \ \ \}\ \]\n\ \ set\ ratliters\ \[\ expr\ \{\ int(\$ratliters)\ \}\ \]\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ \$sumarians*.02*rand()\ \ \ \}\ \]\n\ \ set\ landfraction\ \ \[\ expr\ \{\ \ \ rand()\ \}\ \]\ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ \$sumarians\ \ *\ .10\ *\ rand()\ \}\ \]\ \ \n\ \ set\ sumariansgain\ \ \ \[\ expr\ \{\ \ int(\$sumariansgain)\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ \$sumarians\ +\ \$sumariansgain\ \ \ \}\ \]\n\ \ set\ produce\ \[\ expr\ \{\ \ \$land\ *\ 3\ \}\ \]\n\ \ set\ landprice\ \[\ lpick\ \{\ 26\ 25\ 24\ 23\ 22\ 21\ 20\ 19\ 18\ 17\ 16\ \}\ \]\ \n\ \ set\ landprice\ \[\ expr\ \{\ int(\$landprice)\ \}\ \]\ \n\ \ set\ liters\ \$sumitbarley\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ +\ \$sumitland*.8\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$landprice*\ \$buyland\ \}\ \]\n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$sumarians*\ 7\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ \ \$liters\ -\ \$liters*.1*\$ratinfestthisyear\ \}\ \]\ \n\ \ set\ liters\ \[\ expr\ \{\ int(\$liters)\ \}\ \]\ \n\ \ set\ foodrequire\ \[\ expr\ \{\$sumarians*7\ \}\]\n\ \ if\ \{\ \ \ \$liters\ <=\ \$foodrequire\ \ \ \}\ \{\n\ \ set\ sumariansstarved\ \[expr\ \{\$sumarians*.2\ \ \}\ \]\ \n\ \ set\ famineyear\ 1\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \}\n\ \ set\ sumariansstarved\ \[\ expr\ \{\ int(\$sumariansstarved)\ \ \}\ \]\n\ \ set\ sumitbarley\ \$liters\n\ \ set\ sumitland\ \ \[\ expr\ \{\ int(\$sumitland)\ \ \}\ \]\n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ +\ \$sumarians*.1\ -\$sumariansstarved\}\ \]\ \n\ \ set\ sumarians\ \ \[\ expr\ \{\ \$sumarians\ -\ \$sumarians*.5*\$plaguethisyear\ \}\ \]\ \n\ \ set\ sumarians\ \[\ expr\ \{\ int(\$sumarians)\ \}\ \]\n\ \ set\ percentfields\ \[\ expr\ \{\ (\$sumitland/1000.)*100.\ \ \ \}\ \]\n\ \ if\ \{\ \ \$percentfields\ <=\ 1\ \ \ \}\ \{\ set\ percentfields\ 1\ \}\n\ \ if\ \{\ \ \$percentfields\ >=\ 100\ \ \ \}\ \{\ set\ percentfields\ 100\ \}\n\ \ set\ percentfields\ \[\ expr\ \{\ int(\$percentfields)\ \}\ \]\n\ \ puts\ \ \"annum\ \$counter\ \"\n\ \ puts\ \ \"\$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \"\n\ \ puts\ \ \"\$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\"\n\ \ puts\ \"\$percentfields\ percent\ \"\n\ \ puts\ \"\$sumariansstarved\ sumarians\ starved\"\n\ \ puts\ \"\$sumariansgain\ immigrated\ to\ city.\"\n\ \ puts\ \"census\ \$sumarians\ \ \"\n\ \ puts\ \"total\ \ \$sumitland\ barleyfields.\"\n\ \ puts\ \"yielded\ 3\ measures\ per\ barleyfield\"\n\ \ puts\ \"rats\ devoured\ \$ratliters\ measures.\"\n\ \ puts\ \ \"\$liters\ \ measures\ in\ palace.\"\n\ \ puts\ \"land\ \$landprice\ measures\ per\ barleyfield\"\n\ \ puts\ \"how\ many\ barleyfields\ do\ you\ wish\ to\ buy?\"\ \n\ \ set\ listx\ \ \"\n\ \ \ \ \ \ \ annum\ \$counter,\ \ \ \$liters\ \ measures\ \ \ \n\ \ \ \ \ \ \ census\ \$sumarians,\ \ \$sumitland\ barleyfields.\ \ \ \n\ \ \ \ \ \ \ \$landprice\ landprice\ measures\n\ \ \ \ \ \ \$plaguethisyear\ plague\ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$famineyear\ \ famineyear\ ,0\ or\ 1\n\ \ \ \ \ \ \ \$ratinfestthisyear\ rats\ infest\ \ this\ year,\ \ 0\ or\ 1.\ \n\ \ \ \ \ \ \$sumariansstarved\ sumarians\ starved\ \n\ \ \ \ \ \ \$sumariansgain\ immigrated\ to\ city.\ \n\ \ \ \ \ \ census\ \$sumarians\ \ \ \n\ \ \ \ \ \ total\ \ \$sumitland\ barleyfields.\ \n\ \ \ \ \ \ yielded\ 3\ measures\ per\ barleyfield\ \n\ \ \ \ \ \ rats\ devoured\ \$ratliters\ measures.\ \n\ \ \ \ \ \ \ \$liters\ \ measures\ in\ palace.\ \n\ \ \ \ \ \ land\ \$landprice\ measures\ per\ barleyfield\ \"\n\ \ \ \ \ \ incr\ counter\n\ \ \ \ \ \ return\ \"\ \$listx\ \"\n\n\n\ \ \}\n\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ global\ counter\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ if\ \{\ \$counter\ <=\ 5\ \}\ \{puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ puts\ \"update:\ game\ ends\"\ \}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ \ winnerx\ 1\ \}\n\ \ if\ \{\ \$counter\ >=\ 6\ \}\ \{\ puts\ \"for\ new\ game,\ enter\ reset\ 1\ \"\ \}\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ cc\ \}\ \{\n\ \ \n\ \ global\ sumitland\ sumitbarley\ \n\ \ global\ buyland\ buybarley\n\ \ global\ counter\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ sumitland\ \[\ expr\ \{\ \$sumitland\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ sumitbarley\ \[\ expr\ \{\ \$sumitbarley\ +\ \$token\ \}\ \]\ \}\n\ \ if\ \{\ \$cc\ ==\ \"land\"\ \}\ \{\ set\ buyland\ \ \$token\ \ \}\n\ \ if\ \{\ \$cc\ ==\ \"barley\"\ \}\ \{\ set\ buybarley\ \ \$token\ \ \}\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \ \ land\ \$sumitland,\ barley\ \$sumitbarley\ \"\n\ \ \ \n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ record\ 1\ \n\ \ advisorx\ 50\ 50\n\ \ \n\ \ \n\ \ \}\n\ \ \ proc\ record\ aa\ \{\n\ \ \ set\ results\ \ \[\ calculation\ 10\ \ \]\n\ \ \ puts\ \$results\n\ \ \ return\ 1\ \}\n\ \ \ proc\ reset\ aa\ \{\n\ \ \ global\ counter\n\ \ \ set\ counter\ 0\n\ \ \ \ set\ sumitland\ 1000\n\ \ \ \ set\ sumitbarley\ 1000\ \n\ \ \ \ set\ sumarians\ \ 100\ \n\ \ \ advisorx\ 1\ 2\ \n\ \ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ land\ \"\n\ \ \ puts\ \"\ can\ cut\ &\ paste\ from\ console\"\n\ \ \ puts\ \"answer\ has\ form:\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ buy\ 20\ land\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ sell\ 30\ land\ \ \"\n\ \ \ puts\ \"eg.\ \ \ king\ buy\ 33\ barley\ \"\n\ \ \ puts\ \"eg.\ \ \ king\ sell\ 11\ barley\ \"\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\ \ \ \ \ \ #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\ \ \ #\ written\ on\ Windowws\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 17Jul2010\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\ \n======\n***Extra\ Program***\ \n======\n\ \ \ \ ======\n\ \n***Real\ TEST\ on\ \ trial\ code\ trial\ code***\n\n\ #note:\ this\ Tkpaint\ diagram\ \n\ #\ script\ is\ *correct*\ in\ the\ wiki\ editor.\n\ #\ It\ is\ rewrapping\ on\ the\ Wiki\ display\ page.\n\ \ set\ maxX\ 400\n\ \ set\ maxY\ 400\n\ \ set\ y\ \ \ \ \ \ 0\n\n\ \ set\ x1\ 120\n\ \ set\ x2\ 150\n\ \ set\ y1\ \ 50\n\ \ set\ y2\ \ 80\n\n\ pack\ \[\ canvas\ \ .c\ \ -width\ \$maxX\ -height\ \$maxY\ \ -bg\ bisque\ \]\nset\ Graphics(arrowshape)\ \{8\ 10\ 4\}\nset\ Graphics(fill,color)\ \{\}\nset\ Graphics(fill,style)\ \{\}\nset\ Graphics(font,bold)\ 1\nset\ Graphics(font,color)\ black\nset\ Graphics(font,italic)\ 0\nset\ Graphics(font,normal)\ 0\nset\ Graphics(font,overstrike)\ 0\nset\ Graphics(font,roman)\ 0\nset\ Graphics(font,size)\ 10\nset\ Graphics(font,stipple)\ \{\}\nset\ Graphics(font,style)\ bold\nset\ Graphics(font,type)\ Arial\nset\ Graphics(font,underline)\ 0\nset\ Graphics(grid,on)\ 0\nset\ Graphics(grid,size)\ 10m\nset\ Graphics(grid,snap)\ 1\nset\ Graphics(line,arrow)\ none\nset\ Graphics(line,capstyle)\ butt\nset\ Graphics(line,color)\ black\nset\ Graphics(line,joinstyle)\ miter\nset\ Graphics(line,smooth)\ 0\nset\ Graphics(line,style)\ \{\}\nset\ Graphics(line,width)\ 1\nset\ Graphics(mode)\ NULL\nset\ Graphics(shape)\ circle\nset\ Graphics(snap,on)\ 0\nset\ Graphics(snap,size)\ 1\nset\ Graphics(splinesteps)\ 20\nset\ Graphics(text,anchor)\ c\nset\ Graphics(ticks,on)\ 0\nset\ Graphics(mode)\ NULL\n###\ End\ of\ Graphics\ parameters\n\n\nset\ Zoom(button,text)\ 100%\nset\ Zoom(caller)\ \{\}\nset\ Zoom(factor)\ 1\nset\ Zoom(font,size)\ 10\nset\ Zoom(selected,button)\ 1\nset\ utagCounter\ 62\n\n\nset\ Image(ctr)\ 0\n\n\nset\ Canv(H)\ 368\nset\ Canv(W)\ 610\nset\ Canv(SH)\ 1500\nset\ Canv(SW)\ 1500\nset\ Canv(bg)\ white\n.c\ config\ -width\ \$Canv(W)\ \ -height\ \$Canv(H)\ \ -bg\ \$Canv(bg)\ \ -scrollregion\ \"0\ 0\ \$Canv(SW)\ \$Canv(SH)\"\nwm\ geometry\ .\ \"\"\n.c\ xview\ moveto\ 0\n.c\ yview\ moveto\ 0\nset\ TextInfo(utag52)\ \{Game\ \ kingdom\ \ of\ \ strategy\}\nset\ TextInfo(utag34)\ \{\}\nset\ TextInfo(utag16)\ initial\nset\ TextInfo(utag53)\ \{\}\nset\ TextInfo(utag17)\ \{random\nsituation\}\nset\ TextInfo(utag54)\ \{TCL\ \ WIKI\}\nset\ TextInfo(utag18)\ \{\}\nset\ TextInfo(utag19)\ stop\nset\ TextInfo(utag20)\ \{\}\nset\ TextInfo(utag56)\ \{\}\nset\ TextInfo(utag21)\ \{\}\nset\ TextInfo(utag57)\ LOOP\nset\ TextInfo(utag39)\ stop\nset\ TextInfo(utag22)\ \{winner\ declared\}\nset\ TextInfo(utag58)\ \{COUNTER\ \ >\ \ 5\}\nset\ TextInfo(utag23)\ \{\}\nset\ TextInfo(utag60)\ \{\}\nset\ TextInfo(utag42)\ \{set\ \ counter\}\nset\ TextInfo(utag61)\ \{call\ \ records\}\nset\ TextInfo(utag43)\ \{call\ first\ \ situation\}\nset\ TextInfo(utag25)\ records\nset\ TextInfo(utag62)\ \{incr\ \ counter\}\nset\ TextInfo(utag26)\ \{\}\nset\ TextInfo(utag27)\ ratings\nset\ TextInfo(utag28)\ \{\ \ \ \ \ \ \ counts\}\nset\ TextInfo(utag47)\ totals\nset\ TextInfo(utag29)\ \{\}\nset\ TextInfo(utag12)\ \{new\ situation\}\nset\ TextInfo(utag48)\ \{\}\nset\ TextInfo(utag13)\ \{\}\nset\ TextInfo(utag50)\ \{\}\nset\ TextInfo(utag49)\ \{\}\nset\ TextInfo(utag14)\ king\nset\ TextInfo(utag51)\ \{\}\nset\ TextInfo(utag15)\ advisor\n.c\ create\ line\ 387.0\ 140.0\ 409.0\ 192.0\ 449.0\ 139.0\ 385.0\ 140.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag2\}\n.c\ create\ line\ 210.0\ 37.0\ 232.0\ 89.0\ 272.0\ 36.0\ 208.0\ 37.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag3\}\n.c\ create\ line\ 195.0\ 140.0\ 217.0\ 192.0\ 257.0\ 139.0\ 193.0\ 140.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag6\}\n.c\ create\ line\ 43.0\ 274.0\ 65.0\ 326.0\ 105.0\ 273.0\ 41.0\ 274.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag5\}\n.c\ create\ line\ 52.0\ 146.0\ 74.0\ 198.0\ 114.0\ 145.0\ 50.0\ 146.0\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag4\}\n.c\ create\ oval\ 126.0\ 214.0\ 294.0\ 276.0\ -tags\ \{Ellipse\ obj\ utag11\}\n.c\ create\ oval\ 332.0\ 287.0\ 500.0\ 349.0\ -tags\ \{Ellipse\ obj\ utag9\}\n.c\ create\ text\ 206.0\ 240.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{new\ situation\}\ -tags\ \{text\ obj\ utag12\}\n.c\ create\ text\ 68.0\ 286.0\ -font\ \{Arial\ 10\ bold\}\ -text\ king\ -tags\ \{text\ obj\ utag14\}\n.c\ create\ text\ 81.0\ 155.0\ -font\ \{Arial\ 10\ bold\}\ -text\ advisor\ -tags\ \{text\ obj\ utag15\}\n.c\ create\ text\ 238.0\ 47.0\ -font\ \{Arial\ 10\ bold\}\ -text\ initial\ -tags\ \{text\ obj\ utag16\}\n.c\ create\ text\ 216.0\ 155.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{random\nsituation\}\ -tags\ \{text\ obj\ utag17\}\n.c\ create\ text\ 416.0\ 317.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{winner\ declared\}\ -tags\ \{text\ obj\ utag22\}\n.c\ create\ rectangle\ 347.0\ 220.0\ 482.0\ 267.0\ -tags\ \{Rectangle\ obj\ utag24\}\n.c\ create\ text\ 419.0\ 241.0\ -font\ \{Arial\ 10\ bold\}\ -text\ records\ -tags\ \{text\ obj\ utag25\}\n.c\ create\ text\ 481.0\ 146.0\ -font\ \{Arial\ 10\ bold\}\ -text\ ratings\ -tags\ \{text\ obj\ utag27\}\n.c\ create\ text\ 466.0\ 165.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{\ \ \ \ \ \ \ counts\}\ -tags\ \{text\ obj\ utag28\}\n.c\ create\ line\ 232.0\ 95.0\ 233.0\ 127.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag31\}\n.c\ create\ line\ 264.0\ 153.0\ 377.0\ 151.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag32\}\n.c\ create\ line\ 72.0\ 207.0\ 74.0\ 262.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag33\}\n.c\ create\ line\ 120.0\ 156.0\ 177.0\ 155.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag35\}\n.c\ create\ line\ 146.0\ 275.0\ 102.0\ 289.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag36\}\n.c\ create\ line\ 410.0\ 197.0\ 410.0\ 213.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag37\}\n.c\ create\ line\ 416.0\ 272.0\ 416.0\ 283.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag38\}\n.c\ create\ text\ 555.0\ 319.0\ -font\ \{Arial\ 10\ bold\}\ -text\ stop\ -tags\ \{text\ obj\ utag39\}\n.c\ create\ line\ 506.0\ 318.0\ 522.0\ 318.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag40\}\n.c\ create\ line\ 217.0\ 195.0\ 217.0\ 208.0\ -arrow\ last\ -arrowshape\ \{8\ 10\ 4\}\ -joinstyle\ miter\ -tags\ \{Line\ obj\ utag41\}\n.c\ create\ text\ 320.0\ 66.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{set\ \ counter\}\ -tags\ \{text\ obj\ utag42\}\n.c\ create\ text\ 339.0\ 47.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{call\ first\ \ situation\}\ -tags\ \{text\ obj\ utag43\}\n.c\ create\ text\ 416.0\ 151.0\ -font\ \{Arial\ 10\ bold\}\ -text\ totals\ -tags\ \{text\ obj\ utag47\}\n.c\ create\ text\ 218.0\ 18.0\ -font\ \{Arial\ 18\ bold\}\ -text\ \{Game\ \ kingdom\ \ of\ \ strategy\}\ -tags\ \{text\ obj\ utag52\}\n.c\ create\ text\ 224.0\ 339.0\ -font\ \{Arial\ 18\ bold\}\ -text\ \{TCL\ \ WIKI\}\ -tags\ \{text\ obj\ utag54\}\n.c\ create\ line\ 32.000\ \ 177.0\ 29.67\ \ 23.999\ \ \ \ -arrow\ first\ -arrowshape\ \{8\ 10\ 4\}\ -smooth\ 1\ -tags\ \{arc\ arc\ obj\ utag55\ spline\}\n.c\ create\ text\ 44.0\ 224.0\ -font\ \{Arial\ 10\ bold\}\ -text\ LOOP\ -tags\ \{text\ obj\ utag57\}\n.c\ create\ text\ 322.0\ 134.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{COUNTER\ \ >\ \ 5\}\ -tags\ \{text\ obj\ utag58\}\n.c\ create\ oval\ 529.0\ 296.0\ 577.0\ 344.0\ -tags\ \{Circle\ obj\ utag59\}\n.c\ create\ text\ 501.0\ 185.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{call\ \ records\}\ -tags\ \{text\ obj\ utag61\}\n.c\ create\ text\ 278.0\ 183.0\ -font\ \{Arial\ 10\ bold\}\ -text\ \{incr\ \ counter\}\ -tags\ \{text\ obj\ utag62\}\n\n\n\n\ \ \n----\n\n\n----\n\n***test\ on\ \ trial\ code\ trial\ code***\nWe\ could\ bust\ up\ or\ split\n\ \ \ \ \ phrases\ looking\ for\ words\ buy\ or\ sell\ ,\n\ \ \ \ \ and\ no\ not\ sell.\n\ \ \ \ \ set\ answer\ \[split\ \$lister\ \"\"\ \]\n\ \ \ \ \ llength\ \$answer\n\ \ \ \ \ foreach\ item\ \{buy\ sell\ no\ not\ nay\ \}\ \{\n\ \ \ \ \ lsearch\ all\ \$answer\ \$item\n\ \ \ \ \ \ \}\ \ \ \ \n\ \ \ \ \ if\ we\ find\ one\ of\ the\ command\ words\ in\ list,\n\ \ \ \ \ does\ it\ operate\ on\ the\ next\ number\ found?\n\ \ \ \ \ Better\ check\ on\ how\ to\ identify\ a\ number\ element?\n\ \ \ \ \ say\ if\ \{\ catch\{\ expr\ \{\ 1.*\$element\}\ !=\ 1\ \}\n\ \ \ \ \ \ \ \ \ foreach\ item\ \$bee1\ \{\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ >>\ 0\}\ \{lappend\ cat\ \ \$item\ \}\n\n\ \ \ \ \ \ if\ \{\ \[catch\ \{expr\ \{1\ *\ \$item\}\}\]\ ==\ 0\ \}\ \{lappend\ bat\ \[\ expr\ 200*\$factor*.1\ +\ \$item\ *\ log(\$factor)\ \ \]\}\n\ \ \ \ \ \ \ \}\n\n\ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\n\ \ \ \ \ \ \ \ #start\ of\ deck\ \n\ \n\ #:by\ gold,\ \ \ trial\ console\ operation\n\n\ #\ written\ on\ Windows\ XP\ on\ eTCL\n\ \ \ \ \ #\ working\ under\ TCL\ version\ 8.5.6\ and\ eTCL\ 1.0.1\n\ \ \ \ \ #\ gold\ on\ TCL\ WIKI\ ,\ 1Aug2010\n\n\n\n\n\ \ \ \ console\ show\ \n\ \ \ \ \ \ proc\ ?\ L\ \{\n\ \ \ \ \ \ \ lindex\ \$L\ \[expr\ \{int(rand()*\[llength\ \$L\])\}\]\n\ \ \ \ \ \ \ \}\n\ \ \ \ proc\ lpick\ L\ \{lindex\ \$L\ \[expr\ int(rand()*\[llength\ \$L\])\]\;\}\n\ \ \ \ proc\ advisorcom\ \{lister\}\ \{\n\ \ \ \ \ set\ choutext\ \[list\ \]\n\ \ \ \ foreach\ item\ \$lister\ \{\n\ \ \ \ if\ \{\ \$item\ ==\ 1\ \}\ \{lappend\ choutext\ \"second\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 2\ \}\ \{lappend\ choutext\ \"fifth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 3\ \}\ \{lappend\ choutext\ \"performance\ comparable\ to\ bonzo\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 4\ \}\ \{lappend\ choutext\ \"fourth\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 5\ \}\ \{lappend\ choutext\ \"no\ bread\ left\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 6\ \}\ \{lappend\ choutext\ \"surving\ inhabitants\ have\ fled\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 7\ \}\ \{lappend\ choutext\ \"third\ rate\"\ \}\n\ \ \ \ if\ \{\ \$item\ ==\ 8\ \}\ \{lappend\ choutext\ \"lacking\ any\ sense\"\ \}\n\ \ \ \ if\ \{\ \$item\ >=\ 9\ \}\ \{lappend\ choutext\ ?\ \}\n\ \ \ \ \}\n\ \ \ \ return\ \$choutext\}\n\ \ \ \ \ \n\n\n\n\n\n\n\n\n\ \ \ \ \ proc\ tidings\ \{\}\ \{\n\ \ \ set\ a\ \{\n\ \ \ \ \ \{70\ liters\ of\ grains\}\ \{20\ liters\ of\ grain\}\ \{10\ liters\ of\ grain\}\n\ \ \ \ \ \{10\ liters\ of\ grain\}\ \{50\ liters\ of\ grain\}\n\ \ \ \}\n\ \ \ set\ b\ \{\n\ \ \ \ \ \{400\ hectares\ of\ land\}\ \{60\ hectares\ of\ land\}\ \{50\ hectares\ of\ land\}\n\ \ \ \ \ \{100\ hectares\ of\ land\}\ \{20\ hectares\ of\ land\}\n\ \ \ \}\n\ \ \ set\ c\ \{rain\ dry\ heat\ cold\ drought\ \ snow\ \}\n\ \ \ set\ d\ \{\n\ \ \ \ \ \ \{census\ 1000\}\ \{census\ 3000\}\ \{census\ 2000\}\ \{census\ 5000\}\ \{census\ 8000\}\ \{census\ 4000\}\n\ \ \ \}\n\ \ \ return\ \"\ \ \ need\ \[?\ \$a\].\n\ \ \ need\ \[?\ \$b\].\n\ \ \ predict\ \[?\ \$c\].\n\ \ \ subjects\ from\ \[?\ \$d\].\ \\n\"\n\ \ \ \ \ \}\n\ \ set\ sumit\ 1000\n\ \ set\ sumitland\ 1000\n\ \ set\ sumitbarley\ 1000\n\n\ \ proc\ advisorx\ \{aa\ bb\}\ \{\n\ \ \ puts\ \"\ \"\n\ \ \ puts\ \"advisor:\ \ new\ situation\ \"\ \n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"advisor:\ buy\ or\ sell,\ my\ lord?\ \"\n\n\ \ \}\n\ \ proc\ king\ \{\ aa\ bb\ \}\ \{\n\ \ global\ sumit\n\ \ if\ \{\ \$aa\ ==\ \"buy\"\ \}\ \{set\ token\ \[\ expr\ \{\ 1.*\ \$bb\ \}\ \]\ \}\n\ \ if\ \{\ \$aa\ ==\ \"sell\"\ \}\ \{set\ token\ \[\ expr\ \{\ -1.*\ \$bb\ \}\ \]\ \}\n\ \ set\ sumit\ \[\ expr\ \{\ \$sumit\ +\ \$token\ \}\ \]\n\ \ puts\ \"\ decision\ was\ \$aa\ \$bb,\ total\ was\ \$sumit\ \"\n\ \ puts\ \"\ advisor\ says\ \ \ \[\ advisorcom\ \[\ lpick\ \{\ 1\ 2\ 3\ 4\ 5\ 6\ 7\ 8\ \}\]\]\ \ \ \"\n\ \ advisorx\ 50\ 50\n\ \ \}\n\ \ \ puts\ \[\ tidings\ \]\n\ \ \ puts\ \"buy\ or\ sell,\ my\ lord?\ \"\n\ \ \ puts\ \"\ starts\ with\ 1000\ units\ \"\n\ \ \ puts\ \"answer\ has\ form:\ \ king\ buy\ 20\ or\ king\ sell\ 30\ \ \"\n\n\n\n\ \ \ \ \ \ \ \n<<categories>>\ Toys\ |\ Example\ |\ Games\ |\ Characters\ |\ Math\ \ |\ Math\ |} CALL {my revision {Game kingdom of strategy}} CALL {::oo::Obj299071 process revision/Game+kingdom+of+strategy} CALL {::oo::Obj299069 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