diff --git a/README.md b/README.md index d720c5e833fd049d9b0ca8d46aa0aa35c6b788d0..95453c5deb77539cb2ce6aae224ad662f967d40d 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,12 @@ Key differences: # Code example for making a bot ``` python +import os + from library import * -class DoNothingBot(IDABot): + +class MyAgent(IDABot): def __init__(self): IDABot.__init__(self) @@ -32,7 +35,7 @@ class DoNothingBot(IDABot): def main(): coordinator = Coordinator() - bot1 = DoNothingBot() + bot1 = MyAgent() participant_1 = create_participants(Race.Terran, bot1) participant_2 = create_computer(Race.Random, Difficulty.Easy) @@ -40,10 +43,16 @@ def main(): coordinator.set_participants([participant_1, participant_2]) coordinator.launch_starcraft() - coordinator.start_game("InterloperTest.SC2Map") + + path = os.path.join(os.getcwd(), "maps", "InterloperTest.SC2Map") + coordinator.start_game(path) while coordinator.update(): pass + + +if __name__ == "__main__": + main() ``` # How to build (Windows) diff --git a/docs/gettingstarted.rst b/docs/gettingstarted.rst index 29a31fcc9eace81311fe1a98852f28b8ae0fb5be..4603829fb4470cd932720562b1f553b8f0cb8450 100644 --- a/docs/gettingstarted.rst +++ b/docs/gettingstarted.rst @@ -7,11 +7,18 @@ The goal of this page is to get you quickly started using the API. The following code block is the bare minimum you need to start Starcraft II and run your own bot. +An entire AI template project is available here_, it contains the code below +and more. + +.. _here: https://gitlab.ida.liu.se/starcraft-api/sc2-python-bot + .. code-block:: python + import os from library import * - class DoNothingBot(IDABot): + + class MyAgent(IDABot): def __init__(self): IDABot.__init__(self) @@ -24,7 +31,7 @@ your own bot. def main(): coordinator = Coordinator() - bot1 = DoNothingBot() + bot1 = MyAgent() participant_1 = create_participants(Race.Terran, bot1) participant_2 = create_computer(Race.Random, Difficulty.Easy) @@ -32,14 +39,16 @@ your own bot. coordinator.set_participants([participant_1, participant_2]) coordinator.launch_starcraft() - coordinator.start_game("InterloperTest.SC2Map") + + path = os.path.join(os.getcwd(), "maps", "InterloperTest.SC2Map") + coordinator.start_game(path) while coordinator.update(): pass if __name__ == "__main__": - main() + main() Now, let us break it down piece by piece to understand it. @@ -53,7 +62,7 @@ Next, we need to define our bot. .. code-block:: python - class DoNothingBot(IDABot): + class MyAgent(IDABot): def __init__(self): IDABot.__init__(self) @@ -80,7 +89,7 @@ Moving on, we have the code which sets up a game of Starcraft II: def main(): coordinator = Coordinator() - bot1 = DoNothingBot() + bot1 = MyAgent() participant_1 = create_participants(Race.Terran, bot1) participant_2 = create_computer(Race.Random, Difficulty.Easy) @@ -88,7 +97,9 @@ Moving on, we have the code which sets up a game of Starcraft II: coordinator.set_participants([participant_1, participant_2]) coordinator.launch_starcraft() - coordinator.start_game("InterloperTest.SC2Map") + + path = os.path.join(os.getcwd(), "maps", "InterloperTest.SC2Map") + coordinator.start_game(path) while coordinator.update(): pass @@ -111,4 +122,4 @@ to: bot2 = SomeOtherBot() participant_2 = create_participant(Race.Terran, bot2) -where ``SomeOtherBot`` is a bot defined in the same way as ``DoNothingBot``. +where ``SomeOtherBot`` is a bot defined in the same way as ``MyAgent``.