Skip to content

Instantly share code, notes, and snippets.

@joereynolds
Last active August 6, 2024 18:59
Show Gist options
  • Select an option

  • Save joereynolds/8c0d5dd5df3926106d65fe8bbfd40cdb to your computer and use it in GitHub Desktop.

Select an option

Save joereynolds/8c0d5dd5df3926106d65fe8bbfd40cdb to your computer and use it in GitHub Desktop.
Spatial grid prepopulation
from collections import namedtuple
from typing import Tuple
cells: dict[Tuple[int, int], list] = {
(i, j) : []
for i in range(10)
for j in range(10)
}
unit = namedtuple('Point', ['x', 'y'])
unit.x = 300
unit.y = 34
cells[(unit.x // 96, unit.y // 96)].append('testing')
print(cells)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment