Create a program that mimics a chessboard.
The chessboard must be surrounded by the labels of each row and column, being the columns labeled from 'a' to 'h' and the rows labeled from '1' to '8'. Also, place the default position for each chess piece (blacks are on the top). Each piece is represented by the first letter of his name:
King = K Queen = Q Rook = R Bishop = B Knight = N Pawn = P
Also by his colour
W = White B = Black
So any given piece is recognized by his name and colour. E.G: NB = Black Knight. Empty squares are represented by a hyphen (-).
The program must show the chess board with the pieces. Then it should ask the user to make a move with the message "Move". The program must read user input by console or equivalent. We don't care if the move is legal or not. The program must reprint the chess board with the piece moved, deleting any piece it was on that square. The move is represented
origin square destination square. E.g:
2c 5d = Moves the piece in square 2c to square 5d
If the program detects there is not piece in the origin square or an invalid input, it must show the message "Invalid move" and ask again for another move. If the program detects the final square is occuped by another piece it must show the message "[Name of the moving piece] x [Name of the captured piece]". Eg:
PB x KW
The program is intended to run in a loop, so after each user input the program will ask again for another move. There is no exit clause for the loop.
Example of a initial chessboard and first user's input and program's output:
- a b c d e f g h - 8 RB NB BB QB KB BB NB RB 8 7 PB PB PB PB PB PB PB PB 7 6 - - - - - - - - 6 5 - - - - - - - - 5 4 - - - - - - - - 4 3 - - - - - - - - 3 2 PW PW PW PW PW PW PW PW 2 1 RW NW BW QW KW BW NW RW 1 - a b c d e f g h - Move 2a 4a - a b c d e f g h - 8 RB NB BB QB KB BB NB RB 8 7 PB PB PB PB PB PB PB PB 7 6 - - - - - - - - 6 5 - - - - - - - - 5 4 PW - - - - - - - 4 3 - - - - - - - - 3 2 - PW PW PW PW PW PW PW 2 1 RW NW BW QW KW BW NW RW 1 - a b c d e f g h - Move