Skip to main content

A simple to use library for finding the shortest path in a grid.

Project description

gtravyl

gtravyl provides an easy way to take a grid-like layout and compute the shortest distance from any two desired cells in the grid.

How does it work?

Suppose you are trying to create a real time strategy game. You may have a grid-like map internally represented as a numpy array. It might look something like:

0001111
0001111
0000000
1101110
1101110

where the 1 indicates you cannot travel into that cell. Now you want to move a character that is in the cell with index (0, 0) to the bottom right corner. Ideally, you would like to know the shortest path too. This can be done easily with gtravyl, observe:

import numpy as np
import gtravyl as gt
world = np.array([[0, 0, 0, 1, 1, 1, 1],
                  [0, 0, 0, 1, 1, 1, 1],
                  [0, 0, 0, 0, 0, 0, 0],
                  [1, 1, 0, 1, 1, 1, 0],
                  [1, 1, 0, 1, 1, 1, 0]])
path = gt.shortest_path(world, (0, 0), (4, 6))
for cell in path:
    world[cell] = 2

print(world)

This gives a path (represented by the cells with 2) that looks like one should expect:

[[2 2 2 1 1 1 1]
 [0 0 2 1 1 1 1]
 [0 0 2 2 2 2 2]
 [1 1 0 1 1 1 2]
 [1 1 0 1 1 1 2]]

Documentation

More documentation can be found on readthedocs.

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

gtravyl-0.1.5.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gtravyl-0.1.5-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file gtravyl-0.1.5.tar.gz.

File metadata

  • Download URL: gtravyl-0.1.5.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gtravyl-0.1.5.tar.gz
Algorithm Hash digest
SHA256 e7ac64cba0d2e3c258ebb3ebc85d5c9dc9a78abab2a80ab905e03b801256a485
MD5 70ef49c6c8f4711f801924b16b3f9b94
BLAKE2b-256 86cdf8b0249acb29e75078a54188fcd47bb9d12fa1a719d07f2d70bd308320ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtravyl-0.1.5.tar.gz:

Publisher: python-publish.yml on thyrgle/gtravyl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gtravyl-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: gtravyl-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gtravyl-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b8de1d370415c4c545c43ef730643112a06168ceeba5c97eb02643f65bca5857
MD5 3317605eb9bee6676ceac2254851796f
BLAKE2b-256 be459a53c45122c0bc9d33d15328feaf3fd0b9a3189d414adc4e7190a55715cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for gtravyl-0.1.5-py3-none-any.whl:

Publisher: python-publish.yml on thyrgle/gtravyl

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page