what is going on everybody and welcome
to part 8 of the AI in Starcraft 2 with
Python tutorial series where we are now
applying deep learning and really just
finding out that we have to build data
first as we often do in tutorials so
what we're gonna be doing now is just
kind of building on the last tutorial
where we're trying to get this picture
to be a good representation of what's
going on in the game right now I hope
you're hungry because there's gonna be
some pasta so so in bad jokes to go with
it so so this is fine for the Nexus but
but we want a lot of buildings we you
know ideally we'd like to see our Nexus
or our probes or assimilators or
gateways or stargates all that stuff we
want to see all of those and then we'd
also probably like to see our workers
and our the void rays so with that I'm
gonna replace this code and again you
can go to the text-based version of this
tutorial and grab the code it's in the
description and so I think what I'll do
is I'm just gonna copy actually just
copied here okay so now I've changed
this slightly we've got the draw
dictionary which contains the objects
that we might want to draw this will be
the size of those objects basically the
diameter of the circle and then these
are the colors so we're gonna kind of
color code things because uh you know
confident in theory you could like
change these by like one value and the
content shouldn't understand it just the
same but really for yourself it's
probably useful to change them but you
could just do like full green do like
255 G and then 254 G for a different
thing in 253 for a different thing I
wouldn't recommend it but you could do
that the only other thing you probably
want to think about is maybe drawing
things in proper order
like so from largest to smallest that
way you can see things over other things
you also could throw in like some sort
of
or something but I'm not going to do
that so anyway then we just iterate over
that draw dict and for the unit as long
as that unit is ready so I talked about
in the last one as long as it's actually
produced it's like a thing that's actual
will grab the position and then we'll
draw it based on the the things so the
diameter and then the color so that's
the visualization for the rest of
everything I'm just gonna run that to
make sure that the copy and pasta worked
as intended and if that works the next
thing I'm gonna have us do is I think
we're gonna do is Scout so since we're
drawing it and just really in the game
in general it's really beneficial to be
able to see your enemy so maybe
initially you might send one of your
worker units just to their death
basically over to the enemy area just to
see you see what they're doing and then
later you can actually build like
Protoss has a scout or I'm sorry it's
called an observer and you can send over
the observer to the enemy and just kind
of float over there and see what they're
up to so so that's what we're gonna add
should this work and let me bring it up
so yeah so now you can see it's a much
more interesting result we've got you
know our Nexus is here we've got what I
believe yeah these big blues are
stargates I don't think we're actually
are we drawing I forget if we draw these
so yeah we are drawing the assimilator
oh we don't really have to import those
because we're we already imported those
you have to build them okay so great but
now we don't see the enemy either so
that's the next thing that we want to do
is we do want to draw the enemy but we
also need to scout the enemy because
just simply drawing like the enemy when
they come to our base isn't really
informative enough we want to know
what's up with the enemy what are they
doing what are they building how big is
their base how many units do they have
and we can know all this if we just send
a scout to them so that's the next thing
that we want to do so I'm gonna do
pop over here and let's add that in so
um let me I think I'll close this yes
now we want to do is close that come up
here and just like everything else we
want to add the method so I'm actually
gonna have a way self dot Scout we're
gonna do Scout as the primary objective
so now what we'll do is we'll come down
to I guess we'll just write it up here
and I think I'll copypasta this one too
well save some time we're going to knock
out a bunch of stuff I know most people
just really want to get to the deep
learning part and this is all logic that
should be legible and understandable
again this was all I don't remember but
this is a perfect example of me just
printing out the door of something so I
could see what what it do I think I was
trying to figure out how to move the
dang Scout move too so German Oh we'll
have to build this print move - yeah but
the actual move coordinates have to it
has to be it's Hannah's Paso coordinates
it's gotta be an object so we'll talk
about that in a second but that actually
was really difficult to figure out I'm
sure for the expert out there you could
have figured it out but anyway well all
our Scout method is gonna do so this is
gonna take this is because it's the
first thing called it'll take priority
over these other things you wouldn't
wanna you the Scout is like the most
important thing because the our network
is working completely off of what we can
see so the most important thing that we
can do is make sure we can see so we
want this Scout to be numero uno and
importance so so if we have an observer
which is our Scout and then don't forget
to import it so I'm just going to
observer if we have one we're just going
to rename it to be our Scout or zeroth
observer will be our Scout it should be
our only one if the Scout is idle ie
it's not doing anything first we want to
know what's the enemy's location
then we want to move to that location
but you could just do this like you
could just move to enemy location that
is a point location that can be passed
but I was really curious to get it to
like move around like so you could
hopefully discover at least the two
closest nexuses as well so if you just
go straight to the enemy start location
you're probably only gonna see the
single Nexus and I think that you kind
of want to move around to see if you
could spot the other ones too so what I
wanted to do is have some variants to
that but it turns out that's not simple
as one might hope so so what you can see
here is okay we're doing random location
variants so we need to add that method
so I'm just gonna come here again it's
all in the text-based version this
tutorial you don't need to like pause
the video and write this all out there's
a link in the description go there if I
forget to put it there let me know so
this is our random location variance
there was probably a better way to do
this this is a lot of code for what I
was trying to achieve but I this is how
I figured it out so you can do the enemy
start location which to me appears to be
point values you can reference them as
zeroeth and first death but if you just
simply return X&Y like if you tried to
return after we do this like little
modification here just a random variance
either plus xx or minus xx up to plus xx
or minus 20 if you try to return XY
doesn't work it's got to be a special
position thing so so it actually needs
to be a 2d point and I guess the game is
actually in three dimensions like you've
got this elevation so you really just
stress that it's a to a point and it's
like a position point like then XY so
rather than just return XY you got to
return this big ol thing for coordinates
but that's going to be super useful
especially if you wanted like later on
down the road to use some sort of
regression to determine the perfect
placement for like like a pylon for
example for Protoss you'd want to know
like how do I send is that perfect
position or if you want to like
structure your your attack in some sort
of formation
you're gonna need coordinates so anyways
wow that was really complicated but I
figured it out I probably spent like I
don't even even know probably like two
hours or three hours trying trying to
figure out why that wasn't working
anyways least it felt like that long so
okay so that's our scout and I think
that's everything
we just need to draw the Scout at this
point and then we have a bunch of the
enemy things so this code actually got
super long I think it looks like it cuts
them so fast so I'm gonna re paste in
the Intel and then we'll go over that
one mmm thanks for whoever it was it
said you can just hit escape in there
that's really useful so anyways we draw
all our things and then we're gonna come
down here and then we're gonna draw the
enemies stuff now because you might not
you'll be fighting a different
yeah those illegitimate I'll go over
that one because you don't know the
enemies you know you could do it like by
enemies like name or something like that
but I just wanted to keep it as simple
as possible so if it's a Nexus supply
depot or hatchery we want to draw it
with importance so so basically what
we're gonna say is if if it's not in one
of these like main base names we'll draw
it with the size of five but if it is
we're going to draw it as a 15 just like
we draw ours with a 15 and then we're
gonna iterate over the known enemy units
so that was just the known enemy
buildings and then we go over the enemy
units and again just a little workers we
want to draw those pretty small
otherwise we're gonna draw them like
size three you you could go into it and
you could draw all of them you know with
the perfect sizes and stuff I don't
think it's going to matter at the end of
the day it might matter at the end of
the day especially if your enemy is
producing like good units or really bad
units like you you might actually want
to dig a little deeper into that again
I'm just I'm just trying to see is this
even gonna work so not too worried about
it and then finally I wanted
the observer or have some sort of way to
inform the neural network where the
observer is because again if we don't
have an observer that matters if we have
an observer and like where that observer
is and there's it's like not reporting a
lot of enemy data or something like that
the position of the observer matters
like maybe it's on his way or something
like that so again we want to draw the
observer and we're drawing the observer
so small that we're just going to draw
that last so we can again the most
important thing it's on top of
everything else okay and then we draw it
now if there's oh we need to build are
we building it up here let me look here
so okay so we need to definitely build
the robotics facility so so we're gonna
go down to offensive force buildings and
add that code basically right underneath
the gateway I'm just pasting it in here
so if we have a cybernetics core and
it's ready and we have less than one
robotics facility if we can afford a
robotics facility and we're not already
building one let's build one near a
pylon so we can build it easy enough
okay and I think that should be it and
let's run this thing and see what we get
uh an error right away ah indentation
what's the deal oh don't do that to me
really is it not sure looks pretty
pretty good to me I don't know about you
guys let me do this Arzu that looks like
Oh No
wow they're all this what am I missing
it's like just that function that it's
angry about defying Reina myself
it can be the problem with copypasta
there's no reason that we need to make
that asynchronous oh that's so
frustrating I really don't know let me
just do this
Wow okay I copy and pasted it again
suddenly magically that worked what was
the problem it's loading up we'll see if
we owe it was space just one space over
I just couldn't see it I guess anyway
that was the problem okay okay I figured
we might hit an arrow that's why I let
that one continue going alright so we
need to import the robotics facility
save that one let's run that one again
again while we wait
thank you for my most recent sponsors
/members Abhinav Robert Kevin see Mike
ox long James Howard another Mike
Suzanne Williams New Castle geek and
cigar or is it so gir probably it's my
guess let me know if you're watching
we're neither of those anyways thanks
again sponsors slash members at some
point they will change the name alright
so we are building things we are still
waiting on our we can at least see an
enemy floating about there oh my gosh
hahaha position not defined
really so from SC to import we want to
also import position since we're using a
position
I forgot to refill that I almost dump
that on my face
and then hopefully if we build our
observer and it appears to observe
correctly I'll probably cut it here and
then in the next tutorial we're gonna
finish this up and work on you know
saving this data and then also the
attack method so we're gonna have to
change the attack method to currently
just choose a random of the four choices
and then once we start training a neural
network we'll use the neural network to
choose one of those there it goes our
observer it's off to a good start
well you have the neural network choose
one of those four but also if we are
victorious we need to save that data and
to my knowledge there's no really great
way to do that inside the bot class so
we'll get to that in a little bit but
anyways so we can see our observer is
just kind of floating around it looks
like he was just destroyed hopefully
we're gonna make another one we should
be popping another one out any moment
now there he is
he's huh back on his way I actually have
no idea like I wonder if there's like a
way to research like a bigger radius for
our observer and then also like how are
they spotting the observer how would we
spot their observer if they have one
that kind of thing I'd be curious anyway
so in this case we're just like totally
ignored these guys did we die or what no
also probably if we send our units to
the enemy base it probably a good idea
to to let our units draw above them so
we can see them so our network would
know oh we've got three units there
already like what are these oh is that
what our Scouts it must be what our
Scout sees but like they spotted my
scout immediately interesting
they are just destroying us we are not
gonna make it fellas all right so anyway
and that's my point I don't think that
you're gonna beat the hard AI and right
now we're not well we're making silly
decisions but later we're gonna make
even sillier decisions anyways in the
next video yeah
we're gonna work on saving that data
coming up with random choices that will
save if we are successful and then we'll
build up a big old data set and then
we'll see if using that data set
training a network is it does it tend to
beat the heart AI or no basically does
it do better than random verse heart AI
yes or no and that'll tell us whether or
not we can learn with this and if we can
how much better is it then like Rando
and then if it's significantly better
then we can start adding more and more
complexity and see what we can get away
with with our little generative are not
generative evolutionary algorithm okay
it's almost bedtime for Harrison okay so
if you've got questions comments
concerns suggestions whatever feel free
to leave them below otherwise I will see
you in the next video