Board
Last Updated: v1.5
from PythonFunctions import Board
brd = Board.CreateBoard(5, 5)
Board.DisplayBoard(brd)
Used to quickly create or display a 2d array of items. Useful for creating boards for board games.
CreateBoard
To create a board, you can use the Board.CreateBoard() function
- Board.CreateBoard(x, y, *, param='-')
Returns a 2D array filled with value
- Parameters
x (int) – The width of the board
y (int) – The height of the board
value (str) – Optional, The default value to set each item. Defaults to ‘-’
- Returns
The 2D array
- Return type
list[list[str]]
DisplayBoard
Display a 2d array? Use this useful function.
- Board.DisplayBoard(brd, *, colourData, coords=False)
Prints out the 2D array in the terrminal
- Parameters
brd (list[list[str]]) – The 2D array
colourData (dict) – Optional, The colour to make each item
coords (bool) – Show the coordinates of the board on either side
An example of colourData is shown below use Fore from colorama for the colours (or manually do the codes yourself) Any unassigned values will be shown in the default colour (white)
MultiBoardDisplay
(with help from chatGPT)
Display multiple boards side by side in the terminal.
- Board.MultiBoardDisplay(*boards, colourData)
Return the message to print multiple boards
- Parameters
boards (tuple[list[list[str]]] (2D list one after another)) – The boards to show. Can just be listed as (board, board, board) etc…
colourData (dict) – Optional, The colour to make each item
- Return type
str
- Returns
Message to print multiple boards.