27 lines
723 B
Text
27 lines
723 B
Text
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
|