JavaScript (E6) 481 492 550
Edit Fixed a nasty bug in knight moving. A lot of work to keep the byte count the same.
(Not counting leading spaces and newlines kept for readability)
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
Less Golfed
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
)
Test in FireFox/FireBug console
B("7k/8/8/8/8/1P6/P7/Q1q4K w - - 0 1")
Output
B3B4 A2A3 A2A4 A1B2 A1C3 A1D4 A1E5 A1F6 A1G7 A1H8 A1B1 A1C1 H1G1 H1H2 H1G2
also here is how test case input boards look like: http://i.stack.imgur.com/qlbH4.png
– golffzz – 2013-03-07T03:39:46.6901
possible duplicate of Play a valid chess move, given a board on stdin
– ugoren – 2013-03-07T13:56:56.8971@ugoren, I considered that, but enumerating all possible moves potentially eliminates some shortcuts. I'm not sure, though, why en passant isn't required: part of the point of FEN is that it includes enough information to make en passant possible. – Peter Taylor – 2013-03-07T14:09:45.623
@PeterTaylor I wrote that just to reduce the work. I wonder why no one interested in this golf :) – golffzz – 2013-03-08T21:12:40.563
I wrote a mate-in-2 solver a while back that takes FEN as input. I could dig it out and post it; of necessity, it already calculates all the moves. Mi2 problems don't (generally) use en passant or castling but do use pawn promotion - one thought on why you'd have certain move restrictions. – bazzargh – 2014-04-06T18:52:06.253
1@golffzz shouldn't your test case input 2 be 7k/8/8/8/8/8/PP6/Q1q4K w - - 0 1 instead of 6pk/6pp/8/8/8/p7/PP4pp/Q2p2pK w - - 0 1 (which among other things, seems to have pawns on the end ranks)? – Penguino – 2014-09-09T21:38:28.907
As pointed out by @golffzz, the test case 2 was wrong. Corrected. – edc65 – 2014-10-11T17:51:50.800
@feersum Your last edit is incorrect: See OP "Ignore check, checkmate, and stalemate, king cannot be captured situations too." – edc65 – 2014-10-13T14:52:14.170
@feersum no answer, so I removed the last edit – edc65 – 2014-10-14T04:33:31.863
Any other opinions on this? See discussion of check and test case 2 in my answer. – feersum – 2014-10-14T06:13:33.990