Anonymous user
Morpion solitaire: Difference between revisions
m
→{{header|REXX}}: re-coded the REXX program to show a true cross, reformatted the output. -- ~~~~
m (→{{header|REXX}}: changed wording in the header section. -- ~~~~) |
m (→{{header|REXX}}: re-coded the REXX program to show a true cross, reformatted the output. -- ~~~~) |
||
Line 310:
gS=gS/1
if gS<3 then call err "grid size is too small:" gS
sw=linesize()-1
indent=left('',max(0,sw-gS-10)%2) /*indentation used board display.*/
empty='fa'x /*the empty grid point symbol. */
@.=empty /*field (grid) is infinite. */
CBLF=player\=='' /*carbon-based lifeform ? */
if CBLF then oFID=player /*oFID is used for the game log. */
Line 360 ⟶ 362:
t: say arg(1); call lineout oFID,arg(1); return
Gshot: Gshots=Gshots arg(1)','arg(2); return
tranGC: if gC=='' then return arg(1); return translate(arg(1),copies(gC,12),'┌┐└┘│─╔╗╚╝║═')
/*─────────────────────────────────────GREEKCROSS subroutine────────────*/
GreekCross: wins=0; loX=1e85; hiX=0;
/*─ ─ */
do y=1 for ht; _top='╔'copies('═',lintel)'╗' ; _top=tranGC(_top)
_bot='╚'copies('═',lintel)'╝' ; _bot=tranGC(_bot)
_hib='╔'copies('═',lintel)'╝'left('',lintel)'╚'copies('═',lintel)'╗' ; _hib=tranGC(_hib)
_lob='╚'copies('═',lintel)'╗'left('',lintel)'╔'copies('═',lintel)'╝' ; _lob=tranGC(_lob)
select
when y==1
when y==
when y
when y>LB & y<TB then do x=1 by ht-1 for 2; call place x,y,_sid; end
otherwise do x=LB by TB-LB for 2; call place x,y,_sid; end
end /*select*/
end /*y*/
Line 385 ⟶ 394:
return
/*─────────────────────────────────────DISPLAY subroutine───────────────*/
display: call t; do y=hiY to loY by -1;
do x=loX to hiX /*build an "X" line.*/
end /*x*/
call t
end /*y*/
if wins
else call t right('count of (above) wins =' wins,79,'═')
call t
return
/*─────────────────────────────────────PLACE subroutine─────────────────*/
Line 422 ⟶ 433:
return 0
end
call t
wins=wins+newWins; @.xx.yy=pointChar; call display; turn=turn+1
return 1
Line 466 ⟶ 477:
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
one of them is shown below.
<pre style="height:95ex;overflow:scroll">
···
···
···
╔══╝··╚══╗
╚══╗··╔══╝
···
···
═══════════════════════════════════════════════════════════════════════════════
▲ --- the next line says: 44th move, position=9,2 marked with an "h" ---
move 1 (3,3) with "0"
·············▼
... previous 42 moves elided ... above is the initial board (grid) ...
······X······▼
--- the next line means: 43rd move, position=2,8 marked with an "g" ---
move 43 (2,8) with "g"
▲ ·············
····╔══╗F····
····║S·║·····
·Cg1║OK║3·Dc·
·╔══╝57╚══╗W·
·║aeAN·BQP║U·
·║f·8HG9IV║T·
·╚══╗46╔══╝Z·
···0║·M║2RJ··
·············▼
····║YX║Ld···
═════════════════════════════════════════════════════count of (above) wins = 44▼
····╚══╝E····
* number of wins = 44▼
▲ ·············
</pre>
|