Skip to content

exact 12 tile core spawns #2

Closed
Closed

Description

@subodhbgwt

the updated version you made works because canspawn filters the nearby tiles, but theres a change so that it specifiaclly finds the 12 tiles around the core.

def core(self, ct: Controller) -> None:
if not spawnBots(self.numSpawned, ct):
return

core_pos = ct.get_position()
threats = findThreats(ct)

for dx in (-1, 0, 1, 2):
    for dy in (-1, 0, 1, 2):
        if 0 <= dx <= 1 and 0 <= dy <= 1:
            continue

        spawn_pos = Position(core_pos.x + dx, core_pos.y + dy)

        if not ct.can_spawn(spawn_pos):
            continue

        launcher_threatened = any(
            spawn_pos.distance_squared(threat) <= 2
            for threat in threats
        )
        if launcher_threatened:
            continue

        ct.spawn_builder(spawn_pos)
        self.numSpawned += 1
        return

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions