Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Programming language is C. Problem 1: Checkmate mate! In this problem you are given a chess board with pieces on (all formatted as characters),

The Programming language is C. image text in transcribed
Problem 1: Checkmate mate! In this problem you are given a chess board with pieces on (all formatted as characters), you have to detect whether black is on check, checkmate or not threatened at all. Input is given as 8 lines of 8 characters. Capital letters stand for "white" and lower-case letters stand for "black pieces. Don't assume the input is a proper/complete chess game (e g. there might be all queens) but there always be only one king of each color. A hyphen stands for empty cell. The output must be either "check, "checkmate" or "not threatened". You can read the piece moves on Wikipedia https://len.wikipedia.org/wiki/Chess). In short, all pieces move and capture the same except for Pawn. Rook moves horizontally or vertically, Bishop moves diagonally, Knight has L shaped jumps, Queen moves like both Rook and Bishop, and King can move to its adjacent 8 cells only. Pawn moves straight toward the opponent but can capture the piece on its immediate right or left diagonal cell (that is what matters for checking the king). The king is in check, if it is threatened by an enemy piece (the piece can capture the king).If it is in check and the player doesn't have any move to get the king out of the check, it is checkmate and the player loses the match. A king may get out of the check by either moving out of the threatened cell (into a non- threatened one) or if another piece blocks the way of the opponent's piece that can capture the king (or knocks out the opponent's piece that is threatening the king). Note that the king might be threatened by two opponent pieces. In that case the only valid move is for the king to move to a non-threatened cell. White: K-king, Q-queen, R- rook, B-bishop, N-knight, P-pawn Black: k-king, q-queen, rerook, b-bishop, n-knight, p pawn Sample input (the text is the input, the picture corresponds to the board it is representing and is only here for demonstration): P RP PP-PK Output: checkmate submit them both here and on the iudge lud Problem 1: Checkmate mate! In this problem you are given a chess board with pieces on (all formatted as characters), you have to detect whether black is on check, checkmate or not threatened at all. Input is given as 8 lines of 8 characters. Capital letters stand for "white" and lower-case letters stand for "black pieces. Don't assume the input is a proper/complete chess game (e g. there might be all queens) but there always be only one king of each color. A hyphen stands for empty cell. The output must be either "check, "checkmate" or "not threatened". You can read the piece moves on Wikipedia https://len.wikipedia.org/wiki/Chess). In short, all pieces move and capture the same except for Pawn. Rook moves horizontally or vertically, Bishop moves diagonally, Knight has L shaped jumps, Queen moves like both Rook and Bishop, and King can move to its adjacent 8 cells only. Pawn moves straight toward the opponent but can capture the piece on its immediate right or left diagonal cell (that is what matters for checking the king). The king is in check, if it is threatened by an enemy piece (the piece can capture the king).If it is in check and the player doesn't have any move to get the king out of the check, it is checkmate and the player loses the match. A king may get out of the check by either moving out of the threatened cell (into a non- threatened one) or if another piece blocks the way of the opponent's piece that can capture the king (or knocks out the opponent's piece that is threatening the king). Note that the king might be threatened by two opponent pieces. In that case the only valid move is for the king to move to a non-threatened cell. White: K-king, Q-queen, R- rook, B-bishop, N-knight, P-pawn Black: k-king, q-queen, rerook, b-bishop, n-knight, p pawn Sample input (the text is the input, the picture corresponds to the board it is representing and is only here for demonstration): P RP PP-PK Output: checkmate submit them both here and on the iudge lud

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions

Question

Practice what you preach.

Answered: 1 week ago

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago

Question

Define capital structure.

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago