Game/Kivy: Deploy treasures randomly across the board
Making games with Kivy (3/4)
*note that this task is a part of a series of tasks, but also self-contained.
(1) Objective
Generate a random treasure board using python.
(2) Requirement
1) You are required to write code in Python. Please take a look at python tutorials beforehand. You can find some from Kivy Introduction.
2) We’re making a game that is similar to the Minesweeper, but the other way around. We’re deploying treasures instead of mines, and let player find them out rather than avoid clicking on it.
3) To begin with this game, create an empty board and deploy treasures randomly.
Write a python class called ‘Board’ as follows:
- Create an empty 4x4 board using
list
, so that 16 cards can fit into. - Randomly pick 9 cards amongst 16, and mark them as treasures. (see
random.randint(a, b)
) - Implement a debug function that prints the board to the console.
4) Now the treasures are deployed, but there are 7 empty cards left.
- Count the number of surrounding treasures of each non-treasure card.
- Write the number down to the card. (put 0 in case there is no surrounding treasures)
5) Publish your work to your GitHub (or other) repo.
(3) Expected outcome
A python class that represents a random 16-card deck. See (2) Requirement for detail.