Morpion solitaire: Difference between revisions
Content added Content deleted
(force a table of contents with a __TOC__. -- ~~~~) |
m (→{{header|REXX}}: replaced the example with a higher win, removed dead code. -- ~~~~) |
||
Line 291: | Line 291: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
This REXX program is an attempt to play (badly, and with random moves) the game of Morpion solitaire by a computer. |
This REXX program is an attempt to play (badly, and with random moves) the game of Morpion solitaire by a computer. |
||
<br>The program also allows a carbon-based life form (er, that is, a human) to play. |
<br><br>The program also allows a carbon-based life form (er, that is, a human) to play. |
||
<br>This is a work in progress and currently doesn't log the moves in the manner asked for by this task. |
<br><br>This is a work in progress and currently doesn't log the moves in the manner asked for by this task. |
||
<br>The moves are marked by ''' 0123456789ABC...XYZabc...xyz()[]{}<>«» ''' and thereafter by a plus sign (+) on the board which is shown in 2D. |
<br>The moves are marked by ''' 0123456789ABC...XYZabc...xyz()[]{}<>«» ''' and thereafter by a plus sign (+) on the board which is shown in 2D. |
||
<br>This allows 73 unique moves to be shown on the board (or grid), but all moves are also logged to a file. |
<br>This allows 73 unique moves to be shown on the board (or grid), but all moves are also logged to a file. |
||
Line 383: | Line 383: | ||
end /*y*/ |
end /*y*/ |
||
@abc='abcdefghijklmnopqrstuvwxyz'; @ |
@abc='abcdefghijklmnopqrstuvwxyz'; @chars='0123456789'translate(@abc)||@abc |
||
@chars=@digS||@abcU||@abc; @@.= |
|||
@chars=@chars'()[]{}<>«»' /*can't contain "empty", ?, blank*/ |
@chars=@chars'()[]{}<>«»' /*can't contain "empty", ?, blank*/ |
||
Line 401: | Line 400: | ||
do x=loX to hiX /*build an "X" line.*/ |
do x=loX to hiX /*build an "X" line.*/ |
||
!=@.x.y; xo=x==0; yo=y==0 |
!=@.x.y; xo=x==0; yo=y==0 |
||
if !==empty then do |
if !==empty then do /*grid transformation*/ |
||
if xo then !='|' |
if xo then !='|' |
||
if xo & y//5 ==0 then !='├' |
if xo & y//5 ==0 then !='├' |
||
Line 410: | Line 409: | ||
if xo & yo then !='┼' |
if xo & yo then !='┼' |
||
end |
end |
||
_=_||! |
_=_ || ! |
||
end /*x*/ |
end /*x*/ |
||
call t _ /*...and display it.*/ |
call t _ /*...and display it.*/ |
||
Line 495: | Line 494: | ||
'''output''' when running 1,500 trials, the highest win was a meager 44 (four games, all different), and |
'''output''' when running 1,500 trials, the highest win was a meager 44 (four games, all different), and |
||
one of them is shown below. |
one of them is shown below. |
||
<pre style="height: |
<pre style="height:100ex;overflow:scroll"> |
||
·╞···╔══╗··· |
·╞···╔══╗··· |
||
·|···║··║··· |
·|···║··║··· |
||
Line 511: | Line 510: | ||
move 1 (3,3) with "0" |
move 1 (3,3) with "0" |
||
... previous |
... previous 46 moves elided ... above is the initial board (grid) ... |
||
--- the next line means: |
--- the next line means: 47th move, position=9,9 marked with an "k" --- |
||
move |
move 47 (9,9) with "k" |
||
·|············ |
|||
·|··iQagP····· |
|||
·╞j·d╔══╗F···· |
|||
·|·hO║NL║ck··· |
|||
·|CZ1║bK║3MD·· |
|||
·X╔══╝57╚══╗f· |
|||
·|║YHASGBJR║·· |
|||
·├║UT8I·9·e║·· |
|||
·|╚══╗46╔══╝·· |
|||
·V··0║W·║2···· |
|||
·|···║··║····· |
|||
·|···╚══╝E···· |
|||
─┼────┴────╨── |
|||
·|············ |
|||
═════════════════════════════════════════════════════count of (above) wins = 44 |
|||
═════════════════════════════════════════════════════ count of (above) wins = 47 |
|||
* number of wins = |
* number of wins = 47 |
||
</pre> |
</pre> |