JavaScript (E6) 481 492 550
Edit Memperbaiki bug jahat di knight moving. Banyak pekerjaan untuk menjaga byte tetap sama.
(Tidak termasuk spasi dan baris baru disimpan agar mudah dibaca)
B=f=>
[for(c of(o=b='',f=f.split(w=' '))[0])b+=-c?w.repeat(c):c<'0'?z=10:c]+
[...b].map((c,p)=>
(K=d=>(d=b[p+d])==w?0:d>'a'?m:d>'A'?-m:9)(0)-1||(
t='pPkKnNrRQqBb'.search(c),
O=d=>K(d)<1?o+=w+P(p)+P(p+d):0,
S=(d,s=0)=>O(d*++s)&&!K(d*s)&&S(d,s),
//o+='\n'+P(p)+' '+c, // Uncomment to display pieces list
t<2?[for(i of[~(s=t<1?z:-z),1-s])~K(i)||O(i)]+!K(s)&&O(s)&&(p/z|0)==t*5+1&!K(s+=s)&&O(s)
:t<6?[for(i of t<4?[1,9,z,11]:[12,8,21,19])O(i)+O(-i)]
:[for(i of[t>7&&9,t>7&&11,t<z,t<z&&z])S(i)+S(-i)]
)
,m=f[1]<'w'?1:-1,
//console.log(','+([...b]+',').replace(/1,0/g,'\n')), // Uncomment to display chessboard
P=p=>'ABCDEFGH'[p%z]+(9+~p/z|0))&&o
Kurang Golf
B=f=>(
o=b='',[for(c of f)b+=-c?'.'.repeat(c):c],
m=(w=b[72]=='w')?1:2,n=3-m,
t=0,
P=p=>'ABCDEFGH'[p%9]+(9+~p/9|0),
b=b.slice(0,71),
// console.log(b.replace(/\//g,'\n')), // Uncomment to display chessboard
[...b].map((c,p)=>{
r=p/9|0
K=k=>(k=b[k])=='.'?0:k>'a'?m:k>'A'?n:9
J=d=>K(p+d)<2,
O=d=>J(d)?o+=' '+P(p)+P(p+d):0,
S=(s,d)=>O(d*++s)&&!K(p+d*s)?S(s,d):0;
if(K(p)==2){
// o+='\n'+P(p)+ ' '+c; // Uncomment to display pieces list
if (c=='P')
{
(f=!K(p-9))&&O(-9),
f&r==6&&!K(p-18)&&O(-18),
[for(i of[10,8])K(p-i)==1&&O(-i)]
}
else if (c=='p')
{
(f=!K(p+9))&&O(+9),
f&r==1&&!K(p+18)&&O(+18),
[for(i of[10,8])K(p+i)==1&&O(+i)]
}
else if (c=='K' |c=='k')
[for(i of[1,8,9,10])O(i)+O(-i)]
else if (c=='N' | c=='n')
[for(i of[11,7,19,17])O(i)+O(-i)]
else
{
if (c!='r' & c!='R')
[for(i of[10,8])S(0,i)+S(0,-i)]
if (c!='b' & c!='B')
[for(i of[9,1])S(0,i)+S(0,-i)]
}
}
}),
o
)
Tes di konsol FireFox / FireBug
B("7k/8/8/8/8/1P6/P7/Q1q4K w - - 0 1")
Keluaran
B3B4 A2A3 A2A4 A1B2 A1C3 A1D4 A1E5 A1F6 A1G7 A1H8 A1B1 A1C1 H1G1 H1H2 H1G2