At My Fingertips

Rapid Playground

Documentation

Chessboard

In this activity we will compose a chessboard like this one:

chessboard

The text notation

Let's first start focusing on the text notation that identifies the cells.

Implement the following letter_row function, so that it returns a graphic representing the horizontal " a b c d e f g " notation for the chessboard.

Notice that you also want to add empty square corners on the sides of the "a" and the "g" squares.

  • The square_size parameter indicates the size of each square in the chessboard
  • The top parameter is a boolean value: True if the row should go on top of the chessboard, False if it should go on the bottom.

Use the given TEXT_COLOR color for the color of the text and the TEXT_BACKGORUND color for the background brown color. Use "Fira Sans" as the font.

Loading...

Let's check how your implementation of the letter_row function behaves:

Loading...

Now let's implement the number_col function that generates the vertical "1 2 3 4 5 6 7 8" notation.

  • The square_size parameter indicates the size of each square in the chessboard
  • The left parameter is a boolean value: True if the notation should go on the left side of the chessboard, False if it should go on the right

Use the given TEXT_COLOR color for the color of the text and the TEXT_BACKGORUND color for the background brown color.

Loading...

Let's check how your implementation of the the number_col function behaves:

Loading...

The chessboard

Let's now focus on the central piece of the graphic: the actual chessboard. Implement the chessboard_body function so that it returns a chessboard with squares of the given square_width.

Use the given WHITE color for the bright tiles and the given BLACK color for the dark tiles.

The chessboard should have a bright tile on the top left and on the bottom right to be oriented correctly.

Loading...

Finally, let's combine all the solutions together to implement the chessboard function! The function should return a chessboard surrounded by letter and number notations on all sides.

Use the letter_row, number_col and chessboard_body functions in your chessboard function.

Loading...

This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.

Chessboard

Logo of PyTamaro

PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI

Privacy PolicyPlatform Version 320e1c5 (Thu, 16 May 2024 14:11:39 GMT)