what is going on everybody and welcome
to tutorial series that I have been
looking forward to for quite some time
and that is building a eyes in Starcraft
2 so if you don't know what Starcraft 2
is it's just a kind of like strategy
game very much like command and conquer
Age of Empires here played those where
you've got workers and you so you start
off with some workers you collect some
resources you build more buildings your
research upgrades you amass an army and
you annihilate your enemy so that's
basically the game so it's a little more
complicated than that but that's
basically it so around like mid 2017
deepmind the machine-learning slash deep
learning company partnered with Blizzard
the creators of Starcraft 2 to create an
API around the game to help people
create artificial intelligences to play
the game deep mines main interest seems
to be more like creating reinforcement
learning algorithms but with the API you
can do anything from just creating
simple rule-based BOTS all the way up to
yes like a reinforcement learning
algorithm that you would hope could
could defeat other players unfortunately
the game is unbelievably complicated and
to my knowledge there exists no
reinforcement learning algorithm that's
actually decent at playing the game yet
just because the extreme level of
complexity to the game now what you need
it to play is pretty simple the
Starcraft 2 is free to play now so you
just need to just download it and
install and all that and then we're
going to be using Python - sc2 to
interact with the actual API itself
quick shout out by the way - my two
recent sponsors Nietzche vich and
Werther's original a user named where
there is original not actually where
there's original the company if you
didn't know you can sponsor the channel
if you're looking at a video there
should be a blue sponsor button some
countries it's not available
but if you click on that you can see the
perks that we get basically you get
early access to some of the content and
you get the opportunity to shape future
content via polls that I put up for next
topics that people would like to see
also you even most importantly you get
certain emojis for live chat and then
also a chat badge just like in the
comment sections so if you want to
support awesome this is my full-time job
and if you want to help me continue
making content like this you sure can
now what we're gonna do is so yeah first
of all you need to go to battlenet
basically make an account head to the
download section and download Starcraft
2 I'm on Windows you can get on Mac I
believe there's a way to get it on Linux
I I really don't know anything about
putting it on Linux I may eventually be
finding out but at least for now Windows
and Mac so once you have that you're
going to need Python - SC - not to be
confused with PI se - so python SC - is
a different wrapper than PI SC Tunip is
e - is from deepmind themselves it's
really more focused around reinforcement
learning and it's a more complicated
package if you ask me I think this one's
a little easier to get started with and
you could definitely do reinforcement
learning and all that it's just pi sc2
offers some things more oriented towards
deep learning and stuff that will
probably save you time later on down the
road so we may find ourselves using that
package later but for now python - SC -
so to get that it's just pip install SC
- it's super simple once you have those
packages you also need the map packs now
I've linked to them in the text-based
version of this tutorial and I'll try to
put them in the description of the
tutorial as well but here they are so
what you're gonna want is at least one
of these I would say just get them all
might as well have a bunch of maps that
you can play on but you should at least
probably grab like season 1 we're just
gonna be playing on that first map in
there oh you just have to download it
sorry so anyway I was gonna show you the
perhaps in there and then when you have
those you want to extract those to your
actual Starcraft 2 environment so let me
pull up see if I have one up or not
I don't think I do my waters in the way
mmm
I don't but let me just pull it up real
quick just so you get an idea this is
pretty important otherwise it's not
gonna find it so if you go to wherever
you like installed Lakes probably like
your C Drive and then Program Files or
something like that
let me find mine real quick StarCraft II
so I actually installed mine in a J
Drive didn't want to give up precious
solid-state space for the game inside of
here is the actual game itself you
probably don't have a Maps directory yet
go ahead and make one and then inside of
here is where you're gonna extract your
actual maps and then inside there are
your maps so don't make make sure you
just don't extract maps directly into
the maps directory because it's not
gonna find them for whatever awesome
reason it just won't
so moving this aside I'm going to assume
most people probably didn't even have
this game installed so probably here I
would recommend you pause and wait till
you actually have the game downloaded
and installed otherwise what we're gonna
go ahead and do now is proceed to the
actual part of the tutorials so let me
pull up some code here so this is
actually what's running right now off
here and I'm gonna go ahead and just
close out of this we're gonna forfeit
the match sorry guys and I'll close this
one out too and I always get this always
takes me like forever to clear this
thing out I thought I could just like
right-click maybe it's a left click
there we go
hide panel okay so working with this is
actually pretty darn simple but it's
just kind of like getting used to the
patterns that you have to have to use so
in order to make use of the package
we're just going to need to import sc2
and make that a little bigger and then
we're gonna go from SC to importer I'm
sorry from SC to import run game that's
just going to have us actually be able
to like launch the game and play the
game based based on certain parameters
we're going to import
Maps we're gonna import race and then
we're gonna import difficulty so the
only thing I don't really talk too much
about is race so in the game there's
three different races you've got a tear
on pronounce some way Zerg and you have
Protoss and tear on appears to me to be
more like humans
Zerg is like some sort of bugs and then
Protoss is like technology slash robots
based so we're going to be playing as
Protoss seems the most fitting but there
are other races in each race has their
own kind of perks and disadvantages and
stuff like that so again just more
complexity that we need to probably
worried about way later on down the road
and then difficulty is for the bot that
we're just gonna play against just is to
have somebody to play against you can
also play against your own bot but
especially like starting off you
probably want to play against the you
know just built in box there's like an
easy a medium and a heart and then once
you can consistently beat the hard BOTS
then sure you might want to go ahead and
compete against maybe your own bot or a
variety of different BOTS then what
we're gonna do is from sc2 player we're
gonna import that bot in computer sohbat
is us like if you want to have something
that runs based on a class that you
write you use BOTS otherwise the
computer is just the computer AI so I'm
gonna start with my class sent to bots
and that's going to inherit from SC 2
dot bot a I so what is bought AI so if
you go to your installation directory
for SC 2 so just wherever your Python is
libs I packages SC 2 you'll see there's
bought AI if you go ahead and
right-click that I'll just open an idle
just because and in here you can see the
body I class and all the methods that it
has available to it you've got things
like enemies start locations so you can
pretty relatively know like especially
if it's 1v1 you guys will be at opposite
ends of the map so you'll know where the
enemy is started but if you wanted to
send some units to that location like
maybe you don't know exactly where they
are but they're probably around there
you could just tell your units to go
that way known enemy units this is just
where you know enemy units to have been
you have to have seen them but once you
know about it once you've seen them you
can go there known enemy structures same
sort of thing where have we expanded to
your available abilities expand now
which is actually a pretty useful method
I'm trying to think if there's anything
else distribute workers also one of the
more useful methods also somewhat
complicated anyway there's a bunch of
methods here that you can use but all of
these are inherited so just keep that in
mind so coming back over here oh and
while we're here I'm just gonna pop it
in two paths so just in case you did
like me install it to a different
directory the game you'll need to modify
path so in my case I changed Windows
install path to be where I put it
so just keep that in mind if you changed
it okay so we're inheriting from the sc2
bodyis so one of the things that that
has is an on step basically it's what do
you want to do every step so so when the
game actually runs its gonna check first
you're on step methods so we're gonna
define as an asynchronous method async
def on step self and iteration so every
step that we get basically what do we
want to do well the first thing that
we're gonna do is we're just going to
distribute our workers this is a method
that's already been written for us
because I just showed you this tribute
workers and all this does basically is
so you're going to start the game with
12 little workers and then you need to
tell them what to do so in the game
there's two different types of resources
there's minerals and then there's like
this gas and at least to start we're
just gonna grab the minerals and what
this is going to do is basically any
more than three workers per little
mineral patch is too many you're not
there's no benefit to having any more
than that so the idea of distribute
workers is to to intelligently
distribute them now that's fairly
complex operation but it's already been
written for us
we're just gonna use that one as just to
get us started with working with this
this API
so there's distribute workers for us
that's all we're gonna actually do with
our bot now what we want to do is
actually run the game so to do that it's
run game and then you're gonna specify
where are you running it like what map
are we gonna run on and then you give
the player list and then if you want to
you can specify the run speed basically
is it real time either true or false if
it's true it's gonna run at a regular
speed false it's gonna run ultra-fast
like as fast as it can run basically so
so you're not like wasting time like
once you get through these earlier
stages there's really no point sitting
through them so so it's better to
real-time false for now we'll keep it as
true
anyway Maps dot get and then you're just
gonna specify one of the maps I think
I've closed it I don't know if I left it
it now yeah it closed it but anyways in
your maps you've got the map name and
it's like dot SC to map or something
like that just copy and paste the map
name over so I'm gonna use abyssal reef
I'll eat so that's gonna get that map
for us and then what we're gonna do is
we're gonna specify the list of players
so first we're gonna have a bot player
the bot will be race dot Protoss and
then the actual bot itself is gonna be
sent a bot then and actually we need to
do that then what we're gonna do is
specify the next bot which is going to
be a computer player and the computer
will be race
Tehran and then it's going to be a
difficulty dot easy for now so later on
especially if we if we find that this is
like it really easy we're defeating that
bot will want to upgrade that to medium
and then we'll upgrade it to hard and
then once hard is easy we'll probably
maybe a couple hards or three other
hards and then and then maybe
incorporating our own bots into the mix
so then we'll do the real time and that
will be for now we'll equal true if
everything is the way we want it why are
you
whether okay so let's go a typo yeah I
did
difficulty isn't that not wait sorry I
got difficutly call delete okay anyway
running that so what's gonna do is go
through all your maps find the one that
you wanted to play and eventually it
will launch the game for us the other
thing you'd want to do before upgrading
your bot like if you're consistently
winning is probably changed the map try
a different map and see how well you do
so anyways right away we can see our
little workers are quick to start
collecting resources and then they a
like you would want only three per
little patch because these patches three
minerals it's kind of pointless to have
more than three workers on each path
patch rather okay so um I hate to break
it to you but you're probably not gonna
win any games by doing this so we need
to we need to have quite a few other
things like building buildings and
upgrading and building our actual army
and attacking and expanding our base
here all that stuff but hopefully at
least up to this point you're starting
to catch on to to to how this is gonna
work if you have any questions comments
concerns whatever feel free to leave
them below otherwise I will see you in
the next tutorial where things hopefully
get a little more excited than just
collecting resources okay till next time