Generate random chess position: Difference between revisions

→‎{{header|REXX}}: enhanced REXX program to also display a "pictorial" representation of the chessboard and pieces.
(→‎{{header|REXX}}: added the REXX language.)
(→‎{{header|REXX}}: enhanced REXX program to also display a "pictorial" representation of the chessboard and pieces.)
Line 73:
end /*#*/
/*────────────────────────────────────────────────────────────────────────────*/
FEN: fen=; do r=8 for 8 by -1; $= /*FEN: Forsyth-Edwards Notation.*/
do f=8 for 8 by -1; $=$ || @.r.f; end /*f*/
say $ /*display a chessboard rank. */
$=strip($,'T',.)
$=strip($,'T',.) /*remove any trailing periods. */
do e=7 for 6 by -1; $=changestr(copies(.,e),$,e); end /*e*/
fen=fen || translate($,1,.)'/'
end /*r*/
say 'FEN='fen "w - -" 0 1
say 'FEN='fen "w - -" 0 1 /*show Forsyth-Edwards Notation.*/
return</lang>
'''output''' &nbsp; (using some random chess position):
<pre>
...p....
.....Pq.
Q.......
..K....N
........
..q.....
.......k
...B....
 
FEN=3p/5Pq/Q/2K4N//2q/7k/3B/ w - - 0 1
</pre>