---
description: OK, Thank you!
---

# New Task 2: Letter Chess

<details>

<summary>Author</summary>

Dicaprio Cheung (dhcheungaa@connect.ust.hk)

</details>

## Task&#x20;

Your task is to build a new type of chess called the Letter Chess. The name comes from its chess pieces because they are English Letters. Like normal chess, there are 2 players and they are called:&#x20;

* CAPITAL letter
* small letter

### Chessboard

In the beginning, the chessboard looks like this:

<figure><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FLPP3cd28wMWSDUAzMxgC%2Fimage.png?alt=media&#x26;token=1eec9201-ba74-4538-9ccd-0888096b6a03" alt=""><figcaption><p>Initial game board, with all spaces shown </p></figcaption></figure>

> Note: A8 is inputted by the user

### Chess pieces and movements

The following tables summarize how different chess pieces move: (Yellow = movable tiles)

<table><thead><tr><th>CAPITAL letter team</th><th>small letter team</th><th data-hidden></th></tr></thead><tbody><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2Fr4zXPpVk1azboTFrrXb7%2FO.png?alt=media&#x26;token=1ebcda74-7c77-4d69-bd35-71138681475d" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2F36sgwHXMzslYSZLFS6M4%2Fsmall_o.png?alt=media&#x26;token=1a58a726-23bb-4d37-b29e-56723e27e212" alt="" data-size="original"></td><td>O</td></tr><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FCIZuUpoogrcgqfSzBLnm%2FK.png?alt=media&#x26;token=caca4a4b-7dfe-47c8-bc8d-0ca511d8ccac" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2Ffu43Penll743hPUI6ZGP%2Fsmall_k.png?alt=media&#x26;token=68e72515-ac0a-42c7-a8b1-627ca5897acc" alt="" data-size="original"></td><td>K</td></tr><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FD3cIvudr1Ba2It20REpX%2FT.png?alt=media&#x26;token=bb54c602-72be-4427-8eb1-291e322265f7" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FfSd8CorNGd0VxKIDjzsJ%2Fsmall_t.png?alt=media&#x26;token=7bde368f-a376-44cc-b80a-5687a2cc5bc3" alt="" data-size="original"></td><td>T</td></tr><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FmtZ8GGAI9TorNwtkcYjo%2FH.png?alt=media&#x26;token=3a37fc2e-1fb1-41aa-88b0-58b06fb74fd9" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FgmkmW1jqs7IsEzn5eTEq%2Fsmall_h.png?alt=media&#x26;token=4de2864e-bdfb-4b24-bd76-ec502ee0f6e5" alt="" data-size="original"></td><td>H</td></tr><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FH2dOQKe2UOkWi8UzBYeD%2FX.png?alt=media&#x26;token=7f1753c7-7cef-4305-89a3-db712c4330d8" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2Fnz3muel6wF87Yzc6anyJ%2Fsmall_x.png?alt=media&#x26;token=c98132d8-190e-42aa-9d15-fee8c0c171fd" alt="" data-size="original"></td><td>X</td></tr><tr><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FnX8K0alKlLIHfs7qGoku%2FU.png?alt=media&#x26;token=29ea8d51-eab6-4e87-90fd-6d7fb6f85379" alt="" data-size="original"></td><td><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FjZukfwSBLnt4po2WUK9v%2Fsmall_u.png?alt=media&#x26;token=bbaa7743-f12f-4cd1-9c73-941d2bcb927a" alt="" data-size="original"></td><td>U</td></tr></tbody></table>

> ~~I am using these images to prevent people to use ChatGPT. If these doesn't work, please tell me how you used ChatGPT to read these images and complete this task.~~

The arrows represent how the piece moves along the path. The piece can move infinitely along the arrow until something blocks it. If something is blocking it, it can't go through that piece and reach the other side.

Take `X` as an example:

`X` is just like a normal bishop

<figure><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2FoqL9opWNeXZTp9mh3Nf5%2Fimage.png?alt=media&#x26;token=2140b931-8796-49e3-9465-a1335e043392" alt=""><figcaption><p>bishop in a normal chess</p></figcaption></figure>

If a pawn is blocking the bishop, the bishop can't jump over the pawn and eat the castle. The same logic applies to all other arrows.

### Implementation Details

1. The CAPITAL team always starts first.
2. `K` is the King. If the king is dead, the other team wins.
3. We only accept CAPITAL letters for tile names. e.g. `A8`, `H7`, ...
4. The player can only choose his/her piece that has a valid move. If not, ask the player to choose again like the following:

<figure><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2F1YXPFHRPIKjLT9S2eJzO%2Fimage.png?alt=media&#x26;token=15392317-7f35-4aeb-ba57-c0269bc6d3ab" alt="" width="258"><figcaption><p>Demonstration of user keep choosing the wrong tiles</p></figcaption></figure>

4. After the player successfully chooses which piece to move, that piece and its movable tiles are highlighted as shown below:&#x20;

<figure><img src="https://4192366100-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F7rTy2orwOXMPfCAXCcez%2Fuploads%2F67BsqV0zVeNj4R2QR8bj%2Fimage.png?alt=media&#x26;token=5416460a-83f4-49ea-baad-7a380b3bccf8" alt="" width="267"><figcaption><p>Game board of CAPITAL player moving C8 to B7, with all spaces shown</p></figcaption></figure>

5. After each move, if any side wins, print the winner with the given prompt in the skeleton code and end the program immediately.
6. If any side has no valid move, print the given prompt in the skeleton code and end the program immediately.

## Submission

Name your file as `main.c`. Directly zip it as a zip file and submit it to ZINC. you can name the zip file whatever you want.&#x20;

* do NOT put your `main.c` in a folder.&#x20;
* do NOT add extra spaces   or `\n` in your code.

## FAQ

If any part of this assignment is unclear, please ask our seniors in Discord. The Q\&A will be updated here if your questions are meaningful to all tutees.

