Morpion solitaire: Difference between revisions

→‎{{header|REXX}}: added x/y axis numeration, and a bigger win. -- ~~~~
m (→‎{{header|REXX}}: re-coded the REXX program to show a true cross, reformatted the output. -- ~~~~)
(→‎{{header|REXX}}: added x/y axis numeration, and a bigger win. -- ~~~~)
Line 320:
prompt='enter X,Y point and an optional character for placing on board',
'(or Quit):'; prompt=right(prompt,79,'─') /*right justify it.*/
@abc='abcdefghijklmnopqrstuvwxyz'; @abcU=@abc; upper @abcU; @digS=0123456789
@chars=@digS||@abcU||@abc'()[]{}<>«»' /*can't contain "empty", ?, blank*/
call GreekCross
jshots=Gshots
Line 364 ⟶ 362:
tranGC: if gC=='' then return arg(1); return translate(arg(1),copies(gC,12),'┌┐└┘│─╔╗╚╝║═')
/*─────────────────────────────────────GREEKCROSS subroutine────────────*/
GreekCross: wins=0; loX=1e85-1; hiX=0; LB=gS-1 /*Low Bar*/
lintel=LB-2; turn=1; loY=loX-1; hiY=0; ht=4+3*(LB-2) /*─ ─ */
Gshots=; nook=gS-2; Hnook=ht-nook+1; TB=ht-LB+1 /*Top Bar*/
/*─ ─ */
Line 382 ⟶ 380:
end /*select*/
end /*y*/
 
@abc='abcdefghijklmnopqrstuvwxyz'; @abcU=@abc; upper @abcU; @digS=0123456789
@chars=@digS||@abcU||@abc; @@.=
@chars=@digS||@abcU||@abcchars'()[]{}<>«»' /*can't contain "empty", ?, blank*/
 
call display
Line 396 ⟶ 398:
display: call t; do y=hiY to loY by -1; _=indent /*start at a high Y.*/
do x=loX to hiX /*build an "X" line.*/
_!=_||@.x.y; xo=x==0; yo=y==0
if !==empty then do
if xo then !='|'
if xo & y//5 ==0 then !='├'
if xo & y//10==0 then !='╞'
if yo then !='─'
if yo & x//5 ==0 then !='┴'
if yo & x//10==0 then !='╨'
if xo & yo then !='┼'
end
_=_||!
end /*x*/
call t _ /*...and display it.*/
Line 476 ⟶ 488:
x=xx
do y=yy-1 by -1; x=x+1; if @.x.y==empty then leave; z=z||@.x.y; end
return eureka+countAline(z) /*───────count diag wins: up&<, down&> */</lang>
'''output''' when running 500 trials, the highest win was a meager 43 (three games, all different), and
</lang>
'''output''' when running 1,500 trials, the highest win was a meager 4344 (threefour games, all different), and
one of them is shown below.
<pre style="height:95ex110ex;overflow:scroll">
·╞···╔══╗···
·|···║··║···
·|···║··║···
·|╔══╝··╚══╗
·|║········║
·├║········║
·|╚══╗··╔══╝
·|···║··║···
·|···║··║···
·|···╚══╝···
─┼────┴────╨
·|··········
═══════════════════════════════════════════════════════════════════════════════
 
move 1 (3,3) with "0"
... previous 4243 moves elided ... above is the initial board (grid) ...
--- the next line means: 43rd44th move, position=2,8,5 marked with an "gh" ---
move 4344 (2,8,5) with "gh"
 
··|···········
·|···╔══╗FbTXUQ····
····║S·║··W╔══╗F···
·Cg1║OK║3|···║OR║P··Dc·
·╔══╝57╚══╗W|C·1║VM║3SD·
·║aeAN·BQP║U|╔══╝57╚══╗·
·║f|║·8HG9IV║THA·KBJY║·
·╚══╗46╔══╝Z├║·N8IG9hZ║·
···0║·M║2RJ·|╚══╗46╔══╝·
·|···║YX║Ld0║cL║2···
·|···╚══╝E·║da║e···
·|······b··╚══╝E···
·············─┼──g─┴─f──╨─
·|···········
═════════════════════════════════════════════════════count of (above) wins = 4344
 
* number of wins = 4344
</pre>