Anonymous user
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=
lintel=LB-2; turn=1; loY=
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; @@.=
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.*/
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&> */
'''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
one of them is shown below.
<pre style="height:
·╞···╔══╗···
·|···║··║···
·|···║··║···
·|╔══╝··╚══╗
·|║········║
·|╚══╗··╔══╝
·|···║··║···
·|···║··║···
·|···╚══╝···
─┼────┴────╨
·|··········
═══════════════════════════════════════════════════════════════════════════════
move 1 (3,3) with "0"
... previous
--- the next line means:
move
·
·|··
·╞··
·
·
·
·
·
·
·|··
·|···
·|···
·|···········
═════════════════════════════════════════════════════count of (above) wins =
* number of wins =
</pre>
|