Generate Chess960 starting position: Difference between revisions

no edit summary
No edit summary
Line 1,452:
{{out}}
<pre>NNRQBBKR</pre>
 
=={{header|M2000 Interpreter}}==
 
<syntaxhighlight lang="m2000 interpreter">
Module Chess960 {
function OneFrom960$ {
def q$="♕", h$="♘", t$="♖", b$="♗", k$="♔"
def integer b1, b2, t1, t2, k, q
buffer p as integer *8
return p, 0:=string$(h$, 8)
k=random(1, 6)
t1=random(0,k-1)
t2=random(k+1, 7)
used=list:=k, t1, t2
do : b1=random(0,7): until not exist(used, b1)
append used, b1
n=b1 mod 2
do : b2=random(0,7): until not exist(used, b2) and b2 mod 2 <> n
append used, b2
do : q=random(0,7): until not exist(used, q)
// place pawns to positions
return p, k:=k$, t1:=t$, t2:=t$, b1:=b$, b2:=b$, q:=q$
=Eval$(p)+{
} // append new line to every solution
}
document doc$
For i=0 to 7:doc$+=OneFrom960$(): next
clipboard doc$
report doc$
}
Chess960
</syntaxhighlight>
{{out}}
<pre>
♘♗♗♘♖♕♔♖
♗♕♖♘♘♔♖♗
♗♗♕♖♔♘♖♘
♘♖♕♗♗♔♖♘
♖♔♘♗♖♕♗♘
♖♔♖♗♘♘♗♕
♘♘♗♕♖♗♔♖
♖♔♕♘♘♗♗♖
</pre>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
404

edits