Skip to content
Snippets Groups Projects
Commit fac29f98 authored by Edvard Thörnros's avatar Edvard Thörnros Committed by Jonas Kvarnström
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 each other. 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 separate 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 c8c85abb
Branches edvth289/sc2-python-bot-correct-modules-from-the-start
No related tags found
1 merge request!10edvth289: Change to use a Python3 module structure from the start
......@@ -11,4 +11,11 @@ This repository contains a passive PyCommandCenter-based bot for StarCraft II. I
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 that 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