what is going everybody welcome to part
12 of the artificial intelligences in
the Starcraft 2 with Python tutorial
series in the previous tutorials we
built and trained a neural network and
now we want to put it to use so in order
to do that it's not too difficult all
we're gonna do is I'm headed to part 9
and scrolling on down to the very bottom
where I post the full script and I'm
going to copy that paste so this was the
one that we use to actually build the
data now all we want to do is rather
than randomly attack use the model to
choose to attack so basically we just
want choice equals to rather than be
random be the model so not too many
changes need to be done in order for
that to happen but we do have to make
some changes so first of all we're gonna
come up to the tippity-top and we are
going to import caris then what we're
gonna do is I guess we could I think the
first thing I'll do is we'll load in the
model or so so maybe to go through
testing we want to be able to use this
model both still as random but also as
the neural network so the way that I
thought about doing that is to just have
like a flag so like in in itself after
self will have a use model and for now
I'll set the default to false let's get
rid of that space there and then what
we're gonna say is if self dot use model
so if that is the case let's go ahead
and just print out some information
using model and then self dot model
equals Karras top models dot load
underscore model and then in here you'll
put whatever model you're gonna load so
again the model the link is in part 11
you can come here and just download this
model
that's already trained feel free to
train your own if you want to try like a
different model or something like that
and see how you can do or you want to do
more epochs or whatever have at it
I hosted all the data hosted the models
do what you want so anyways this is the
name of the model so I'm gonna hopefully
highlight it copy and get lost for a
second
where oh here we go okay so so now we've
got the model itself now now what I want
to do is at least I think before we
start copypasta Inge I'm gonna at least
get the usage of the model in so we'll
come down here and then basically what
we need to do is have like an if
statement here as well so if self dot
use model then we want to you know use
the model else the choice is just take a
random action now if we want to use the
model how would we have to do that well
we would have to say something like that
it's like prediction equals self dot
model whoops
self-taught model and then you use dot
predict notation and then to pass at
least the way predict works is you pass
a an array or a list of things that you
want to be predicted so no matter what
it has to be a list so then what we're
gonna want to pass is that like flips
that flips input but one day I'll find
it oh it is already solved off flips
I can't I copy and pasted this for part
9 so I'm gonna assume I heard already
made that change that was the change I
had to make it someone I don't measure
one anyways okay so we want to predict
self dot flipped so that's actually
pretty simple but we also need to
reshape it with that whole negative one
then 176 then 200 and then the three
channels then are you kidding me
I don't actually think I mean it's a
parameter but if the parameter is a list
do you still Peppe to have information
on that anyway okay so that's our
prediction and then our choice would be
numpy da Arg max prediction prediction
in not just prediction but the zeroeth
prediction because again we have to pass
a list and then it returns you a list of
predictions then at least in the
text-based version a tutorial I did this
little thing and I really just did it
for debugging so I'm just gonna copy and
paste it in so then we just have this
little dictionary here really wonder why
the spacing looks okay in the text-based
tutorial but not here anyway
here I'm just simply outputting what the
choice happened to be the next thing is
even if so in this case it was if you
had idle void rays but the other
question is if so like we kind of want
to do this like cut here and then let's
pick that's why it wasn't that's why
it's not aligned because I did this in
the text-based territorial okay I think
this is working out right okay so so we
definitely like we don't need to be
using our GPU to make predictions if we
haven't met this if statement so I
wanted to move that down by the same
token we didn't mean need to be making
the choice before it didn't really make
logical sense like if we can't make the
choice we can't make the choice what is
happening there I don't appreciate that
so why this doesn't stay in line I don't
know okay
that was that's a lot of spaghetti going
on hopefully hopefully we're gonna be
alright okay so that should well so the
default when we run sent a bot is
actually off so what we'd want to say is
use model equals true and now we should
use the model so I'm gonna go ahead and
run that and we're gonna see that it
fails and the reason it fail let's see
why it says those Falls if use model has
no attribute if self dot use model
oh okay so so really use model with that
that's not necessarily yeah so self not
use model we're gonna set that to use
model because not only do we want to
reference it here but we want to
reference it everywhere in this object
at least right now we just have like the
one spot that we're trying to reference
that but we are referencing it outside
of this an init method - okay try again
all right the game is at least loading
up come on you can do it so at least no
last one my video and audio didn't seem
to be chopping out despite it was
lagging in OBS so hopefully that doesn't
happen here but if it does I apologize
actually our GPU should not be in use at
all until we produce void rays so while
we wait on a thank you to my recent
sponsors /members dun da Li LeBron no I
do that right Oliver Hall's ex storm 78
and Moses you guys are spectacular thank
you very much for your support so we are
still waiting
do we have our we do have a gateway
we've got our cybernetics core over here
what we got going on over here okay we
got a Stargate coming up we do have an
observer heading off on to his doing his
objective so one of the things that I
guess we can talk about now is like what
what are we kind of wanting to do in the
future
Wow we already sent okay so it's already
making choices to attack the enemy which
is interesting so I guess now I'll talk
about how this model actually did so in
my testing the trained model are we
running who are we running against here
is this harder medium okay it's just
medium here but wow we rushed and
demolished this gentleman see ya we're
not always that lucky so so in at least
with a hundred games each the random
model defeated the medium AI 44% of the
time and the trained model defeated the
medium AI 66% of the time we'll just
accept this
great thank you are we gonna hang here I
can't remember if we iterated no so so
the model definitely does better so with
this I'm pretty confident that I'm I can
spend a little more time trying to
actually make a quality AI that isn't as
bad as this one so this one has a lot of
mistakes a lot of spaghetti code going
on not to say that the next one won't
have horrible code to but but there's
like a lot of little stuff that's just
wrong here and then some stuff I've
learned over the over the course of
making this series so lots of people
have suggested like for example the the
initial Scout probably shouldn't be like
the observer it should just be like a
worker unit right that's the first thing
that you send also the way I'm doing
Scout is it like flies around apparently
you set the scout and then the radius
gets bigger so probably more what you'd
want to do is produce a scout send it to
the main base area set up shop there and
then probably go to the next to at least
resource areas and then also if you
aren't fun and then probably wait there
and then if you aren't finding if you
don't see any enemies in those first
like three locations start to look like
go to all the other resource areas
because probably where they are because
one of the like biggest issues I had is
the AI clearly is winning it's doing
really really well but it doesn't finish
off the enemy because it doesn't seek
them out it only goes to the enemy start
location so if there's no enemies there
we have to wait until the enemy builds
up again and then maybe attacks us and
then maybe we happen to find their
locate their new location but that's not
working and eventually we throw an error
or something like that and then we lose
the game but we didn't really lose the
game we should have won so stuff like
that has to be fixed
try think of what else there there's a
discord pot I forget what the discord
channel is but anyways there's the the
actual ladder for Python s where's the
sc2 AI
yeah if you go here you can go to the
discord and stuff and some of the people
have been pretty helpful in there and
one of the guys are kaya Trish I think
is the name anyways suggest two things
one is like we're just kind of like
pulling Radiesse out of thin air when
you can actually just reference the
radius of the actual object which makes
way more sense and then also he's shared
the way to actually acquire game time
like real game time which is so much
better than you know estimating
iterations per minute so stuff like that
and there's there's a bunch of other
things I've just made a huge list of all
the stuff that I'll kind of want to fix
here also we want a more complex AI we
want an AI that decides when do we build
the Scout right and then if we have a
scout the Scout just follow some rules
but when do we build Scouts should we
build a worker should we and then again
when we build workers will still use
probably distribute workers but with
when do we build a worker when should we
maybe expand so any of the any of the
choices that are made any one of the
four choices that we made prior to like
or at least in this script I think the
new average was like a 10 or 11 actions
per game and we average somewhere
between 30 and like 50 choices a game so
so you only need like whatever the thing
is wherever the action is that you might
want to take you just want to be around
11 of them per game as long as you can
have that many it's a choice that you
could probably throw in so many ways
stuff like that which you know like
building Scouts building workers
building void rays what to attack better
scouting better probably some other
attack options we might change those
around anyways there's a whole lot of
things we've got to fix here so so
anyways in the coming tutorials
probably more at least maybe the base
code will we'll probably just run
through whatever I end up coming up with
but yeah we'll see so if you have any
other suggestions about things that
you've seen that I haven't mentioned
here also supply depot this was never
the correct naming it should have been
command center I for the record I need
that
but I thought I just typed the wrong
thing anyways yeah so there was that I
think there was some other things too Oh
someone else pointed out in the scout I
think I fixed it that before this
where's our scout where's the truth okay
so no I didn't even fix this one either
I swear I fixed this but I guess I
copied it from part 9 I fixed it in my
own code but this was also problematic
enemies you know doing a random variants
of the enemy start location doesn't make
any sense you should do a random
variants of you know the game map sighs
so this never made any sense on four
we're gonna toss this anyways but there
were other errors too I just are slip in
my mind but anyways anything else you
want to improve or you think should be
done better that I haven't brought up or
if you want to kind of reiterate
something you've said before now would
be the time anyways that's it for now
questions comments concerns whatever
feel free to lay below otherwise I will
see you in another video