python-sc2
python-sc2 copied to clipboard
expand and build_assimilator does not work
-
pixel_map.py, i delete two sentences
assert self.bits_per_pixel % 8 == 0, "Unsupported pixel density" assert self.width * self.height * self.bits_per_pixel / 8 == len(self._proto.data) -
class sentdebot, i delete distribute_works()
or it won't work!
problem : train probe -- good build pylons -- good expand -- bad build assimilator -- bad
even it get so much money ,it does not work
import sc2
from sc2 import run_game, maps, Race, Difficulty
from sc2.player import Bot, Computer
from sc2.constants import NEXUS, PROBE, PYLON, ASSIMILATOR
class SentdeBot(sc2.BotAI):
async def on_step(self, iteration):
await self.build_pylons() # pylons are protoss supply buildings
await self.expand() # expand to a new resource area.
await self.build_assimilator() # getting gas
async def build_workers(self):
# nexus = command center
for nexus in self.units(NEXUS).ready.noqueue:
# we want at least 20 workers, otherwise let's allocate 70% of our supply to workers.
# later we should use some sort of regression algo maybe for this?
if self.can_afford(PROBE):
await self.do(nexus.train(PROBE))
async def build_pylons(self):
if self.supply_left < 5 and not self.already_pending(PYLON):
nexuses = self.units(NEXUS).ready
if nexuses.exists:
if self.can_afford(PYLON):
await self.build(PYLON, near=nexuses.first)
async def expand(self):
if self.units(NEXUS).amount < 2 and self.can_afford(NEXUS):
await self.expand_now()
async def build_assimilator(self):
for nexus in self.units(NEXUS).ready:
vaspenes = self.state.vespene_geyser.closer_than(25.0, nexus)
for vaspene in vaspenes:
if not self.can_afford(ASSIMILATOR):
break
worker = self.select_build_worker(vaspene.position)
if worker is None:
break
if not self.units(ASSIMILATOR).closer_than(1.0, vaspene).exists:
await self.do(worker.build(ASSIMILATOR, vaspene))
run_game(maps.get("AbyssalReefLE"), [
Bot(Race.Protoss, SentdeBot()),
Computer(Race.Terran, Difficulty.Easy)
], realtime=False)
win10 64 bits python 3.6.8
i have changed the sc2 from stable to develop version , pixel_maps and distribute_work both ok now, but expand and build assimilator still do not work. build stargate and train spider work correctly i upgrade the python from 3.6.8 to 3.7.3 now