【解決方法】チェスの計量問題

[ad_1]

Problem Statement
Project: Chess Metrics

The game of chess is deeply complex, but it can be interesting to study from a metrics and analysis point of view. Your task is to develop a software tool that, given the input of a sequence of moves in a chess game, outputs the count of each unique piece taken and the average number of moves it takes to capture each type of piece.

Inputs:
The program will receive a list of strings representing the sequence of moves in a standard game of chess. Each string is formatted according to the standard algebraic notation (SAN) of chess moves, without additional markings like check or checkmate symbols.

Outputs:
The program should return a dictionary, where keys are the types of pieces captured ("pawn", "rook", "knight", "bishop", "queen", and "king") and the corresponding values are tuples of two elements: the count of that type of piece captured, and the average number of moves taken to capture each instance of that type of piece.

For the purposes of this problem, we will ignore the distinction between different colours of pieces. All piece captures, whether of black pieces or white pieces, should be included in the same count.

If no piece of a certain type has been captured during the game, that piece should not appear in the output dictionary.

Example:
Input:

["e4", "e5", "Nf3", "Nc6", "Bb5", "a6", "Bxc6"]"
Output:

{"pawn": (0, 0), "rook": (0, 0), "knight": (1, 7), "bishop": (0, 0), "queen": (0, 0), "king": (0, 0)}

In this example, the seventh move "Bxc6" means a bishop captured a knight. Hence, the count for knight is 1, and it took 7 moves for it to be captured.

Constraints:
All inputs will be valid and formatted correctly according to the standard algebraic notation (SAN) of chess moves.
The list of moves will not be longer than 500 elements.
The game represented by the sequence of moves can be in any state: it can be complete, incomplete, or even impossible in a real game of chess.
Remember, the main challenge in this problem is not just to code the solution, but to understand the rules and conventions of the chess game, and translate that into a program.

私が試したこと:

まだ実際に取り組み始めていないんです。 この質問にどうアプローチすればいいのかわかりません。

[ad_2]

コメント

タイトルとURLをコピーしました