TE006143*nTTv`Za  bXESCAPEUARROWDARROWLARROWRARROWSPINCLSPINCC BASICCUBE CUBELINES SLOTCENTERSgresgcardGVIEWGWINDOWBORDER DISPLAYCUBEROTAGENDDISPLAYSLOTSONPLANETRFOBSDISTONTOXYLINESSCALETORADMOVECUBEIL1ACOLORRL2PENDBCFSKEYSWpanelTMLNZDEGLAAAAXDISTdXYAXISKOKPLANESPLINESORDERLUPPLCENTERSineySLSHOWCUBEBKEYSPROMPTOPLAYESCBSDIGITLETTERnDESCRIBEVERSIONallslotsbacklolxxostate evalstatefreeboardcubecanhehow showslotscanitryCCcpueXpsIMAGEPOSSXSOdescrrvbXoliendevalivlinesvalueevaluateexcessNSLOTSILPfevalLVALUEIPLISLforcewTimegetqsterrifplayEXPforihelphisturninptindexrlbnocomaidetakenwhatcondininputcrmyturnlslotsmaxlostwonwinforcedcheckbestfiniHowpresentoknotepassplanesSHOWnqbqstbareverserunbrnbrsimulatestshortenSTtestxoemptyordwhichFreeState iamforcedforcehimendbrSeq statevalueposkwmlttt3dTotalanwtwiceALLCRLPLS TECHNIQUEtrapstarthimmeoverSearchOSSnCsR12aLlhIdsRh98067TNL15L10pOvL17L20L60L25L45L30L55L35L40L50MvtreduceMAXBRmsgAllslots RESTORESCREENAxisTiltROT UPPERCASEAIXSttt3Dttt DisplayTimeTRAPWPOSMsgPosOKLpDVXcolorOcolorForcerandomw2dEDIT RotateAngleZzSTOPSsPcoords SETCUBEVARSPCL0l0ObsDistForseHisturn SCREENMODEduml10HelpgameoverlinemodegetsHepSlots ScreenModehisturLCnforcesl5hHistoryUCMDRESULTPBDFRCPACKBINPDEFPNAMES GLOBALALX GLOBALELX GLOBALCT GLOBALIO GLOBALPWUFILESSYSID3UCMD2DEFAULTOVERMATRIFYMATIOTAIFERRINOUTFOPEN OVEROBJ MATRIFYOBJ MATIOTAOBJPARSEXACEHIJKLTTYPEVVARCSUERRMSGQPKGTIEDYZW423512111013141522161718211920VALUEMODaZaAaBPARMSPATNARGSWITDLMSWPATQSPL4MEML3CHKCOMPCMDOSSOSL11CADELTIEOBJFILELEFTRIGHTXSAPLCFOBJLLAT SHOWLASTMOVEMOREWinLinetOTALplCMDFORIexpfwrongl1 RESETSCREEN GraphicsHelpTZG?T o(HTZG? TZG?3 founTZG?SE ''TZG? MOONTZG?nAN PROTZG?5HT ZG?T0[G?T[G?@T [G?   T [G?IBMCOLORT [G?T [G? 4 3 4 T$[G?T ; %T T T00010000 %R?X1TPT 00020000# %[  ]z?Kz??T *[G?U  B; .; &; ; #; =; (U`T U00010000# Lines & Cube in globals PLINES & PLANES. SLOTS' centers in CENTERS.wU@U U00020000# Display the cube line by line @@g U`U U00030000 =,/ ;[;;]  .# Green,Blue,Red,PurpleQUP U U00040000 >: # =[ ] & .[ #] &  ;[ #;;] &  <[ #;;;] ?5?UPU U00050000 ( B  # ([;]=(    @[ ([;];]) &} ?U0U 00060000. >  ?"U 0[G? U ! 4  -; ; 5; %m U`U &U00010000# Rotate on Axis. AA is Axis Angle in deg & Axis (1=x,2=y,3=z). 2=b^v &U0 U )U00020000# M is Xd struct.쀈)UP&U .U00030000 %( ) 4 5 %/    4.Up)U 5U00040000 !   ( !) !# 3 3 1 0 0 0 ,(1 1 R),,0,R0@5U0.U 8U00050000# M[;AX] 0 1 1/A+.1,B/M8U05U ;U00060000 !( %/ -). 3t93#O3t;UP8U 00070000-M[((  -) ;)AX]R ! -o8?o8@U6[G?AU ;AU0@U DU00010000# Leave graphics modeDU AU FU00020000FU`DU LU00030000 .[]  [] # in case of E1024LU FU 00040000 NU <[G?PU  +; ; (; *; @ 2PU0NU SU00010000# DISPLAY OBJECTSLԄSU PU 00020000     +JUU B[G?WU !  FWU@UU 00010000 !( [?] ) F[?] [U H[G?]U ! (  ?1<]UP[U bU00010000# Slots are in the range 1..64, PLanes in 1..4ybU@]U 00020000 !( ?/ ([;]) (y fU N[G?hU !  v@<hU@fU 00010000 !  @lvllU Z[G?nU ! 6  &; 7; 1; 0; /nU@lU rU00010000# PROJECT C onto XY plane from DISTancerU@nU vU00020000# C is 3 col mat: X, Y & Z coordsvUPrU {U00030000 / 7((/ &).)?{U@vU U00040000 0( 1 7) 6 1 / / &UP{U 00050000 !(/ &)/( /) ( 7 0) 7U `[G?U ! 3  .U0U 00010000 3#( .) .Uf[G? T?U l[G?U !  2U0U 00010000 ! 2tUP\\G?U * - C ; ;; ); 9; 1; <; ,; '; @; %; D; E; F; /; #; &; 0;;; ; U0U U00010000 RESTORESCREEN?U`U U00020000# M is message to display (if it starts with * no more input is accepted)U0U U00030000 * ->- U0U U00040000# W is stuff written so farUPU U00050000   * 0# Char spacing (approx)U@U U00060000#  CR BackSpace Zz Ss 1234 Gg Bb Rr Pp?VcEUPU U00070000 D  /ZzSs1234GgBbRrPp?U0U U00080000# Z (), Y and X ()-?@U@U U00090000 )      U`U U00100000 F E Use arrows to turn cube or Enter / position: 9B.U U U00110000 : B.U U U00120000 :hEU0U U00130000 1 :  1X  1R UPU U00140000 1Y 1S 1T *?( 0 F *) U0U U00150000 E?     -? UPU U00160000 ": 9'.( 9 D)/ G.( % 9/ ))/ H :. "@ڳU`U U00170000 :: [ ,] [ ,] '(  % ) , %// 789 V X]G?V m ; n; oV@V V00010000 n + o W r   U VPV V00020000(  o o[ n]) [ n;] V V 00030000 o  Wp'j]G?L  !1#4)=+@ "2*> #3+?  "1$4*=,@%5'8&6'7&5(8 )9 +< *: +; *9 ,<  %1 '4 -= /@&2.>'3/?&1(4.= 0@   !"#$!%)-!&+0"&*.#'+/$'*-$(,0%&'()*+,-./01234159=16;@26:>37;?47:=48<@56789:;<=>?@&'W v]G?)W q r U; n; s;)W`'W /W00010000# return a value for each slot according to the state of each line/W@)W 3W00020000# note that all globals are in IO=1/3W@/W 7W00030000 n  UHforc7W`3W =W00040000 s/ t[ n[ u]]# excess 'valuable' lines on each planeuefreeeval=W`7W CW00050000 q v s# transformation fn: value of each planeCWP=W HW00060000 q w[ n]/ q[ x]# each line's evaluationHWPCW 00070000 q/ q[ y]# each slot's evaluationMW ]G?OW]G?  "/0123456789:;<=>?@ABCDEFGHIJKL#%0:D '(2<F )*3=G!,.5?I /9C6@J !7AK"%&(*-.8BL 6AL"#$')+,7@C+.1;E$%4>H$&2=I +-3<DgW ]G?iW h v SiW0gW 00010000 h SlW ]G?nW]G?L                                           W9]G?@     !"#$%&"'( ")*"+,-./01 /2 /3/4506 126 34656#07$'247 )+137!,57%048&(28*-38.1589:; 9< 9=9>?#:@'+;<@$)=>@,?@:A  <>A ;=A!?A%:>B(-<B&*=B.;?B#+CDE 'CF )CG$,CHIDJEFJGHJIJ DKFHKEGK!IK%-DHL (FL *GL&.EILW ]G?W z {; L; |W`W W00010000# Force machine to play somewhere or set FORCE level (0=weakest)WPW W00020000.( {) Was    {.WPW W00030000 : |[].(  {)  { ~where ? W@W W00040000 :.  A L( ./ {) W W W00050000 L.W0W 00060000 :Not a valid slotW ]G?W h ~ W W W000100008  W W 00020000 hW ]G?W h W W 00010000 h / W ]G?W h b; 0WPW W00010000 S S b U U  p./ b W[ b]쀂WpW W00020000 hI play ( \ b) / (({Gz? 0[] |) secs) W0W 00030000# Total[2]Total[2]+W ]G?W /; '; -; nW`W X00010000 n / / -/  /. n / /X0W X00020000 -  XPX X00030000 -A( -) ( -F)( - ) -Nii+1 X X X00040000 ' XP X 00050000# dba 83/9/27 will EXP for i:=N[1](or IO) to N[2]X]G?X X X 00010000 aX0]G?X  ; ; L;; b; ,; 689;<>X@X X00010000# Allow player to see cube and enter choiceX@X X00020000  ,[]# time to think X X "X00030000.  "X  X $X00040000[$F@$XP"X )X00050000# SCREEN mode doesn't have as many choices as LINE mode@>VcE)X0$X ,X00060000 :.    ?VcE,X@)X 0X00070000 :.( *A  C S  T) $@0X@,X 4X00080000  Invalid choice  Ӌ4X@0X 8X00090000.  A/ L( ./ ) # GBRP8X@4X (*/ )/789.YP%^G?  !"#$%&'()*+,-./0123456789:;<=>?@ !%)-159= "&*.26:> #'+/37;?  $(,048<@!"#$1234%&'(5678 )*+,9:;<  -./0=>?@)*+,=>?@ %&'(1234  !&+016;@ $'*-47:= #'+/48<@ "&*.159=SY^G?TY ^G?VY  ;  >VY@TY ZY00010000# returns 1 if 1st letter of answer is 'y'ZYPVY _Y00020000 :  /( ~ )/ yYnNmeover_Y0ZY bY00030000.(/ ) to see cube anbY0_Y eY00040000Answer by Yes or NoeY bY 00050000. tP0003000 gY ^G?iY ; n; L; iY@gY mY00010000 n.  L   mY@iY 00020000 :  [ n n;].(  n- L)/ XqY0^G?tY h ; ; q; U; ; ; ; W; ; tY`qY zY00010000# Given a list of moves return a list of possible forcing new moveszY`tY Y00020000# 'State' is the original state of the game before any move in the list.Y`zY Y00030000 h .( . ) W  W[ ]Y0Y Y00040000 U  [;] V [;]Y0Y Y00050000.( U)/   Y0Y Y00060000 :.# end of branchY@Y Y00070000# Seq is the global holding the solutionYPY Y00080000 :  [] W[ ]/  p[ U ;]YPY Y00090000. # This global used to signal the end of the searchYPY Y00100000 :.(-  W[ ]/ (/ U) p) YPY Y00110000# we may be able to bypass this forcing situationY@Y Y00120000.(/ ( U/) p./ ) Y0Y Y00130000# indeed we are:Y`Y Y00140000 h (  )  W[ ]/  p.Y@Y Y00150000 :  W[ ]/ ( U/) pYPY Y00160000 q [  U]# value of each lineY@Y Y00170000 q/ q[ y[ ;]]# value of each slotY0Y Y00180000 (   ) + qYPY 00190000 h [ [?]   ]# alternate pairsY ^G?Y h j; i; k; Y0Y Y00010000# shorten winning sequence XoYpY Y00020000 k p[(//[] p./ j)(   j[;]) (;]Y@Y Y00030000 i (  j)YPY Y00040000 :.(.  ( i/ j[;]) V i/ j[;]) YPY Y00050000.(( i i j[;] ( /) p). i) Y@Y 00060000 : h i j# note:does not always work!Y ^G?Y ! / aY0Y Y00010000 ! RR+cpu eXp /Y0Y 00020000 ! ! /# avgY &_G?YP_G?Y Y@Y 00010000  >(*A )/789Y V_G?@  !"#$%&'()*+,-./0123456789:;<=>?@Y\_G? Z b_G?LZ&ah_G?L@ ]Xn_G?i The design of this ws is based on 3 known theories: 1) sequential machines 2) tree searching 3) heuristic evaluation 1 - the vector 'state' shows the state of all 76 possible lines in the cube. Each element is a 2 digits integer, the first showing the number of 's, the second the number of 's. Ex.: 12 means 1 , 2 's; 3 means 0 , 3 's. 2 - the function 'try' uses tree searching technique to foresee a winning sequence of over (as in try ). The fn 'run', used by 'try', is recursive and manages the search in the tree while 'simulate' will make a best choice of branches to generate at each level. 3 - if no winning situation is found the fn 'evaluate' will give each slot a value, the higher the better, based on the variable LVALUE and the fn 'feval'. LVALUE contains a factor for each possible state feval returns a value for each of the planes, given the number of s over s in each plane. To find a winning situation, the fn 'simulate' uses the variable 'statevalue' which gives a value to each line according to its state and 'MAXBR' determines the maximum number of branches to generate at each level. e]0t_G?('789'3dm)/overdmh]P_G?m]  ;; ; ; ; ; ; ; ; ; ; ; ; ; ; ; m]@h] q]00010000# DANB: Object Search String - Version 4.1q]@m] u]00020000#~ sR aLl hId sRh OSS pO Mvu]0q] x]00030000.(7OSS)/  x]@u] |]00040000# OSS could be TIE #, start, last cpts|]x] ]00050000 :.(    )  ( (  ) ) . ]P|] ]00060000 : ( "    )/   ]@] ]00070000 :# set variables from arguments]P] ]00080000 ( /     ) # mode, strings]p] ]00090000  btcalr=BTCALR  [] #~Body,~Text,~,Apl,,, RESULT]p] ]00100000   [?] [ ]/BTC# ...perticular constraints]P] ]00110000 (  )/  [] # all strings together]] ]00120000 ( )          # start of each str (0), length (1)]`] ]00130000 ( [])  / []# syntaxic search]`] ]00140000 B_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#]P] ]00150000# Build locals functions]0] ]00160000# The \ Partitionning fn]`] ]00170000  rs pO p;t[1]sspr\s\t10,ts/p#]0] ]00180000# The VTOM fn]`] ]00190000 DIO1L1L-1+1L0,(~B)/BDMV,D  M(B)(,BL./0,BL)\B/M]P] ]00200000 A(( )MD Mv V;L;B;IO)[] #]P] ]00210000# mask fn: Comments, Text, Body, Diamonds, Apl]`] ]00220000 %[1]BCTT>C\(M'')>TT\TM''''# non APL text]`] ]00230000. []    [2]BCTT>(M)(,1,0 1B^M'')# APL text]`] ]00240000  3pO(ASS'ELX')(ASS'ALX')(ASS'NC')''=A,M#]P] ]00250000# NOTE: {error:trapping} NOT taken in account]`] ]00260000 : MhId M;C;T;B;A( []/ M~ )#]0] ]00270000# search fn]`] ^00280000 RsRh T;M;S;N;s;I[1]SMhId TRI0N1#^P] ^00290000  ( / s1~TaLl)T,T#^ ^ ^00300000  $[2]L:RR(ST SS sR[0[I]+1[I]])( []/^s)( []/ ^(1+1[I])s) (N>II+1)/L( []/[3]RR^M)#^ ^ ^00310000. / ^`^ ^00320000 :.(  ) .(  7 (   ) )/   ^0^ ^00330000# Search and count^`^ !^00340000 :.( /  )  /  !^0^ $^00350000# Display if any found$^`!^ *^00360000.( )/  (  Var )[ ;] .  *^P$^ /^00370000 ( ):(     )  [;]/^`*^ 5^00380000 :  (( ) found)  /\ /  5^0/^ 8^00390000# Lines found displayed here8^P5^ =^00400000 :( P<[>Q<]>I5,X1  ) [] [;]=^@8^ A^00410000 ( [] [;])\^A^p=^ H^00420000.(   )/    [  ]  . H^ A^ J^00430000# VariablesJ^0H^ M^00440000 : - # char mat onlyM^`J^ S^00450000 :.(   ) .(   )/   . S^0M^ V^00460000# Get next item to searchV^`S^ \^00470000 :   . /  ( ) . # object or file \^`V^ 00480000 :.(/  )/  .   b^ R`G?d^ h id^Pb^ 00010000 :.( iA h j[;] i k)  i h. i^X`G?j^d`G?@a11a12a13a14a21a22a23a24a31a32a33a34a41a42a43a44b11b12b13b14b21b22b23b24b31b32b33b34b41b42b43b44c11c12c13c14c21c22c23c24c31c32c33c34c41c42c43c44d11d12d13d14d21d22d23d24d31d32d33d34d41d42d43d44G11G12G13G14G21G22G23G24G31G32G33G34G41G42G43G44B11B12B13B14B21B22B23B24B31B32B33B34B41B42B43B44R11R12R13R14R21R22R23R24R31R32R33R34R41R42R43R44P11P12P13P14P21P22P23P24P31P32P33P34P41P42P43P44 ^j`G?^ ; ^0^ 00010000 ^ v`G?^ ! 8 () ( [^P^ 00010000 !( 8[]) ( 8[]) ( 8[])  (/^ |`G?^ ! !; ;^`^ ^00010000#upperUPPERCASE text -- Convert all lowercase characters to uppercase^P^ ^00020000ERROR(^\DMTCNL)/DM# Copyright 1985, UNIWARE^^ ^00030000.(/ , (DR)  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~؎&u) &GGu*&.+) ^ ^ 00040000>((VALUEDOMAINRANKLENGTHLIMITINDEXSEPARATOR[ $[   ]  [   ]]) ERRORZ^@`G?^ ; S; T; U; W; ; `;; ; ; ; ;;; ; ; IBWH^0^ ^00010000# x and o's 3d game^P^ ^00020000   #  // ^0^ ^00030000  [ ;;]^@^ ^00040000( /RESTORESCREEN)DM ^P^ ^00050000# The game strength can be specified thru the X parameter PA^P^ ^00060000. / / d # strength 0=100 (!) F^p^ ^00070000 : W@  UL  S T   []  PPDE^@^ ^00080000. Do you want to start ?  ^ ^ ^00090000쀂 RENUM^0^ ^00100000 :.(*/  ) ^@^ ^00110000.     S Y T  쀂 SEN^`^ ^00120000 :.( )  * OK, hit any key# 1=game over (ESC hit)LX ^ ^ ^00130000 BINDDOC^ ^ ^00140000 : CA^`^ ^00150000The game took (( `[] [])<) minutes. CMD^0^ _00160000  []<N _p^ _00170000 You took   minutes and me ( ` []) secs to "think".DFORI _@_ _00180000# 3 possible answers: yes, no or back _P_ _00190000. /Yy   ~Another one ? RE CMD_0 _ _00200000. /Bb _0_ 00210000 P . CMDO_`G?_`G? x_`G? @D_`G? @$]_`G?_`G?  _0aG?@? _  aG?"_ ; ,"_` _ (_00010000# AT is the tilting on each axis. PC is the planes coordinates(_@"_ ,_00020000 ,  ,[;;]  ; ,,_P(_ 1_00030000 ,  ,[;;;]  < ,1_@,_ 00040000 ,  ,[;]/  @ ,5_$aG?6_p'HaG? 7back : go back one move board : shows the board canhe : how can 'x' win cani : how can i win descr : info about the game end : ends the game eval : evaluate slots for me force : force machine to play somewhere OR with FORCE0help : all acceptable keywords and their meaning pass : allows to skip a turn twice : allows to play again `laG?]_8aG?k This workspace was written over the space of about 15 years...! It was first attempted in 1976 and the "real" interesting version came out in 79 while I was studying at the university. It included most of the logic which allows it to play in line mode today. In 85 I rewrote it on the Sharp APL system and added some user commands (help, go back, end, etc) and put it in public library (where it still resides) over there. In 87 I transfered it onto Sharp APL on the PC and STSC's APL*PLUS. It was slow (specially on Sharp's) but ran just the same (I had to modify the search procedure but the logic remained identical). Recently, this year (1993), I incorporated the ability to play using the G functions and "see" the cube better. It's not perfect yet (rotating the cube more than 90 degrees creates problems) but it's getting there! DanB 930909 _ cG?_ ; b; >_@_ _00010000# Show the last move if graphics are on_0_ _00020000 . (7 )? _P_ _00030000.( A)  b S  T b[ b[;] ;]@$_ _ _00040000  C b_ _ 00050000 : _ "` g`G?RESTORESCREEN@`m`G?AxisTiltA`y`G?UPPERCASEB``G?AIXSC``G?ttt3DD` `G?DisplayTime[1<F``G?TRAPG``G?WPOS?H``G?MsgPosaI``G?XcolorJ``G?OcolorK``G?ForceL``G?randomM``G?EDITN` `G?RotateAngley@P``G?STOPQ`aG?PcoordsR`  aG?SETCUBEVARST`!aG?ObsDistU`'aG?ForseV`-aG?Histurn W` 3aG?SCREENMODE\yO 2Y`EaG?HelpZ`KaG?gameover[`QaG?linemode\`WaG?gets]`caG?Slots ^` iaG?ScreenMode  L2 ``oaG?histura`{aG?forcesb`VG? c`aG?Historyd`aG?UCMDe`aG?RESULTf`aG?PACKBINg`aG?PDEF