[Question]
  [
Alternate name: `ChessMoveQ`
Given a list of up to 32 elements, each consisting of 4 elements, and a second list with 4 elements, determine whether the move detailed in the second input is a valid chess move.
The first list indicates the position of all 32 pieces on the board. Each element will follow the structure `<colour>, <piece-name>, <x-coord>, <y-coord>`, such as `["W", "K", 5, 1]`, which indicates that the white king is on `5, 1` (`e1` on a normal chess board). All elements of the first input will be unique. `<x-coord>` and `<y-coord>` will always be between 1 and 8. One example would be:
```
[["B", "K", 3, 8], ["B", "Q", 1, 5], ["B", "N", 4, 7], ["B", "N", 7, 8],
 ["B", "B", 2, 4], ["B", "R", 4, 8], ["B", "R", 8, 8], ["B", "P", 1, 7],
 ["B", "P", 2, 7], ["B", "P", 3, 6], ["B", "P", 5, 6], ["B", "P", 6, 7],
 ["B", "P", 7, 7], ["B", "P", 8, 7], ["W", "K", 5, 1], ["W", "Q", 6, 3],
 ["W", "N", 3, 3], ["W", "B", 5, 2], ["W", "B", 6, 4], ["W", "R", 1, 1],
 ["W", "R", 8, 1], ["W", "P", 1, 3], ["W", "P", 2, 2], ["W", "P", 3, 2],
 ["W", "P", 4, 4], ["W", "P", 6, 2], ["W", "P", 7, 2], ["W", "P", 8, 3]]
```
which would represent the board:
[![an example chessboard](https://i.stack.imgur.com/NhRX7.png)](https://i.stack.imgur.com/NhRX7.png)
The second input will consist of the same structures as the sublists of the first one, but rather than the x and y coordinates indicating where the piece is, they are indicating where it is trying to move to.
For the above example, a valid move could be `["W", "B", 4, 3]` (bishop moves one square forward and to the left), and an invalid move could be `["B", "R", 4, 1]` as the rook would have to move through the knight, and the pawn to get to the square. As the move could refer to multiple pieces at times, you must test whether *any* of the specified pieces can make the move, not just one of them. For instance, the first example is valid for only one bishop, but it is still a valid move. However, neither black rook can perform the second move, so it is invalid.
Your task is to determine whether the move detailed in the second input is a valid chess move. The validity of a rule varies, depending on the piece trying to move (click on the name of the piece for a diagram of valid moves):
* **Any piece**: No pieces can move onto an already occupied square, or off the board, unless that square is occupied by a piece from the other colour. For example, a white piece may move onto a square occupied by a black piece, but not a white piece. Additionally, no pieces, except for Knights, can move to squares which are directly obstructed by another piece.
	+ A move by piece **B** to square **C** is "directly obstructed" by piece **A** if **A** is directly, in a straight (orthogonal or diagonal) line, between **B** and **C**.
* **Any piece**: The position of the king can also affect the validity of a piece's move. If either of these two conditions are met, the move is invalid:
	+ Exposing the king to check, by moving a piece on the same side as the endangered king. This only applies if a non-opposing piece makes the move, rather than an opposing piece moving to place the king into check.
	+ Leaving the king in check, in which case it *has* to move out of check. Therefore, if the king is in check and the move dictates that another piece moves, it is an invalid move, *unless* the other piece is preventing check. A piece can prevent check in one of two ways: either it takes the piece performing check, or it obstructs the path between the piece performing check and the king.
	+ A "check" is a situation in which the king's opponent could (if it was their turn to move) legally move a piece onto that king. This rule does not apply recursively, i.e. a king is in check even if the move by the opponent onto that king would leave their own king in check.
* [**Pawns**](https://i.stack.imgur.com/VmwIB.gif): A pawn can move forwards (i.e. upwards if white, downwards if black) one square to an unoccupied square. There are also three special situations:
	+ If the pawn hasn't yet moved (you can determine this using the Y-coordinate; white pawns haven't moved if their Y-coordinate is 2, black pawns haven't moved if their Y-coordinate is 7), the pawn is allowed to move two squares forward to an unoccupied square.
	+ If there is an opponent's piece diagonally in front of the pawn (i.e. on the square to the north-west or north-east of the pawn if it is white, or to the south-west or south-east if it is black), the pawn is allowed to move onto the occupied square in question.
	+ If a pawn moves to the final Y-coordinate (8 for white, or 1 for black) in normal chess rules it must be promoted to a queen, rook, knight, or bishop of the same color. For the purposes of this question, the choice of promotion is irrelevant to whether the move is valid or not (and cannot be expressed in the input format), but pawn moves that would result in promotion must be allowed.
* [**Bishops**](https://i.stack.imgur.com/0rNIP.gif): Bishops can move between 1 and 8 squares along any continuous non-obstructed intercardinal (i.e. diagonal) path.
* [**Knights**](https://i.stack.imgur.com/utNVJ.jpg): Knights can move in an `L` shape, consisting of either of the following (equivalent) moves:
	+ A single square in any cardinal direction, followed by a 90/270° turn, followed by a final move of 2 squares forward.
	+ 2 squares in any cardinal direction, followed by a 90/270° turn, followed by a final move of a single square forward.
(Remember that the path of a knight cannot be blocked by intervening pieces, although its final square must still be legal.)
* [**Rooks**](https://i.stack.imgur.com/aw0ID.gif): Rooks can move between 1 and 8 squares along any continuous non-obstructed cardinal path.
* [**Queens**](https://i.stack.imgur.com/J0d5P.gif): Queens can move between 1 and 8 squares along any continuous cardinal or intercardinal (i.e. diagonal) non-obstructed path.
* [**Kings**](https://i.stack.imgur.com/rUiHI.gif): Kings move like queens, except that they are limited to moving only one square per move (i.e. a king can only move to cardinally or diagonally adjacent squares). As a reminder, you cannot make a move that leaves your king in check; thus you cannot move your king into check, either.
The rules of chess also contain special moves called "castling" and "en passant". However, because the legality of these moves depend on the history of the game, not just the current position (and because castling requires moving two pieces at once, which doesn't fit with the input format), you should consider neither of these moves to exist (i.e. a move that would be castling or en passant should be considered illegal).
You may output any two distinct results to indicate the validity of a move, and you may take input in a method you want. You may also choose 0-indexing rather than 1-indexing for the positions if you prefer. This is a [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so shortest code wins!
## Test cases
```
Board
Move => Output (Reason)
[["B", "K", 3, 8], ["B", "Q", 1, 5], ["B", "N", 4, 7], ["B", "N", 7, 8], ["B", "B", 2, 4], ["B", "R", 4, 8], ["B", "R", 8, 8], ["B", "P", 1, 7], ["B", "P", 2, 7], ["B", "P", 3, 6], ["B", "P", 5, 6], ["B", "P", 6, 7], ["B", "P", 7, 7], ["B", "P", 8, 7], ["W", "K", 5, 1], ["W", "Q", 6, 3], ["W", "N", 3, 3], ["W", "B", 5, 2], ["W", "B", 6, 4], ["W", "R", 1, 1], ["W", "R", 8, 1], ["W", "P", 1, 3], ["W", "P", 2, 2], ["W", "P", 3, 2], ["W", "P", 4, 4], ["W", "P", 6, 2], ["W", "P", 7, 2], ["W", "P", 8, 3]]
["W", "R", 8, 2] => True (The rook on h1 can move forward one)
[['B', 'K', 6, 8], ['B', 'Q', 1, 7], ['B', 'N', 1, 3], ['B', 'N', 7, 1], ['B', 'B', 8, 8], ['B', 'B', 2, 5], ['B', 'R', 4, 3], ['B', 'R', 1, 5], ['B', 'P', 5, 5], ['B', 'P', 7, 2], ['B', 'P', 5, 7], ['B', 'P', 5, 6], ['B', 'P', 4, 4], ['W', 'K', 7, 3], ['W', 'Q', 3, 2], ['W', 'N', 4, 8], ['W', 'N', 7, 5], ['W', 'B', 1, 1], ['W', 'B', 8, 1], ['W', 'R', 1, 8], ['W', 'R', 3, 7], ['W', 'P', 8, 2], ['W', 'P', 6, 3], ['W', 'P', 4, 2], ['W', 'P', 1, 4], ['W', 'P', 8, 7]]
['W', 'N', 1, 5] => False (Neither knight to move to a5 from where they are)
[['B', 'K', 7, 3], ['B', 'Q', 2, 4], ['B', 'N', 5, 2], ['B', 'N', 1, 6], ['B', 'B', 7, 7], ['B', 'B', 1, 8], ['W', 'K', 7, 1], ['W', 'Q', 6, 1], ['W', 'N', 5, 6], ['W', 'N', 3, 3], ['W', 'B', 2, 2], ['W', 'B', 6, 5]]
['B', 'K', 8, 3] => False (The white bishop would put the king in check)
[['B', 'K', 7, 6], ['B', 'Q', 8, 3], ['B', 'N', 7, 7], ['B', 'N', 8, 7], ['B', 'B', 2, 2], ['B', 'B', 3, 8], ['B', 'R', 1, 1], ['B', 'R', 1, 6], ['B', 'P', 8, 5], ['B', 'P', 4, 3], ['B', 'P', 8, 6], ['W', 'K', 7, 8], ['W', 'Q', 7, 2], ['W', 'N', 5, 1], ['W', 'N', 4, 6], ['W', 'B', 1, 2], ['W', 'B', 2, 6], ['W', 'R', 4, 4], ['W', 'R', 3, 6], ['W', 'P', 5, 2], ['W', 'P', 6, 2]]
['B', 'N', 5, 8] => False (The white queen currently has the king in check, and this move doesn't prevent that)
[['B', 'K', 7, 6], ['B', 'Q', 8, 3], ['B', 'N', 7, 7], ['B', 'N', 8, 7], ['B', 'B', 2, 2], ['B', 'B', 3, 8], ['B', 'R', 1, 1], ['B', 'R', 1, 6], ['B', 'P', 8, 5], ['B', 'P', 4, 3], ['B', 'P', 8, 6], ['W', 'K', 7, 8], ['W', 'Q', 7, 2], ['W', 'N', 5, 1], ['W', 'N', 4, 6], ['W', 'B', 1, 2], ['W', 'B', 2, 6], ['W', 'R', 4, 4], ['W', 'R', 3, 6], ['W', 'P', 5, 2], ['W', 'P', 6, 2]]
['B', 'N', 7, 5] => True (The king is in check, and the knight blocks that)
[['B', 'K', 8, 3], ['B', 'Q', 6, 5], ['B', 'N', 7, 8], ['B', 'N', 3, 7], ['B', 'B', 4, 1], ['B', 'B', 1, 1], ['W', 'K', 7, 7], ['W', 'Q', 7, 1], ['W', 'N', 2, 2], ['W', 'N', 1, 3], ['W', 'B', 3, 5]]
['B', 'B', 2, 2] => True (takes the white knight)
[['B', 'K', 6, 1], ['B', 'Q', 6, 2], ['W', 'K', 8, 1]]
['B', 'Q', 7, 1] => True (Smallest checkmate possible, in terms of bounding box)
```
This challenge was [sandboxed](https://codegolf.meta.stackexchange.com/a/14204/66833). It received downvotes, without any explanation, so I decided to post it anyway
  
[Answer]
# Regex (PCRE2), ~~931~~ ~~925~~ 837 bytes
This solution departs from the problem statement in that two board states are passed to the regex, instead of one board state and a move. The move is inferred from the difference between the two board states. So I made it the job of the TIO program to take the test cases in the format provided by this question, find all instances of the described piece on the board, and with each one, try moving it to the destination position and evaluating the regex with that possibility, finding if any are reported by the regex as valid. If this is not okay, let me know; it's possible to implement a regex as position + move, but would be much less elegant and require serious refactoring.
The board is represented in 8×8 ASCII where white pieces are uppercase and black are lowercase: **P**awn, k**N**ight, **B**ishop, **R**ook, **Q**ueen, **K**ing. Black's side (the 8th rank) is on the top and white's side (the 1st rank) is on the bottom. Each rank is separated by a newline, and empty squares are marked as `-`. The two board positions are separated by an extra newline.
The actual aim of this project is to validate entire games, not just single moves. See below for the current state of progress.
```
()?(?>|((.|
(?=.)){2})((?=(\X{72})-))((?=(?(1)[-a-z]|[-A-Z])))((?5)(?(?=(.*
)
)[qnrb]|p))((?5)(?(?=(?8){8}
)[QNRB]|P)))(?>((.)(?=(?5)\11)|(?(m)$)((?(1)(-(?=(?9))(?=(?3){8}((?3){9})?P(?4))(?(-1)(?=(?8){4}
))|[a-z](?=(?9))(?=(?3){7}(?2)?P(?4)))|(p(?4)((?=(?3){8}((?3){9})?-(?7))(?(-1)(?=(?8){7}
))|(?=(?3){7}(?2)?[A-Z](?7)))))|(?<e>(?6).)?(?=(?i:(?|(?(e)|(B|Q))(?27)(?(e)(B|Q))|(?(e)|(R|Q))(?31)(?(e)(R|Q))|(?(e)|(N))(?34)(?(e)(N))|(?(e)|(K))(?35)?(?(e)(K))))(?(e)(?<=(?!(?6)).)(?4)|(?6).(?5)\19))(?(e)(?=(?5)\20)|(?!(?6)).(?4)))(?<m>)|(?(+1)$)(.))+
)+\k<m>
(?!\X{0,70}((?(1)p|k)(?=(?3){7}(?2)?(?(1)K|P))|(?i:(?<E>(?!(?6))K)?((?(E)|((?6)[BQ]))(()?((?(-1)-)(?3){7}(?(-2)(?2)))+)(?(E)(?-4))|(?(E)|((?6)[RQ]))(-*|((?(-1)-)(?3){8})+)(?(E)(?-3))|(?(E)|((?6)N))((?<=..)(?2){3}|(?=.)(?2){5}|(?2){8}(?2)?)(?(E)(?-2)))(?(E)|(?&E))|K((?3){7,9})?K)))
```
[Try it online!](https://tio.run/##7Vhbc9pIFn7nV7SZnajbIMcSFynGmDIxW3ExITbG60wwRcnQGBUgKZII6xj/9fGcvgipkWf3ZR72YakUqL9z6/Od06flTIJAf5xMXn@Z0pnrUXT1sd8xxx@/XHTGt73Lwfju8mLwCdmFX1xvslxPKToNJiE1j@ZnhcncCdE4GI5QE/WL7c1m8VBZ//709HUwr2/m@BWTFm6dbTE@2hZwq3lEyLP5QjA84vuvzxY860QsW9ggQ93Rf462Q/1c/zYiXFAjIAHx0WGBFMjwuxc@jLaBImrZ5Nl@AeF1r98eba@YYesMQhIurZF7wyBb0F2RfzA7CIR1LvpAhEqFOcD898MLaV3hVpVJsG6QJEAVApDtkO1v39R6wS0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fzIupq5etTVE6GeUHlG6mpv1946I@Yo13r221UU73STdRhSL14@IfZylytkGTneFGA3Eqdi6tPI09j/KtAfYAYSJ/5/sf9Xim0loy298EQ1o1xBaTLvHpb@ZBG9VUg7N9nqCpW9LE3tzLTZK2Q1dx@qt0Q32xBZuvfINXMFMHKTraLOsV0fpaTEzoKKRhfHQNCQv/iNXOqmumV@salKfM9pqJuVs1xS/vc4MA9vsRQFfhS5D0vKXodRTMNVxP5sevDX3pQV6sH/N/ljMls6j9GrvuSvurr9Jw "C++ (gcc) – Try It Online")
Pretty-printed, and partially ungolfed (absolute backrefs changed to relative, and capturing groups changed to non-capturing, or in some cases atomic for speed):
```
# Chess move validation regex (PCRE)
()?                 # decide whether to evaluate this as white's or black's move; \1 set = white, \1 unset (NPCG) = black
(?>|                # subroutines:
  ((.|\n(?=.)){2})                  # (?3) = for moving within the board, without wrapping to the next board, (?2) = (?3){2}
  ((?=                              # (?4) = assert that position of just-consumed piece is vacated on the next turn
    (\X{72})                        # (?5) = skip to the position of the just-consumed piece on the next turn
  -))
  ((?=(?(1)[-a-z]|[-A-Z])))         # (?6) = assert that the piece at the current position belongs to the current player's opponent or is empty
  ((?5)(?(?=(.*\n)\n)[qnrb]|p))     # (?7) = black pawn that might be promoted, (?8) = .*\n
  ((?5)(?(?=(?8){8}\n)[QNRB]|P))    # (?9) = white pawn that might be promoted
)
(?>
  (?>
    # Handle squares that don't change (empty->empty or pieces that doesn't move)
    (.)(?=(?5)\g{-1}) |
    # Handle a piece that moves (and optionally captures an enemy piece)
    (?(m)$)  # allow only one move to be made per turn
    (?>
      (?(1)
        (?:                                                         # white pawn
            -  (?=(?9))(?=(?3){8}((?3){9})?P(?4))(?(-1)(?=(?8){4}\n)) |   # move 1 or 2 spaces forward
          [a-z](?=(?9))(?=(?3){7}(?2)?     P(?4))                     )   # capture diagonally
      |
        (?:p(?4)(?:                                                 # black pawn
          (?=(?3){8}((?3){9})?  -  (?7))(?(-1)(?=(?8){7}\n)) |            # move 1 or 2 spaces forward
          (?=(?3){7}(?2)?     [A-Z](?7)) )                   )            # capture diagonally
      ) |
      # bishops, rooks, queens, knights, or kings
      (?<e>(?6).)?   # decide between scanning forward (<e> is unset) or backwards (<e> is captured)
      (?=
        (?i:
          (?|
            (?(e)|(B|Q)) (?&B)  (?(e)(B|Q)) | # bishops or queens
            (?(e)|(R|Q)) (?&R)  (?(e)(R|Q)) | # rooks or queens
            (?(e)|(N  )) (?&N)  (?(e)(N  )) | # knights
            (?(e)|(K  )) (?&K)? (?(e)(K  ))   # kings
          )
        )
        (?(e)(?<=(?!(?6)).)(?4)|(?6).(?5)\g{-2})   # verify that the piece moved, and optionally captured piece, are of the correct color
      )
      (?(e)(?=(?5)\g{-1})|(?!(?6)).(?4))   # verify that the piece moved is the same type and color at its destination in the next turn's board position
    )(?<m>) |
    (?(+1)$)(.)  # handle the destination/source square that a piece moved to/from (only allow matching one of these per turn)
  )+\n
)+
\k<m>         # assert that a move has taken place
\n
# don't allow moving into check  
(?!
  \X{0,70}
  (?:
    # pawns (capture diagonally)
    (?(1)p|k)(?=(?3){7}(?2)?(?(1)K|P)) |
    # bishops, rooks, queens, knights, or kings
    (?i:
      (?<E>(?!(?6))K)?   # decide between scanning forward (<E> is unset) or backwards (<E> is captured)
      (?:
        (?(E)|((?6)[BQ])) (?<B>()?((?(-1)-)(?3){7}(?(-2)(?2)))+)         (?(E)(?-4)) | # bishops or queens
        (?(E)|((?6)[RQ])) (?<R>-*|((?(-1)-)(?3){8})+)                    (?(E)(?-3)) | # rooks or queens
        (?(E)|((?6) N  )) (?<N>(?<=..)(?2){3}|(?=.)(?2){5}|(?2){8}(?2)?) (?(E)(?-2))   # knights
      )
      (?(E)|(?&E)) |
      K(?<K>(?3){7,9})?K   # kings
    )
  )
)
```
*-88 bytes by using non-atomic subroutine calls, thus retargeting from PCRE1 to PCRE2*
The version above has been modified not to allow en passant or castling, but the full project is currently at a state where it validates every type of move, starting at the initial board state (which must be the standard chess starting position – Chess960 is not supported, yet at least). The full rules of en passant and castling are enforced.
[Here is a sample game validated by the full regex [regex101.com]](https://regex101.com/r/GUZl7X/6).
An invalid move will result in every subsequent board position not being matched/highlighted. Checkmate/stalemate detection, and thus detection of who the winner is (or if it's a draw), is not yet implemented; that's why the final board state in this example is not highlighted.
[Here is a C/C++ program that converts algebraic notation into the format recognized by this regex.](https://github.com/Davidebyzero/chessconv) The algebraic notation currently must be put in the form of an array inline in the source code, with separate strings for each move, but reading it as single string from stdin or a command-line argument, with the entire sequence of moves separated by spaces and dot-terminated move numbers, is planned.
I also started on a regex that validates a full game purely in algebraic chess notation, with the standard initial position being implied. All it needs is an empty "scratch board" appended at the end of the input (after the list of moves). I'm pretty sure it's possible to implement this in full, and plan on finishing it sometime.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 693 bytes
```
(b,M,[c,p,x,y]=M,m=Math.abs,J='some',F=(C,X,Y,W,T,Q=P=>P[2]==X&P[3]==Y)=>W.filter(([i,j,k,l])=>i==C&j==(T||j)&[B=m(H=k-X)==m(V=l-Y)&!W[J](([I,J,K,L])=>(K-k)/H==(L-l)/V&(k>X?K<k&K>X:K>k&K<X)&(l>Y?L<l&L>Y:L>l&L<Y)),R=!(k-X&&l-Y)&!W[J](([I,J,K,L])=>k-X?L==Y&(k>X?K<k&K>X:K>k&K<X):K==X&(l>Y?L<l&L>Y:L>l&L<Y)),B|R,k==X?!W[J](Q)&(l-Y==1-2*(C<'E')|l-Y==2-4*(C<'E')&!W[J](E=>E[2]==X&E[3]==Y+1-2*(C<'E'))):m(k-X)==1&l-Y==1-2*(C<'E')&W[J](E=>Q(E)&E[0]!=i),(k-X)**2+(l-Y)**2==5,(k-X)**2+(l-Y)**2<3]['BRQPNK'.search(j)]))=>x>0&x<9&y>0&y<9&!b[J](([i,j,k,l])=>k==x&l==y&(i==c|j=='K'))&F(c,x,y,b,p).some(e=>!F(c<'E'?'W':'B',...(W=b.map(E=>E[J]((a,i)=>a!=e[i])?E:M)).find(Z=>Z[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TYBMqo27Yw0gQC5iQyImIJbmd5Fudmv0TUhXfuajy@8bkvkDCBJH5VXKPCxLiEXjrQlZ8PzkK8xJSFtKKQlubYtSdsCcfIWGZK0JvQoPDO5a03otvY11xqB5CL7T0N@o4ZYVy8EW7oQTCDJqEq3XzmkFw1pSW8DeEe61cZWZbsQyZCE1KULoQmP/9kP115sukTOgEWlFzdclFZFvtVq6ScU/xMgPqHOn1NacohXR4y@7r7ukEi5f1bwcr9LjsqSr1X2T8p5H1H@rSmKeLiPIy3e/4Ojn2GMxTpCav@9/Q8 "JavaScript (Node.js) – Try It Online")
I sought out this challenge with the aim of combining CodeGolf with a project idea for a chess app. I realized that most of the functionality of a chess app hinges on the ability to validate a chess move, and while the challenge's input format does not explicitly include *which* piece in particular (which white bishop?) is moving, I still found this fun to write. My original working code was 1200 bytes, so I'm proud I managed to cut it down to 693. It takes input in the same format as the spec and outputs 0 for invalid, 1 for valid.
## Explanation
Really simple when you get down to it. We call a huge function `F` which returns the list of pieces that can move to an `X,Y` coordinate with color `C` and type `T` within a board `W`. This is called to retrieve the list of eligible pieces based on the `[c,p,x,y]` input, and again to determine whether there is check or not. Here we do not call with a type parameter as we want to consider every piece.
The large list in the `filter` function body is simply a list of booleans which check Xs and Ys, the code is too unreadable for me to explain how that works... but it should be easy to figure it out by reading the code. Notably, all a queen needs is either bishop eligibility or rook eligibility. The pawn code was what took the longest to write.
Then we have a simple `some` call which operates on the filtered list, checking if there is any piece where, after recalling `F` with a slightly modified board (that particular piece is moved to the target), we get an empty list (no eligible pieces of the opposite color) or in other words there is no first element.
Here's an expanded version of my code (thanks Emanresu A!):
```
(b,M,
  [c,p,x,y]=M,
  m=Math.abs,
  J='some',
  F=(C,X,Y,W,T,
    Q=P=>
      P[2]==X&
      P[3]==Y
  )=>W.filter(
    ([i,j,k,l])=>
      i==C&
      j==(T||j)&
      [
        B=m(H=k-X)==m(V=l-Y)
        &!W[J](
          ([I,J,K,L])=>
            (K-k)/H==(L-l)/V
            &(
              k>X?
              K<k&K>X
             :K>k&K<X
            )
            &(
              l>Y?
              L<l&L>Y
              :L>l&L<Y
            )
        ),
        R=
          !(k-X&&l-Y)
          &!W[J](
            ([I,J,K,L])=>
              k-X?
                L==Y
                &(
                  k>X?
                  K<k&K>X
                  :K>k&K<X
                )
              :K==X
                &(
                  l>Y?
                  L<l&L>Y
                  :L>l&L<Y
               )
          ),
        B|R,
        k==X?
          !W[J](Q)
          &(
            l-Y==1-2*(C<'E')
            |l-Y==2-4*(C<'E')
            &!W[J](
              E=>
                E[2]==X
                &E[3]==Y+1-2*(C<'E')
            )
          )
        :m(k-X)==1
          &l-Y==1-2*(C<'E')
          &W[J](E=>Q(E)&E[0]!=i),
        (k-X)**2+(l-Y)**2==5,
        (k-X)**2+(l-Y)**2<3
      ]['BRQPNK'.search(j)]
    )
  )=>
    x>0
    &x<9
    &y>0
    &y<9
    &!b[J](
      ([i,j,k,l])=>
        k==x
        &l==y
        &(
          i==c
          |j=='K'
        )
    )
    &F(c,x,y,b,p).some(
      e=>!F(
        c<'E'?
        'W'
        :'B',
        ...(
          W=b.map(
            E=>E[J](
              (a,i)=>
                a!=e[i]
            )
            ?E
            :M
          )
        ).find(
          Z=>
            Z[0]==c
            &Z[1]=='K'
        ).slice(2),
      W)[0]
    )
```
[Answer]
# [Python 2](https://docs.python.org/2/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~141 138 134 133~~ 132 bytes
Without doing any of the really interesting code - but maybe this can compete with golfing languages or (dare I mention it) Mathematica?
Note: [python-chess](https://github.com/niklasf/python-chess) is a [Pypi](https://pypi.python.org/pypi) package install it on Python 2.7.9+ with:  
`python -m pip install python-chess`)
```
import chess
a,p,n=input()
S=chess.Board(a+' - - 0 1')
for m in S.legal_moves:1/(m.to_square!=n)**(`p`in`S.piece_at(m.from_square)`)
```
A full-program accepting input of three items:
1. the beginning of a [FEN record](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation) - the string containing the first two fields. This is to define the board state AND which colour is moving (since this is the information in the input in the OP, whereas fields three through six are "fixed" by the OP hence should not be a part of the input)
2. the piece-name attempting to move (as given in the OP -- one of `PRNBQK`)
3. the square to which the named piece is attempting to move where `a1` is `0`, `b1` is `1`, ... `a2` is `8`, ..., `h8` is `63`,
The program [outputs via its exit-code](https://codegolf.meta.stackexchange.com/a/5330/53748) given valid input:
* `1` if the move is a valid one (the program raised an error - due to division by
zero);
* `0` it it is not (the program exited normally)
(Don't) **[Try it online!](https://tio.run/##NY/BTsQgEIbvfQo8AWsXHPZgNOmlVxOD26MxLa6sSywwC6zGp6/YaCYzyffnm8OP3@UUg1qcx5gKQYdNXeGNC@yZupCLmWfaEoqruD2cbM70hf8/rNyYFtvQuYCXwngzdGsq@mjSGzPXlGzr3BCgvDnGRDxxgQxitu9mHn38tPkeJPOixDGfLybZqy7wzYZNOLkwDQKdPdjRlKocU/R/Ep/4slD1kVRIEhECIKJUCLiT51sJr6ChV1LDo3pSEnQlrbXc7x7Unnz9Vurrgbsf "Python 2 – Try It Online")** (because the python-chess package is not installed there and TIO does not allow internet connectivity so the pip-install code in the header wont work).
Note that the power operator in Python makes `1**1 == 1**0 == 0**0 == 1` but `0**1 == 0`  
...hence `1/0**1` raises a division by zero error while `1/1**1`, `1/1**0`, and `1/0**0` all succeed  
(...and that in Python `False` and `True` equate to `0` and `1` respectively).
[Answer]
# [Python 2](https://docs.python.org/2/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~127~~ ~~125~~ 124 bytes
```
import chess
a,m=input()
S=chess.Board(a+' - - 0 1')
for l in S.legal_moves:1/(m!=str(S.piece_at(l.from_square))+`l`[17:19])
```
[Try it on replit.com - test cases](https://replit.com/@Davidebyzero/cgcc-148587-python2-test)
Jonathan Allan never responded to the golf optimization and other comments I provided under [his answer](https://codegolf.stackexchange.com/a/148609/17216). So I'm finally doing that here. This program is based on his.
Input consists of two items:
1. The board state, in the form of a [FEN record](https://en.wikipedia.org/wiki/Forsyth%E2%80%93Edwards_Notation). As per the challenge's specifications, this is abbreviated not to include extra information about the state (castling, en passant, halfmove clock, or fullmove number) but it must include the color whose turn is next to move.
2. The move whose legality is being queried; this is a 3-character string. The first character is the piece type; as in the challenge's input specification, this is one of `PRNBQK`, except that a white piece must be in uppercase, and a black piece must be in lowercase. The next two characters are the destination square for the move. This is given in standard chess column,row format, where the column is one of `abcdefgh` and the row is one of `12345678`.
Python 2 automatically runs `eval()` on `input()`, so the input is taken in the form of comma-delimited Python string literals. Examples:`'rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b','nf6'`  
`'rnbqkb1r/pppppppp/5n2/8/8/5N2/PPPPPPPP/RNBQKB1R w','Pc4'`
[Here is a C++ program that converts the test cases.](https://tio.run/##7VdNc9pIEL3zKzqknEEG7yIJJJUJSYXDXlxF2dlUcWAplxBjIyMkVhL2Jil@u7dnRkJqjZzzHpaDbD/153s9PTg4HK4eg@D19X0YB9Fxw@FjmGR5yv39p06QxFkO6ySJgD/70X0YH4454GcKeXrkk7pB4X4fJFGSng3COIe9H8Y9A352hGeWb66vMX4YP4IMN5HwA/r0hPGP6XCijB55HoUx78k/gjAeKHtjUoYSn/BBuCG8HK6mU7Zk9ZelwQ8D0CLY@mmP/RUzY4JZzAkxEy@xDz/dLL1Lb4X1/xyeGiayV2l4mU1l0t@Ce2ylZ/Qb0WQ3k0nWn5pesyDxUYl6zGNX2dIcrYxLD/rQw9/N1RUzmSEKyJbuSqDMZ1fsCzMu8b0lmpxhB1pI0Sf6O6t3UzZAFtao4I6anTq0BhRtHfnB7j5P7vfJM5c5LVOlaKHnEPKgMHJkZdT7MxSVwjUMjRZ/NHzZ8pQvrb4pGZaKZEt7uOqrLrFzY4DxbXs1gCb/osNqCuuSsiYh52l6EtP09NHDR7/fpoQI@gTvplhxFfD3NoLPMUMRM8SYbfHOzQbYoJL5SYobriatxqKA4K1I4lNWFeDY9vthe5QT8Cjjv4giCo@n4QQ2iYwCL9sw4ighKXE6HcKHD6I5TIbmV/Hk7YhYeFwjbcj6sfFGdZ1fIydNZ7JMMAmui/yh14WLoDsAbezWYuTYS1O1wqu2uT5Dlw2AXQQX2UXG4P1F1kVPEVYAGFqO@KCxy9BLmLUEUt5dnNlytnF6kUnbq5Wiujt1Tq@vy2V3hlm6N/iwB@DhlBfIHT7MAYwrZI6P0QBcirjESzwsNKuQr8rLo4hHkFuVy6WIpSFYoUORsYY4mperIV6JLMreMY5ZIXcqjl0hc5W9hsyUl0URp@x9UXZqkshF7zWk6N2miEUiF703kBHJVfTesHE1xBO5tIIsXH@f4BvekND7tuWQJskOkhi2JgR@DHKucd@84NlEmBudznKJOxkn7obJvFJNhdyxSk2FzFnVY4W4BQ8KEQ@PxBEPq5hAhXxlsmubIiaxuWVSlwZS8kBsXA1xKFIyzBZlp26ZfVF2WuqikDmrpr1C3LKeRdlXORUV4hGk6MujiF3WvCgr9Ej2W1bNbYWMNBuT9FXEcVe0aEmrmIo/fLHJe3Me5rhQYBeHj9sc94uaCvzpj@EhTfYg9w2g0Xfw0@aMuES3O1btiWoixkSlogiHToRLdJtpPN3UJ@uskkOQeV3tM2IT5orpsyjiCFKq9DesOFA1nsTxwbss57AOs21ygJfkGG3EtSSogZ36nol3Mg92OkcO5chrOzWNk@VpjFiExxmrdjs5NaaGNObf084RPX2FjaOx71H2Xe2MjDU9RiROoaul6eHQE0FPaHFGHDrb47YzYq200fPaVfz7yDnKdUxTHufRd9j6mS7kAPx4g3CYqVOxSXgWsxxvfP6MbvjGz/8X@78itluuturCU2pmmqC83HfrKAl2WZuQnrbZHELlvE7TrLZtGkKOtPuQ3hI39YGo090g19IEMLXNZtM9dp6jipTc33E16OoYKBr0i9/UWrdoyfJio0ay5irVn3s/irj8VxaZ3/uY7ZBkWbiO5DdfyHm6zyB5wH9fjvFGCLVO/jH@BQ "C++ (gcc) – Try It Online")
The program [outputs via its exit-code](https://codegolf.meta.stackexchange.com/a/5330/53748) given valid input:
* `1` if the move is legal (the program raised a `ZeroDivisionError`)
* `0` it the move is illegal (the program exited normally)
[Try it on replit.com](https://replit.com/@Davidebyzero/cgcc-148587-python2)
Can't [Try it online!](https://tio.run/##HYhLCsIwFAD3PUVcJUFtfFXxA910K0i0S5EaNWoxn2cSBU9fiwwDw@A3Pbwruq616EMil4eOMVMjW7YO34nxrC7/L6@8ClemhpSMeyYEKM9uPhBDWkfq3Oi7Mo31Hx3XIJgdlDEFVufY6otuVGImvwVvm/h6q6A5H57M6QCLNayOvOtocOfXE1wQiFj0iqWYyamASs77lLLYoJRiv4UdVNs9OdMRxTvQHw "Python 2 – Try It Online") (python-chess is not installed on TIO, nor is internet connectivity allowed, and even if it were, [Pypi](https://pypi.python.org/pypi) and the latest version of python-chess no longer support Python 2)
python-chess v0.23.11 was the last version to support Python 2. To install it for use with this program, you may run the following git command:
```
git clone --branch 0.23.x https://github.com/niklasf/python-chess.git
```
And then symlink, copy, or move its `chess` subdirectory to the directory from where you are running this CGCC program.
# [Python 3](https://docs.python.org/3/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~134~~ ~~132~~ ~~121~~ 120 bytes
```
import chess
b,m=eval(input())
S=chess.Board(b)
for l in S.legal_moves:1/(m!=str(S.piece_at(l.from_square))+str(l)[2:4])
```
This is a straight port of the Python 2 version. Python 3 dropped support for the backtick alias for `repr`, so `str` is used instead. We can't use `str(l)[2:]` because an extra character is appended to `str(l)` in the case of pawn promotions, specifying what it is to be promoted to.
We save 11 bytes by using the latest python-chess, more than making up for the 7 bytes sacrificed by using Python 3, because python-chess v0.27 [added support for omitting the last 5 parts of the FEN string](https://github.com/niklasf/python-chess/commit/65e872995c6380522d3839e60a7235f06899fced?diff=split). This still accomplishes exactly what the challenge requires – it defaults to treating castling and en passant as impossible moves. (We still need to include the current turn, because otherwise it defaults to white's turn.)
[Attempt This Online!](https://ato.pxeger.com/run?1=LY7NisIwGEX3fYrMqgmjDek4UIRuuhUktstBSuqkWszPZ5KWmWdx043zTn0bO-riwoUD597rH_yGkzXjeOtDu8ymn06DdQEdTtL7qFnoXA5C4c5AHzAhUZU_SFJY4b5xQ6LWOqRQZ1CVKHkUqtZ2kH7NKNZvuQ8OVwl08iBrEbBKWmd17S-9cJKQ93-syFe6Xu3Jc_91Y5yy2JnmcmbGUQBI59CMrvgHZQX_nCvn6QY4p-WW7VixLVETL2I4svgpuAM "Python 3 – Attempt This Online")  
[Attempt This Online! - test cases](https://ato.pxeger.com/run?1=nZS_b-M2FMfRdvNf8eoOklCdGFKxEzjQ4qFLAEFxbksPgmjRliCZpEkqjnN75-5dbmn_p7uxf0kfLecu7bVLbRgC33v8ft4v-bc_9NE1Sn74-L7daWUctCq2RxuPp77lk1psoGylHlwYLWDbK1714IR1N2CEG4w8HSZlyYe2d620ZZmcwiE737sBpYUMpz7OJvo4jaeHaZQcTOtEaKbT6e-D27y5_vh0TmHdCGsnPN5l4rHqwzM7mtxnJ0-yVJWpQx5NNspAD62E-6QX26ovd-pR2AUl4e77zDoT3ie6FWtRVi7sk41Ru9Luh8qIKPrRu_vogS0u30Uj_9M3EebyQBdv6LvoBrALia5cg8VYYVx4EUMQoP05uziBnQf7IOvqVi4mgJ92A88L0KaVmPCLxT2gYJYFP8tgAb4r7sEjTm7fEm8ZD-Y4yviP9u0rx46U5bl50-izf0R9HlNiRK-qOtRjhHhaC-1eqZ1SoljCn7_8GsTgYhCyzqZnQdFb8c_gi_8Kfs7ozdixD5---zZgnWHSEK2ppFprwjTVKdlfEcppQZeMFDRnd7QgtMAj_sgqvWUrOKBysGpYAD_AWzMICN82AoxSHSgJDYV1JcEPFLDbB5w4mkU0CVYspx3lZE9XVLOCXCLNcKTmlBRMXxLJDC1uKWF3eCzIciaXIyyvZh72U4XVQpiL1jXCQCfbbePAqRGGz2oGflfggG40NOIIfmcmAb8ic06JTPOUzLAyup8TlqcdJVinRNvdLQXuUV2TvkL5wg4Nbjvw1jZKw0ENfQ3-HUF16Fq59cuE273uEMN4iunPpSRmucpZp8mVJunqkqQ63ZMlZ0VxR4nBLEaYFNf_CtsPQqDqYIyQrj9CU9mveTFUskZza8f6ayWsDBwugXjEa-ip3P_JaTv7-2BHqP2KK14GwHu17uwLby5xgNIzrwlbsj3DZz7vCM3nhDOOCzVyOH-1QK7qxFji2IBRGdWuyZfvDLVmHb0d7--39Mv9-13V9_6NPGW4q1BCK2tb3ovYJ-6E2VlQG-BqkLUviKun87_HXw "Python 3 – Attempt This Online")
To install the latest release of python-chess:
```
pip install chess
```
# [Python 3](https://docs.python.org/3/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~158~~ ~~152~~ ~~141~~ 138 bytes
```
import chess
b,p,n=input().split()
S=chess.Board(b)
S.turn=p<'a'
for m in S.legal_moves:p[p+n==str(S.piece_at(m.from_square))+str(m)[2:4]]
```
The [**132 byte**](https://codegolf.stackexchange.com/a/148609/17216), **124 byte**, and **120 byte** versions of this program have a problem. Their input is not bijective to the input specification given by the challenge – the color to move next must be given in two places, and if they disagree, the move is considered illegal.
This version solves that in the most natural way, by taking the color of the piece to move in the same place as the move itself is specified (i.e., whether the the piece identifier is in uppercase).
Also, evaluating the input as Python code is bad; there's a reason that was dropped in Python 3. So this answer uses `split` instead of `eval` on the input.
For optimal golf, the piece type and its destination coordinates are to be separated by a space in the move to be queried. Examples:`rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R n f6`  
`rnbqkb1r/pppppppp/5n2/8/8/5N2/PPPPPPPP/RNBQKB1R P c4`
[Here is a C++ program that converts the test cases.](https://tio.run/##7VdNc9pIEL3zKzqknEEG7yIBksqEpMJhL66i7GyqOLCUS4jByAiJlYTZJMVv9/bMSEitkXPew@owxk/9/bp7wD8cbp58//X1fRD54XHN4WMQp1nCvf2nlh9HaQarOA6Bv3jhYxAdjhngM4GNF6Z8XJXI9R/9OIyTUiKIMth7QdQx4GdL6KbZ@vYWPQTRE0iDYwlvUKkjhH9M@mMl9MSzMIh4R/7jB1FPyRvjwpR4go1QQ3jRX04mbMGqLwuBHwaghL/1kg77K2LGGL2YYyImXmIiXrJeuNfuEhP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l8DImdnFdL48OmE0EnNJ8Rm/b2qGlGrKXWem4zi38fOUe6jknCoyz8Dlsv1YnsgRetEQ5SNRXrmKcRy/DG5y@ohm@87H@y/ytkO8VqKy88xWaqEcqLfbcKY3@XNhHpapvNJqWcVcs0rWybGpFD7T6kt8RdtSGq5a4V19IIMLXNNqB77NJHZVEyb8dVo6sxUGXQL35TS92iIcuLjQrJmEtXf@69MOTypyxWfu@ht0OcpsEqlN98IePJPoV4gz9fjtFaELWK/zH@BQ "C++ (gcc) – Try It Online")
Unlike the others, the error used to trigger an exit code of `1` in this version is `IndexError`, by attempting to access the second character of a single-character string.
[Attempt This Online!](https://ato.pxeger.com/run?1=LY7BisIwGITvfYrcbFETUhVEzKVXQaI9ipRUUw02ye-fVNhX2FfYSy-77-TbbHf1MMwwHwPz9QMf8epd3393sZkun5_GgsdITlcdQlJPYOKEcdDFNKMBWjN4Uop_Sguv8JzWQ0Fjh07AeqRGSeORWGIcKWmrL6qtrH_osIIDjJ0QIWJaUjD6pCsVU0sb9LYK906hzrLxH7bZIV_Nj8fXo_ex_jlDV99v3CEDgHwQW7K5nDFeyMUQpcw3ICXbb_mOF9s9AXLhr-0v "Python 3 – Attempt This Online")  
[Attempt This Online! - test cases](https://ato.pxeger.com/run?1=lVGxbtswFERWfcWDFkmIIuZRtmPI1aLVgCDboxsIYkzbgmSKouimTvcOnbp3ydL-UzL2S0pZRloU6FASAvHeO94dT99-yJPeN-L55VN5kI3SUDZ-d-r8oapLZm34FvJSyKN2vQh2dcOKGjTv9AwU10clzoWV5-xY1roUXZ4HZzjEl3szaCQXrt3jukCebN9-tL3gUZWau8q27e9Hvb2Zvny5WHjY866zmC99EV-Eg07WpTmtVXyeBklTqI3LTCPoPcTynVM41rZRcIBSwCqo-a6o80PzgXeRXMtrEcedVu4qkCV_4Hmh3UOwVc0h79pjobjnXffjg7em0ej-fnD0euUZd2uMbvDem4HJJZCF3pvndVxp99YHxzH9p_j2rKx75R7U6U0pIgvMKrfwFIFUpejdXzp6bQjj2HkvnAj6nPS6lziP-5D6zlCo00DTL9kHmg8Z5fklTtt7mw9Sbz8uULxuio0rBwT_-MCl_oPtbAnNE35-_ur4oH3gYhPbF0Jed_xv8O2_wE8xzobEnl-vElopKhSREgVKKQmVKEPS3hFkmGFCSYYpXWBGMDOl-cgynNMlLGFPrSVNsUJGWlyipBkZmauKGYoUSUbliAiqMJsjoQtTZiQZiwRSKMYWuyMThkSEaUjGRgXbCaFpWCExmsL0FnOECvahRVloCCZCEJUsU1pJcidJuByRUIYtSRjNsgUSZYhAAJ_-H343tibC2BP9nSmhCW2pOdNJRTCdEEaZeTswYNSakt97bFDjCufQwg6HLH8B "Python 3 – Attempt This Online")
# [Python 2](https://docs.python.org/2/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~294~~ ~~278~~ ~~276~~ ~~270~~ 197 bytes
```
from chess import*
b,m=input()
S=Board()
S.clear()
S.turn=m[0]<'a'
for P in b:S.set_piece_at(P[1],Piece.from_symbol(P[0]))
for l in S.legal_moves:1/(m!=[str(S.piece_at(l.from_square)),l.to_square])
```
Even the 138 byte program's input is not quite bijective to the input specification given by the challenge, in which the board's pieces can be listed in any order.
In this version, the board is provided as a list of pieces, as in the challenge's specification. Each piece's type (one of `PRNBQK`) is specified in lowercase for black or uppercase for white, instead of providing the color as a separate element. The coordinates are specified as single numbers, where `a1` is `0`, `b1` is `1`, …, `a2` is `8`, …, and `h8` is `63`. Following this list is a comma, followed by the move to be queried (in the same format as the pieces already on the board). Examples:
```
[['r', 56], ['n', 57], ['b', 58], ['q', 59], ['k', 60], ['b', 61], ['n', 62], ['r', 63], ['p', 48], ['p', 49], ['p', 50], ['p', 51], ['p', 52], ['p', 53], ['p', 54], ['p', 55], ['P', 8], ['P', 9], ['P', 10], ['P', 11], ['P', 12], ['P', 13], ['P', 14], ['P', 15], ['R', 0], ['N', 1], ['B', 2], ['Q', 3], ['K', 4], ['B', 5], ['N', 21], ['R', 7]], ['n', 45]
[['r', 56], ['n', 57], ['b', 58], ['q', 59], ['k', 60], ['b', 61], ['n', 45], ['r', 63], ['p', 48], ['p', 49], ['p', 50], ['p', 51], ['p', 52], ['p', 53], ['p', 54], ['p', 55], ['P', 8], ['P', 9], ['P', 10], ['P', 11], ['P', 12], ['P', 13], ['P', 14], ['P', 15], ['R', 0], ['N', 1], ['B', 2], ['Q', 3], ['K', 4], ['B', 5], ['N', 21], ['R', 7]], ['P', 19]
```
In this way, the input is fully bijective with the challenge's specification, but optimally golfy.
[Here is a Python program that converts the test cases.](https://tio.run/##7VZNj5swEL3nV4y2B5OWrgokgCptD5G2l5XS3bZSDlEOJHEKCmBqnE33129tbMdMvD@gh@bgwMPMx3szY7oXUbI2eX2tmo5xAZxOJnt6gB1rnykXjxXd0aBT6/TzBOSPU3HiLawHbB1toDqAvv60ubsjKwK07inYx7c1O1MeTEPQVtbx5mM0hQ/2NlG37/PNZHIuq5pCpL0I/qIv1G/LCr6HO6DPRR1UbXcSwXR6edqwZxrKeJuGtkLuMhtu@66uREDg7gsQvNuaUtdTz0td9SJoii4YUxDqx1PPEOIJG@x41YqgFzzQ734gIQlB3Q/7QiDvzL0JfmTdJDHc0z872gm4//b1nnPGR7xwWhxfX9frm8VNCDcPcklCyDchGORJLlEIc4cs5TILIcNIht5SSyy3OeS7fivHSI6QR@0rw0jsITLCFCNzD0m9tzIPyS2ysrlLO5FDnrSdxCFL7X2ELPRbMUZSm/vKZhohyyb3EWJyTzASI8sm9ytkhnyZ3K/2ZB6SK1@bCY4n3qhS/8lPFIKfJQXO2BFYC2UEu6LV9Xpg/KyqnLWyTifrNVnICiQPZHA7iKmRJ@LE1MiSuBQdkhkaNKKWHNlRS2wKUCPfyZB0gpEI7XkkgyxXiKUB7ck8JMWIJVgOJpNpZr2vbKZWFo0siSt2h2Q2npXNyxaFQ3KEmLxyjCQ25pWNMEfeH4krW4fMvD0RysvYyVRRuJgHVlVRfC3USA6WtBIl5XBsq1@lAMF0Ucj/Yg4Hzho4y8cSKOkLFPy6RDIk2xNxU8IVxByJZIJIcUFkSLaFR9PDuLAuIqUIWY7FviAJIs4UX4yRVJGiaLrkNXTTiCbVPPIwEhS2VV@yDs7sVO9BDmTFDByr9pecz7Ar6e7oU5RiivK3euaqr3KPkBjRuCBusKOeiTzkqvpzr4tw75k9qUd@jsnPvA6Ze3LMkB0ja@zJkeJ@wP1pOiTFlT1/q0NiJ6KJJ39bxN8nSqVaJ87lEVu/QFn0vo4hFO1ewlWve2LPaN8SIc9w@qw@K0RZiP9a/yNaZ3auucNOi9l7elI77LY12x37t3TMvbGWIiaXY5YWo1FzpePMOwvxCfEwrocx21fcxh7/kTfWEjTELlXkOBHFkeoy102gWfDP/MjLPMYRD2faxdMlYufpR1PUNe2F5r0ppLOO9X21reVHs5RDUN70wA7yA/rU7pVMW/Zn@hc "Python 3 – Try It Online")
[Try it on replit.com](https://replit.com/@Davidebyzero/cgcc-148587-v3-python2)  
[Try it on replit.com - test cases](https://replit.com/@Davidebyzero/cgcc-148587-v3-python2-test)  
Can't [Try it online!](https://tio.run/##Rc5Bb4MgFAfwu5@CnZTFOLWF2mZeel2yuHk0xKilqxmIBVzST@8EG7z9eLz/e2986JsY0nm@SsFBd6NKgZ6PQupXrw153g/jpAPolflZNPJiFHWMNtJKT3LIeRWTd7/xvauQoAD9ANpTGSmq67GnHa0bHRRVQsLCvCKzp1YP3gq2lGMCoc0xkysjRn8aVnPxR9UpeQv4S14pLYMycqPYc8J9aiSFMGSRFs8XgfNcVb70Q4AwCUHlD4YHy9Yws7wbHi1/F@LY9eLU0kzAO8tx4T7beHRE8catF@03IsdkbSgW7tbLzgtT5Kopdsyc1l0fJp@6YrLfuOa/F663fJqi1ZfZ5BYh94td4kDcdZj8Aw "Python 2 – Try It Online")
# [Python 3](https://docs.python.org/3/) (with [python-chess](https://github.com/niklasf/python-chess)), ~~309~~ ~~306~~ ~~290~~ ~~288~~ ~~282~~ ~~271~~ 203 bytes
```
from chess import*
b,m=eval(input())
S=Board()
S.clear()
S.turn=m[0]<'a'
for P in b:S.set_piece_at(P[1],Piece.from_symbol(P[0]))
for l in S.legal_moves:1/(m!=[str(S.piece_at(l.from_square)),l.to_square])
```
This is a straight port of the Python 2 fully-bijective-input version.
[Attempt This Online!](https://ato.pxeger.com/run?1=RdDNToMwHADweN1T1BNgEIGNji1y2dXEoBxJQ2B2jthSVsqSPYuXXfRlfAJ9GvtByu3Xf_9f7ed3fxFH1l2vX6M43Ke_PwfOKNgf8TCAlvaMi7tF49MMn2vitl0_CtfzFkW2YzV_c6WCPcE11xIj7zJahujRqZ3FgXGQg7YDzbYIBiyqvsV7XNXCzcsI-bk6BWpaNVxow4gMh0j2VnVE1RUBwe81qSg742EbPbj0NisHwd0isK3I1OE01hx7nk8CwaYT8syTppdd_25gWTrc8UECkQ9Kp1NcazaKqeZJcaP5IQlDmwtjTdUBLjV7yVU6c2OZhDPn3GQ1M7GMTEIuuTSb7STjxEZjaJlamVlPqj62wWg109S_SppdnlVQ60VNsoMSewttxRrZ7SAy__cP "Python 3 – Attempt This Online")  
[Attempt This Online! - test cases](https://ato.pxeger.com/run?1=5Za9juM2EMeRKoCBvMNEKSgHWkXy1629cbPFNQcY3tvrFEOQbHolWCZlkl6fN33q9GmuSV4mT3BX5klCcmTSl0ueIG7802jImflzOPZvf7RnVXH24ePP9b7lQkHNI3mWET41ddnb0C3kNWuPKuzP4KnhZdGAolLdgaDqKJh96OV5eawbVTOZ57F1h3m37g54S1kYGD8Zt-cgCk5BPz6JWtFQBEHw-1Ftb24__rkVfA_rikoJGP_7Xhnt5_S5aMIug37vcX7PC7EJNcXrhhbCkklkvs-S1Y-kIL0tF7CEmkE5e4wlVXlb0zXNCxUus3QVLc1TbKLl8rwveaPNyUrvbdY1Zt1j3NCnosn3_JnKWfpDuP92nkklwsfYbdV0OxyOhaD9ftTEindPqz6W9OmrG11els5u0lX_DrSwcVuoSusjqVBhEgEh2v4yT2xoZUIbJ6k2NZv1QH_qLbzMoBU1UyH5iZH-xaoyvel8bmwzMGKrzISxr43SxoIP4oxbmU9rTiVHdfO8O5Og795jOHf6saANLzZhix70_Zq26mo3m1aqy_jrl19JBCoCyjbzoNuQNpL-0zn5L-eXeXqHqn349PU3WRbsggjGt6sIsuCgcTiwyIw1dThBa6lxMLYojMPU4WRosdU4uvU49TjwOHI49svGV1YM8cb4WnowcTGbhcYUI9wbHDgcYLC3GhNHrywtjefE4dQbE4eDK9ehx5F3GK7ctul4Bd_BO3GkEL6rKAjOd8AZVCmsCwamn0G32knfIG2m_V6WkZ0-jIktghzIRSbCyCU1i0gluShqcYgojOvUIZ4UaQ1OHGLCFsfeYeStWCd5YxAdHshFCLIgl1O1OMQc70knqSVc_9Z4Tjzi-yWx2lwQzwytHgcjh_qkfbCB0fR1obsZwgWtVUUF7Fj9VClQHDXV38UY7AA76dfaUNEzmMFwUbirySiMnYoKDxyOEqcrthzixKkycaKMXW6dfgZTr8nU0fAV1mEzGF7VYZrjVOkJDGUtK97CiR-bDZi5rVOHXc2ezDTS03i9czWMJr6GoUu8y5aRywWxiU99CbeuNRJHXbW2Saa-STyOfDtMrtrB13tFQ1ev12CUuh4Y-M7A244Hf4V4g7DRk39V6XCkVMtxFIIy1ZyhKuSXQkVQsI021xK7YsOpZETp0Uef9TL9plD_KzH1Pf1sHKFa8gvB6OU-lQ1f7-TnQnXqHLCd3Tn5mzP2N8fPpsRV3En64K7Qwim68EPO3pbR6kpyl7kqdhRPG3sBc3X5jV16OJ9t0O7eHWxQt9Pjvmga8-Nsq98XerOWS1mXDY2MKIqKvQS-hZIf2caIVfL33Z-JvwE "Python 3 – Attempt This Online")
It's almost a shame there turned out to be an interface in python-chess whereby the direct placing of the pieces and setting of the current turn could be done concisely, because there was some fun golf in converting the board to FEN in the **271 byte** version:
```
import chess
b,m=eval(input())
B=['1']*64
for P in b:B[P[1]]=P[0]
B='/'.join(map(''.join,[*zip(*[iter(B)]*8)][::-1]))
i=8
while i:B=B.replace('1'*i,str(i));i-=1
S=chess.Board(B+' '+'bw'[m[0]<'a'])
for l in S.legal_moves:1/(m!=[str(S.piece_at(l.from_square)),l.to_square])
```
[Attempt This Online!](https://ato.pxeger.com/run?1=RdDNToMwHADweN1T1BNgEIGNji1y2dXEoBxJQ2B2jthSVsqSPYuXXfRlfAJ9GvtByu3Xf_9f7ed3fxFH1l2vX6M43Ke_PwfOKNgf8TCAlvaMi7tF49MMn2vitl0_CtfzFkW2YzV_c6WCPcE11xIj7zJahujRqZ3FgXGQg7YDzbYIBiyqvsV7XNXCzcsI-bk6BWpaNVxow4gMh0j2VnVE1RUBwe81qSg742EbPbj0NisHwd0isK3I1OE01hx7nk8CwaYT8syTppdd_25gWTrc8UECkQ9Kp1NcazaKqeZJcaP5IQlDmwtjTdUBLjV7yVU6c2OZhDPn3GQ1M7GMTEIuuTSb7STjxEZjaJlamVlPqj62wWg109S_SppdnlVQ60VNsoMSewttxRrZ7SAy__cP "Python 3 – Attempt This Online!")  
[Attempt This Online! - test cases](https://ato.pxeger.com/run?1=5Za9kts2EMcnVWY0k8krbJgC5JlHixJFS7qwUeHGMzd3PncMh0NK0BERRVAgdLIufWr3btwk7xSXeZLggwTkOHmCqNGPiyV2978LSB__aM-8os2nP38l-5YyDoT63bnz9VNNytEGbyEnTXvkrreEx5qWRQ0cd_wGGOZH1qiHUZ6XR1Jz0nR5Hih3SPr3boC2uHEd6dcF7dnxnZPjBSdGOHaZ4zi_H_n2ev75m-_7HNYV7rpR6e8T_FTUbh_cG62SFIUou4qj0ZYyuAPSQLlcpXdpmGXJXTrOhAt6iYJfKGncfdG6SLOfXj2T1r1KRUTmrrzsau5l6XJ5HWZiW5LMR6eK1BjIcpWsAobbulhjV8S6In7HmUs874ZcJ-HoIVG5BStasI27eoEAvUDlCaV7EfwnVKDMU6nVMrWHoMaPRZ3v6RPuluFLd_9DksrtHoKW4DXOC-7WwZbRfd4djgXDnufXAaf9U-YNulwLjdJQZXsDojtBW_BKiNxhxt2xDwgJ-3MyVqG5DC2dOr4hzXIE4kO28LyElpGGu-jnBnmDladi0ySRtiXIjvFUhlHLsl3Soh_YWW8lP61sba6bled9Yx3PrOtwZoSEoDUtNm6rPfD7NW75xW4qrVCU8ddvH5AP3AfcbBKn3xDXHf6n8_i_nJ-T8Ear9unzt9-lqbNzfJjNMx9S5yBwOlHYSGtoMNbWUuBkppBJh4XBeKqwFRjNLS4sTixGBmf2tdmFVYd4I30V3cu4OptbgaGOsJI4MTjRwd4KHBt6pehOesYGF9Y4Nji5cJ1ajKzDNDPbhrMMfoR37IjBfVdhYJTugDZQhbAuGpDzDGLUTuIMCDP2RmmKdqIZsSoCHdAgE2rQkJpCTSUaFFU41cik68Kg7hRqJcYGdcIKZ9YhslZdJ3ojUTvco0EIdIuGriqc6hxXqJdUkX7_rfSMLer1O6S0GVD3TFstTiKDotM22ERq-roQ0wzuLSa8wgx2DXmsOHCqNRXfxQzkhQAnsSwMFT6DvBgGhfuapMJ6UrXCE4PR2OiqR05jbFSJjSgzk1uvn8TQarIwNH2l61AZTC_qkMMhbk6OoSRdRVs40WO9AXn5i9RhR5pHeRuJO3O9MzVEsa1hahLvs23QcEBU4gtbwtyMxthQX60akoUdEouRHYf4YhxsvRc0NfVaDaLQzMDEToY-7brxF6hPkB708b-qdDhiLOQ4MoYbXp-hKrqvhfKhaDbCTDo9FRuKuwZxcfXhJ_GaWCn4_0pMcU6_uI60Wt1XguHhPJU1Xe-6L4Xq1TnocTZ9sidnZk-OvZvGpuJe0ntzhG6Norf2klOnJcouJDeZ82KHdbf1LOhcTX4zk56-n1XQ_twdVFCz08O-qGv546yq3xdis5Z2HSlr7EtRxH-cfQd0CyU9NhspVknf938m_gY "Python 3 – Attempt This Online!")
# [Python 3](https://docs.python.org/3/) (with [python-chess](https://github.com/niklasf/python-chess)), 163 bytes
```
from chess import*
b,m=eval(input())
S=Board()
S.clear()
S.turn=m[0].color
S.set_piece_map(b)
for l in S.legal_moves:1/(m!=[S.piece_at(l.from_square),l.to_square])
```
An even smaller code size is achieved here by setting a rather ridiculously specific input specification. Examples:
```
{56: Piece(ROOK, BLACK), 57: Piece(KNIGHT, BLACK), 58: Piece(BISHOP, BLACK), 59: Piece(QUEEN, BLACK), 60: Piece(KING, BLACK), 61: Piece(BISHOP, BLACK), 62: Piece(KNIGHT, BLACK), 63: Piece(ROOK, BLACK), 48: Piece(PAWN, BLACK), 49: Piece(PAWN, BLACK), 50: Piece(PAWN, BLACK), 51: Piece(PAWN, BLACK), 52: Piece(PAWN, BLACK), 53: Piece(PAWN, BLACK), 54: Piece(PAWN, BLACK), 55: Piece(PAWN, BLACK), 8: Piece(PAWN, WHITE), 9: Piece(PAWN, WHITE), 10: Piece(PAWN, WHITE), 11: Piece(PAWN, WHITE), 12: Piece(PAWN, WHITE), 13: Piece(PAWN, WHITE), 14: Piece(PAWN, WHITE), 15: Piece(PAWN, WHITE), 0: Piece(ROOK, WHITE), 1: Piece(KNIGHT, WHITE), 2: Piece(BISHOP, WHITE), 3: Piece(QUEEN, WHITE), 4: Piece(KING, WHITE), 5: Piece(BISHOP, WHITE), 21: Piece(KNIGHT, WHITE), 7: Piece(ROOK, WHITE)}, [Piece(KNIGHT, BLACK), 45]
{56: Piece(ROOK, BLACK), 57: Piece(KNIGHT, BLACK), 58: Piece(BISHOP, BLACK), 59: Piece(QUEEN, BLACK), 60: Piece(KING, BLACK), 61: Piece(BISHOP, BLACK), 45: Piece(KNIGHT, BLACK), 63: Piece(ROOK, BLACK), 48: Piece(PAWN, BLACK), 49: Piece(PAWN, BLACK), 50: Piece(PAWN, BLACK), 51: Piece(PAWN, BLACK), 52: Piece(PAWN, BLACK), 53: Piece(PAWN, BLACK), 54: Piece(PAWN, BLACK), 55: Piece(PAWN, BLACK), 8: Piece(PAWN, WHITE), 9: Piece(PAWN, WHITE), 10: Piece(PAWN, WHITE), 11: Piece(PAWN, WHITE), 12: Piece(PAWN, WHITE), 13: Piece(PAWN, WHITE), 14: Piece(PAWN, WHITE), 15: Piece(PAWN, WHITE), 0: Piece(ROOK, WHITE), 1: Piece(KNIGHT, WHITE), 2: Piece(BISHOP, WHITE), 3: Piece(QUEEN, WHITE), 4: Piece(KING, WHITE), 5: Piece(BISHOP, WHITE), 21: Piece(KNIGHT, WHITE), 7: Piece(ROOK, WHITE)}, [Piece(PAWN, WHITE), 19]
```
[Here is a Python program that converts the test cases.](https://ato.pxeger.com/run?1=7VdNbuM2FF5050XPQKQL2o3HGMm2JARwgXrgAQZpHSczgBeGEcg2PRIsiypFxeMUPclsspmeoKeZ05QUSVHPzAG6qBeM9Onp_Xzfe6Ty9e_izBOav7x8q_j-TfT9hx_TY0EZR4z00TYhZdnp7MgebWn-RBhfpGRLuoVcezcdJH4Fmii7Qf1ssGf0-FiejxuaKbuVt0bpHqnrt-vJBC8xIllJkHk8yOiJsG6vVztkhFcsRyusYuFr7f3D7N3scf7r77OPq2JQv_rIzwVZD6qikG9f4z4yxu_ufrt7aIy3NKOsZdcTljo3f_3G66FrczuUtz9H607nefK2c0rSjCBP1cnZWV3I34bGbCcKJ09x1k3zouIme_k70idJHj0eSc6FlTYYlEWW8i5Gk18QhtbGlby2TwRrzzeoYGku3m7Q54nXXKtn-E9REMl3E9xyexYFmOs9ZUKnNFd52zJ0kLMJIhl0PSlvHrhfSNVBS0B75a_krLsQAgvOb4Q2CyG_617XD7xBHnRyf_Vlfit8LZ8KV0pwGaMG6jBrif0kFglrBXpuTK1IfU--bEnB0ezu_YwxyloiMxIf1Fjo6Xj53vlntbqaXvXR1a1Yhn0UiYo0ci8Wr4_GFpmLZdRHIURC8JZcfGFmkQf1VgSRCCALFSuEiO8gIsMAImMHCZy3QgeJDLI0tQs_nkXulZ-hReYqeguZqrd8iASm9qWp1AOede0tRNc-hIgPPOvaL5ARiKVrv7AJHSSSsdYdmI-_lmP8iVUEdT8lBDFKD4jmKPHQNs5VU4uxO8l9guaimTurFZ7K7rzFddhaTIXcYyumQubYlmiRUNOgELlEwI9cfN2ACnnAddFDiHjAZoFrWS4QQwOwCR0kgIghWGzxutLQRF-aSo0sCplj2-wWCU0-S1OXaQqLRADRdUUQGZqclybDCERfYNu2Fhk5Nh6oS_sJZVPYnGtWZVO8j-Xh1p2TlCeEoUOefk444lQ1hfgbj5E8JdFJPBZAQs4oZpctEgLZ7rHdJWxDjIFIOokANkQIZJs6NN22G6sRKQDIvC12gwwBcbr5fIgEkhRJU1NXPU0tmuTwiIOWE7RJy4QW6ESrbIfE_iyZQYc0_yxPLnGubw8uRQGkKHptZi7mKnII8QGNU2w3djAznoNcdH_kTBGcPW0TOORHkPzQmZCxI8cI-NGy-o4cLZsHZz71hASws8evTYhvRdT5RK-L-EdFiFCrYkycvNkZJXHp6thHcb4TcFqqmdhRUuaYi4OePMlPJp7E_H-t_yNah2Zfs4edErN09CRms9tkdHsoX9Mxcra1ADA5b7PUIENHx5FzFsIT4rbdD222L7j1Hf49Z1sbgk2s6SLLCY8PRLW5GgLFgnvme07lPsy4PtOaSE3GNtLHY5xlpOSK92MsghW0LNNNJv7jEHJwwo4lonvxpV_lOynThn7pqa_XfwE "Python 3 – Attempt This Online")
[Attempt This Online!](https://ato.pxeger.com/run?1=ddPNTsIwAAfwgyd5inoxnZlz33wkO4AhsmAAHYYDIUuZRZZ06-w6EmN8Ei8kRt9Jn0YQhmNZb-3v37X_pN37V_LClzRerz8zvrhsfH8sGI1AsMRpCsIooYxf1OZy5OAVIjCMk4xDSap5Toci9gg3IyUgGLG_Ec9Y7ERTdaYElFC2kRRzPwlxgP0IJXAu1RaUAQLCGHgKwU-I-BFd4bSlXcHozJl6ym4x4pAo2yJ--pwhhiWZKJzuJzNpV3XfeP1zcv5q2S0w2n4K74fDvgw6t-3rviQDq557f-De9MaFpJEnHdfrDUeFpJkndw_d7uA_sNXDZu7gpuCaaCtbFx1vG9WFzUOtUXtSONtsVrulClwTuC5wQ-CmwK1qL9Wf9Nxxd8PNatZUgWsC1wVuCNwUuFXt6vGlHJaXbzEP9PLF54FRekK5m8cvKGdLtI8uPLpeVfVNBtPq92Zas9Pd__IL "Python 3 – Attempt This Online")  
[Attempt This Online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