Summer Deals - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Cyber Battle Game
Game elements
3. Step 1 – board representation
Main Game Loop
Final game

Instruction

In this initial section, we'll try to come up with proper Python representations of our game objects. We'll also try to visualize them in the console.

We'll start by creating the board for our game. It's a 4 x 4 board, which should initially look like this:

- - - -
- A - -
- - - -
- - B -

The hyphens represent empty fields; the letters A and B represent the robots.

Exercise

Create a function named create_board(). The function should return the initial game board.

The game board is a list which contains four sublists (rows). Each sublist (row) should store four string elements, each representing a single field in a given row.

Try to create the game board representation from the Instruction. For each "empty" field, insert a hyphen into the given cell. For fields with robots, insert a string containing 'A' or 'B', respectively.

Invoke the create_board() function to verify if the board you created is correct.

Stuck? Here's a hint!

Remember that lists are introduced with square brackets and their elements are separated with commas. A sublist from the game board looks as follows:

['-', 'A', '-', '-']