BurnySc2/python-sc2

Add instruction on how to install this repo using pip

BurnySc2 opened this issue · 2 comments

We need a command in the readme on how to install this repo similar to a command from here Dentosal/python-sc2#266 (comment) so people can start using it in SC2 client version 4.9.0

Should be able to install this fork with command
pip install pipenv burnysc2 --upgrade
If you are on linux or mac, you might have to use pip3 or pip3.7 instead of pip

Changes that bot authors have to consider when changing to this fork (work in progress):

General:

  • Numpy and scipy are now part of the requirements
  • Scipy is used to quickly calculate the distances between all units every frame (distances.py)
  • self.on_start() function is now async, self.on_start_async() has been removed
  • self.on_end() function is now async
  • Some effects, that are marked as Unit in the API, were moved to effects

Units management:

  • self.units (previously units and structures) was split into self.units and self.structures
  • self.known_enemy_units (enemy units and structures) and self.known_enemy_structures (only enemy structures) are now changed and renamed into self.enemy_units (only enemy units) and self.enemy_structures (only enemy structures)
  • self.geysers is renamed to self.gas_buildings (refineries, extractors, assimilators)
  • self.state.mineral_field and self.state.vespene_geyser are now in the BotAI class (property useable through self.mineral_field and self.vespene_geyser). self.resources contains both.
  • self.state.units is now self.all_units which contains all units (self, enemy, neutral)
  • Creating a new Units object now requires the bot object, because cached distances are stored in the bot object and each Unit object needs to be able to access it. So new Units objects have to be created with Units([], self)

Actions management:

  • self.do(action) is no longer async (no await needed). This function is recommended over self.actions.append(action) again. self.do(action, subtract_cost=False, subtract_supply=False, can_afford_check=False) has now optional parameters. When a build command is given, subtract_cost=True is recommended. When a unit train command is given, subtract_cost=True, subtract_supply=True is recommended.
  • self.do_action(actions_list) has become a private function self._do_actions(actions_list) which automatically executes self.actions at the end of the step and clears the list (executed by main.py)
  • self.already_pending() now checks all unit orders by default, not just worker orders

Effects:

  • Reaper grenade, parasitic bomb (after the unit died) and forcefield are now emulated effects in self.state.effects instead of units/structures

Debug draw:

  • await self._client._send_debug() is now automatically executed and emptied after the user issues draw shape requests through self._client.debug_box_out() etc. functions. See Ramp Wall Bot for more examples on debugging commands.

New bot_ai functions:

def step_time() -> Tuple[float, float, float, float]
def calculate_supply_cost(unit_type: UnitTypeId) -> float
def calculate_cost(item_id: Union[UnitTypeId, UpgradeId, AbilityId]) -> Cost
experimental: def train(unit_type: UnitTypeId, amount: int = 1, closest_to: Point2 = None, train_only_idle_buildings: bool = True) -> int
def structure_type_build_progress(structure_type: Union[UnitTypeId, int]) -> float
def tech_requirement_progress(structure_type: UnitTypeId) -> float
experimental: def research(upgrade_type: UpgradeId) -> bool
def in_map_bounds(pos: Union[Point2, tuple]) -> bool

New function for Unit.py:
Unit.is_facing(other_unit: Unit)

Added helpful dictionaries in sc2/dicts folder

Started with a documentation and tutorial

Added more tests in /test folder

Bug fixes:

  • Only one train command per structure was issued per frame (e.g. you couldn't make 200 Zerglings in a single frame if you had 100 larvae)

Since it is now in pypi, the installation instruction is clear.

Probably should write down notable changes between dentosal's library and this fork on the documentation website.

Just updating my bots after not touching it for 9 months and moving from Dentosal/python-sc2 and noticed some differences not listed and as I was directed here I figured it might be worth noting them.

  • can_afford has changed to return a bool, and is not wrapped by CanAffordWrapper so you'll have to manually figure out what yo are lacking in. Seems like a slight regression.
  • noqueue has been replaced with is_idle for structures so self.structures(UnitTypeId.BARRACKS).ready.is_idle rather than self.units(BARRACKS).noqueue.
  • Point2 has removed distance2_to, not checked but distance_to_point2 seems to work.