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

Add instruction on how to install this repo using pip #4

Closed
BurnySc2 opened this issue Jun 8, 2019 · 2 comments
Closed

Add instruction on how to install this repo using pip #4

BurnySc2 opened this issue Jun 8, 2019 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@BurnySc2
Copy link
Owner

BurnySc2 commented Jun 8, 2019

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)
@BurnySc2 BurnySc2 added the help wanted Extra attention is needed label Jun 8, 2019
BurnySc2 pushed a commit that referenced this issue Nov 27, 2019
@BurnySc2
Copy link
Owner Author

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.

@KeithBrio
Copy link

KeithBrio commented Mar 18, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants