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

don't have "run_game" file in sc2 lib #317

Open
SemaSC2 opened this issue Jan 27, 2022 · 1 comment
Open

don't have "run_game" file in sc2 lib #317

SemaSC2 opened this issue Jan 27, 2022 · 1 comment

Comments

@SemaSC2
Copy link

SemaSC2 commented Jan 27, 2022

I don't have "run_game" file. It is in all sources and is used in the documentation%0A%0Asc2.-,run_game,-(%0A%20%20%20%20sc2.maps.get), but I can't find how get it anywhere.
My code:

import sc2
from sc2.bot_ai import BotAI
from sc2.player import Bot, Computer

class MyBot(BotAI):
    async def on_step(self, iteration: int):
        print(f"This is my bot in iteration {iteration}!")

sc2.run_game(
    sc2.maps.get("AcropolisLE"),
    [Bot(sc2.Race.Zerg, MyBot()), Computer(sc2.Race.Zerg, sc2.Difficulty.Hard)],
    realtime=False,
)

error:
AttributeError: module 'sc2' has no attribute 'run_game'

@JayRizzo
Copy link

hi @SemaSC2 , I hope you are well.

I am playing around with the code and looks like this worked for me.

This is what got me working.

from sc2.main import run_game

my test code so far:

import sc2
from sc2.bot_ai import BotAI  # Parent AI Class that you will inherit from
from sc2.data import Difficulty
from sc2.data import Race
from sc2.main import run_game
from sc2.player import Bot
from sc2.player import Computer
from sc2 import maps
from sc2 import units
from sc2.constants import *
import random

class RizzoBot(BotAI): # inhereits from BotAI (part of BurnySC2)
    async def on_step(self, iteration): # on_step is a method that is called every step of the game.
        print(f"This is my bot in iteration {iteration}") # prints out the iteration number (ie: the step).
        await self.distribute_workers()

        # INFO
        print(f"INFO_ \
                 Minerals: {self.minerals} \
                  Vespene: {self.vespene} \
        Total Supply Used: {self.supply_used} \
          Total Army Size: {self.supply_army} \
        Total Worker Size: {self.supply_workers} \
               MAX Supply: {self.supply_cap} \
        Total Supply Used: {self.supply_used} \
        Total Supply Left: {self.supply_left} \
        Units_ \
               Total Townhalls: {self.townhalls} \
        Total Structures Count: {self.structures} \
                   Total Units: {self.units} \
            Total Worker Count: {self.workers} \
             Idle Worker Count: {self.idle_worker_count} \
              Total Army Count: {self.army_count} \
              Total Warp Gates: {self.warp_gate_count} \
                   Total Larva: {self.larva} \
           Total Gas Buildings: {self.gas_buildings} \
        OtherInformation_ \
          Current Selected Race: {self.race} \
              Current Player Id: {self.player_id} \
        OtherInformation_ \
          1st Townhall Location: {self.start_location} \
        Main Base Ramp Location: {self.main_base_ramp}")

run_game(
    maps.get("2000AtmospheresAIE"),
    [Bot(Race.Protoss, RizzoBot()),
     Computer(Race.Zerg, Difficulty.Hard)],
    realtime=True
)

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

2 participants