Skip to content
Snippets Groups Projects
Commit 4bb91868 authored by Edvard Thörnros's avatar Edvard Thörnros
Browse files

Change to use a Python3 module structure from the start

There's a lot of difficulty for students to share their agents
between eachother. When they start the project they don't think about
the need to make it into a module since it "runs".

A lot has been done in this commit, move everything to a seperate folder
which the students have to rename. Reformat the README.md to respect
people reading it in the terminal and add some more instructions for the
setup.
parent 296e4a99
No related branches found
No related tags found
No related merge requests found
# StarCraft II Python Bot
This repository contains a passive PyCommandCenter-based bot for StarCraft II. It is intended to be a reasonable starting-point for creating your own StarCraft II-playing system.
This repository contains a passive PyCommandCenter-based bot for StarCraft II.
It is intended to be a reasonable starting-point for creating your own
StarCraft II-playing system.
## Setup for creating your own bot
1. Locate your own fork ("copy") of this project and its repository. If you are participating in TDDD92 or TDDE25, **you should *not* create your own fork!** Instead, begin by registering your group in Webreg. We periodically run a script that forks this project for all registered groups, placing projects in the [TDDD92-2020 group](https://gitlab.liu.se/tddd92-2020) or the [TDDE25-2020 group](https://gitlab.liu.se/tdde25-2020). We will require you to use these projects and repositories.
1. Locate your own fork ("copy") of this project and its repository. If you are
participating in TDDD92 or TDDE25, **you should *not* create your own
fork!** Instead, begin by registering your group in Webreg. We
periodically run a script that forks this project for all registered groups,
placing projects in the [TDDD92-2020 group](https://gitlab.liu.se/tddd92-2020)
or the [TDDE25-2020 group](https://gitlab.liu.se/tdde25-2020). We will require
you to use these projects and repositories.
2. Now clone the repository from Gitlab using the following command: `git clone <path>`, where `<path>` is shown when you press the blue button *Clone* in the top-right corner on your repository page. If you have configured SSH-access, then use the SSH link, otherwise use the HTTP link.
2. Now clone the repository from Gitlab using the following command: `git clone
<path>`, where `<path>` is shown when you press the blue button *Clone* in
the top-right corner on your repository page. If you have configured
SSH-access, then use the SSH link, otherwise use the HTTP link.
3. Next, setup the library in PyCharm. See [PyCommandCenter's page on PyCharm](https://gitlab.liu.se/starcraft-ai-course/pycommandcenter/blob/master/pycharm.md) for instructions.
3. Next, setup the library in PyCharm. See [PyCommandCenter's page on PyCharm](https://gitlab.liu.se/starcraft-ai-course/pycommandcenter/blob/master/pycharm.md)
for instructions.
4. Everything is now ready for PyCharm: Start PyCharm, and then select "Open" and navigate to the location you cloned your fork of this repository to.
4. Everything is now ready for PyCharm: Start PyCharm, and then select "Open"
and navigate to the location you cloned your fork of this repository to.
5. In order to run the code, right click the file named "main.py" in the project panel to the right, and select "Debug main". This will run the code in "main.py", and consequently start StarCraft II. You can also edit the code in "main.py" by double-clicking "main.py".
5. In order to run the code, right click the file named "start.py" in the
project panel to the right, and select "Debug main". This will run the code
in "start.py", and consequently start StarCraft II. You can also edit the
code in "start.py" by double-clicking "start.py".
6. Rename the folder 'myagent' to something unique, preferably with your group number
in the name. This will make it easier when you want to run against other bots. So make
sure ALL of the source code for the bot lives in the folder.
File moved
from typing import Optional
from library import *
from myagent.extra import *
class MyAgent(IDABot):
def __init__(self):
IDABot.__init__(self)
def on_game_start(self):
IDABot.on_game_start(self)
def on_step(self):
IDABot.on_step(self)
import os
from typing import Optional
from library import *
class MyAgent(IDABot):
def __init__(self):
IDABot.__init__(self)
def on_game_start(self):
IDABot.on_game_start(self)
def on_step(self):
IDABot.on_step(self)
from library import (
Coordinator, Difficulty, Race,
create_participants, create_computer,
)
from myagent.main import MyAgent
def main():
fight_against_agent = False
coordinator = Coordinator(r"D:\StarCraft II\Versions\Base69232\SC2_x64.exe")
bot1 = MyAgent()
# bot2 = MyAgent()
bot1 = MyAgent()
participant_1 = create_participants(Race.Terran, bot1)
# participant_2 = create_participants(Race.Terran, bot2)
participant_2 = create_computer(Race.Random, Difficulty.Easy)
if fight_against_agent:
bot2 = MyAgent() # Change me
participant_2 = create_participants(Race.Terran, bot2)
else:
participant_2 = create_computer(Race.Random, Difficulty.Easy)
coordinator.set_real_time(True)
coordinator.set_participants([participant_1, participant_2])
......@@ -37,4 +32,4 @@ def main():
if __name__ == "__main__":
main()
\ No newline at end of file
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment