A 3D grid creation library for simulation and games.
Project description
Gameboard
This library creates a 3-dimensional grid object with 2 fixed-length dimensions (x, y) and a third unfixed-length dimension (z).
Example use cases include multi-agent simulations where multiple agents can be placed on a 2D grid and be in the same cell, or board games where the board is a 2D grid and pieces can be stacked on top of or adjacent to each other.
The primary purpose of this project is to be able to access coordinates just as on a coordinate plane.
e.g. with the variable board
of type grid
, board[0, 0]
will return the bottom-left corner of the grid.
Install
Run:
pip install gameboard
Example Usage
from gameboard.grid import grid
board = grid(grid_size = 3, fill = True)
print(board)
# [[[1], [2], [3]],
#
# [[4], [5], [6]],
#
# [[7], [8], [9]]]
print(board[2, 1])
# [6]
board[2, 1].append('a')
print(board)
# [[[1], [2], [3]],
#
# [[4], [5], [6, 'a']],
#
# [[7], [8], [9]]]
Warning
This project does not currently work with negative indices for the y-coordinate when accessing the grid.
This project is in an early development stage and may not be suitable for all use cases. For ease of use, the __iter__
dunder method has been implemented for both the y-axis and x-axis arrays, and the append
method has been implemented for adding elements to the z-dimension arrays.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for gameboard-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee9de0b0b05bc99fd6f329808dd85c984e05f21e03fc42eb0a51bdd925d32dc0 |
|
MD5 | 01a02cd20964c4dbf3467cad72bc4883 |
|
BLAKE2b-256 | a40759c2cd097401371bab092f2463bdd0654089a58f5713b2bf91076a48f743 |