Skip to main content

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]]]

board[2, 2].remove(3)
print(board)

# [[[1], [2], []],
#
# [[4], [5], [6, 'a']],
#
# [[7], [8], [9]]]

print(2 in board[1, 2])

# True

print(2 in board[2, 1])

# False

position = [1, 0]
print(board[position])

# [8]

data = [2, 3, 4]
board[position].append(3)
board[position].append(data)

# [[[1], [2], []],
#
# [[4], [5], [6, 'a']],
#
# [[7], [8, 3, [2, 3, 4]], [9]]]

import numpy as np
pos = np.array([0, 0])
board[pos] = ['0']
print(board)

# [[[1], [2], []],
#
# [[4], [5], [6, 'a']],
#
# [['0'], [8, 3, [2, 3, 4]], [9]]]

The fill parameter is set to True for the example, where all squares are numbered. If you set the fill parameter to False or do not specify (default is False), all z-axis arrays will be empty.

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/remove methods and __iter__ dunder method work for adding, removing and iterating through elements in the z-dimension arrays as the z-dimension arrays are simply Python lists.

Metadata

Release files for gameboard 1.0.9.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gameboard 1.0.9.1
File Size Uploaded Provenance Actions
gameboard-1.0.9.1.tar.gz 3.1 kB Without provenance Details for gameboard-1.0.9.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gameboard 1.0.9.1
File Interpreter ABI Platform Actions
gameboard-1.0.9.1-py3-none-any.whl Python 3 none any Details for gameboard-1.0.9.1-py3-none-any.whl

Total release size: 6.2 kB

Release files / gameboard-1.0.9.1.tar.gz

Download URL gameboard-1.0.9.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
3f43e368d6c56823417f29dbbce0bfe80fe00b2e43eb6df4c7a001d02268aa74
BLAKE2b-256 checksum
How to use checksums
de2ffe34dffc9f747de07c1015eeac5d3253c434d97a3dd004737964dd903eb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / gameboard-1.0.9.1-py3-none-any.whl

Download URL gameboard-1.0.9.1-py3-none-any.whl
Size 3.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
044b3c6e8d5c286fa536ee5b59c3a8bc0f0a16cf59ea7a6910cd8ebca3fd97d9
BLAKE2b-256 checksum
How to use checksums
2953165dc9d32dfb3aa4134079170e0ebf747ace6048b5cff96393b2f8c8a801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Security for gameboard 1.0.9.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page