Skip to content

bsp.split_recursive raises TypeError when seed is a tcod.random.Random instance #168

@lionas32

Description

@lionas32

Describe the bug

bsp.split_recursive raises a TypeError when the seed parameter receives a tcod.random.Random instance, even though the type hint allows tcod.random.Random | None.

To Reproduce

import tcod

bsp = tcod.bsp.BSP(x=0, y=0, width=50, height=50)
random = tcod.random.Random()

bsp.split_recursive(
    depth=2,
    min_width=6,
    min_height=6,
    max_horizontal_ratio=1.5,
    max_vertical_ratio=1.5,
    seed=random,  # raises TypeError
)
TypeError: initializer for ctype 'union TCOD_Random *' must be a cdata pointer, not Random

However setting seed=random.random_c works fine. split_recursive could internally access .random_c for the type hint to hold.

Desktop (please complete the following information):

  • OS: macOS 15.4.1
  • Python version: 3.13.7
  • tcod version: 19.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions