Board class
This commit is contained in:
parent
0442e04eaa
commit
88ecb3a2e2
1 changed files with 42 additions and 0 deletions
42
marinbad/board.py
Normal file
42
marinbad/board.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
class Board:
|
||||||
|
def __init__(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def show_board(board):
|
||||||
|
"""
|
||||||
|
Display the board o screen
|
||||||
|
:param board: the board
|
||||||
|
:type board list
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
for index, val in enumerate(board):
|
||||||
|
print(f"Row {index + 1}: {val}")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def nb_allumettes(board: list):
|
||||||
|
"""
|
||||||
|
Return the number of remaining allumettes
|
||||||
|
:param board: the board
|
||||||
|
:type board list
|
||||||
|
:return: int
|
||||||
|
"""
|
||||||
|
return sum(board)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def retirer(board, row, stick):
|
||||||
|
"""
|
||||||
|
Computer player move on the board
|
||||||
|
:param board: the board
|
||||||
|
:type board list
|
||||||
|
|
||||||
|
:param row: the selected row to remove allumettes from
|
||||||
|
:type row: int
|
||||||
|
|
||||||
|
:param stick: the number of allumettes to remove
|
||||||
|
:type stick: int
|
||||||
|
|
||||||
|
:return: board
|
||||||
|
"""
|
||||||
|
board[int(row) - 1] = board[int(row) - 1] - int(stick)
|
||||||
|
return board
|
||||||
Loading…
Reference in a new issue