Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR 4444 #205

Open
Yifei-Bi opened this issue Dec 2, 2024 · 5 comments
Open

ERROR 4444 #205

Yifei-Bi opened this issue Dec 2, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@Yifei-Bi
Copy link

Yifei-Bi commented Dec 2, 2024

it can not run:
for vespene in self.vespene_geyser:
await self.build_gas(UnitTypeId.ASSIMILATOR, vespene)

@BurnySc2 BurnySc2 added the bug Something isn't working label Dec 6, 2024
@hnuxxaqtp
Copy link

me too

@BurnySc2
Copy link
Owner

Calling self.build_gas should not work inside the step function body of a bot class.
The only definition of build_gas is in the unit.py file.

python-sc2/sc2/unit.py

Lines 1299 to 1325 in 15fbac3

def build_gas(
self,
target_geysir: Unit,
queue: bool = False,
can_afford_check: bool = False,
) -> UnitCommand | bool:
"""Orders unit to build another 'unit' at 'position'.
Usage::
# Target for refinery, assimilator and extractor needs to be the vespene geysir unit, not its position
SCV.build_gas(target_vespene_geysir)
:param target_geysir:
:param queue:
:param can_afford_check:
"""
gas_structure_type_id: UnitTypeId = race_gas[self._bot_object.race]
assert isinstance(
target_geysir, Unit
), "When building the gas structure, the target needs to be a unit (the vespene geysir) not the position of the vespene geysir."
return self(
self._bot_object.game_data.units[gas_structure_type_id.value].creation_ability.id,
target=target_geysir,
queue=queue,
subtract_cost=True,
can_afford_check=can_afford_check,
)

The bot class defines a self.build() function which should work with gas structures.

python-sc2/sc2/bot_ai.py

Lines 941 to 943 in 15fbac3

if building in gas_buildings:
assert isinstance(near, Unit)
builder.build_gas(near)

Can you give context to your example or show the error stacktrace?

@hnuxxaqtp
Copy link

111
222
333
444
555
666
777

@BurnySc2
Copy link
Owner

I recently updated the AbilityIds, but it only does up to Id number 4132:

SALVAGEEFFECT_SALVAGE = 4128
SALVAGESENSORTOWERREFUND_SALVAGE = 4130
WORKERSTOPIDLEABILITYVESPENE_GATHER = 4132
def __repr__(self) -> str:
return f"AbilityId.{self.name}"

The issue is Id 4444 does not map to an ability in that list. Different maps may have different Ids, especially AIE maps.

Did you download the map 2000AtmospheresAIE from https://aiarena.net/wiki/maps/#wiki-toc-map-downloads or can you send me a download link ?
Does the error appear on other maps too?

If not, you may have to generate the ids by running the id-generator:
https://github.com/BurnySc2/python-sc2/blob/develop/generate_id_constants_from_stableid.py

@hnuxxaqtp
Copy link

yeah
i get it
i copy your ability_id.py code to my local ability_id.py and it works
maybe i install it with "pip install --upgrade burnysc2 "dose not get the latest version
thanks for you help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants