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

expand and build_assimilator does not work #279

Open
qq309381 opened this issue May 13, 2019 · 2 comments
Open

expand and build_assimilator does not work #279

qq309381 opened this issue May 13, 2019 · 2 comments

Comments

@qq309381
Copy link

qq309381 commented May 13, 2019

  • 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)
@qq309381
Copy link
Author

win10 64 bits
python 3.6.8

@qq309381
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant