what's going on everybody and welcome to
part 5 of our halite 3 or highlight 2018
competition video series in this video
we're gonna be working on just kind of
continuing to build this script so right
now we've got our going out and somewhat
reasonably finding howlite and
collecting it but as we saw in the last
video everything's ending with ships
that are just full so within relatively
short order or ships get full of halite
they elect to stay still or not move
anymore they definitely don't need to be
collecting halide anymore and now it's
time that they go back to the actual
shipyard to drop off the things they've
collected so that's what we're gonna be
doing now so to do that basically
outside of the wild true loop so inside
of this this is updated every frame but
there are certain things that we're
gonna want to track even outside of that
so what I'm gonna do is say we're gonna
say ship States and this will be an
empty dictionary and then we're gonna
start iterating over our ships now if
our ship if if shipped up an ID is not
in ship states at all this is probably
because the ship was literally like just
spawned we're gonna say
ship ship States shipped ID equals
collecting so if it's just spawned
it's a collecting ship I can't imagine
any other reason why I wouldn't be in
ship States so I'm gonna assume that
that will handle things then what we
want to do is I kind of want to leave
these things in because I'm trying to
decide if I want to leave position
options not like so if we leave this in
we can always do a check as far as if
we're about to like run over somebody or
at least we can append that ships
position to make sure our other ships
don't run into them because right now I
kind of want to show a different
navigation method so if we go into here
I'm trying to think where it even comes
from is it's probably let's do
highlights positional x' maybe let me
just look for navigate I forget where
where it is a let's see it must be let's
try game map naive yeah so naive maybe
yes
now you've navigate so here they've got
this get unsafe moves and then you can
mark as unsafe and that appears to be
very similar to what I'm doing so you
may want to check out this method rather
than using what I'm doing but I'm gonna
continue I think my way but basically
what naive navigates going to do is
return either a direction or directions
still in both cases we can still collect
that position in it and both systems
should work with each other because at
some point you're gonna want something
more complicated than naive navigate and
I might maybe at some point here I'll
show you guys what I'm talking about as
far as wide I you've navigate or my
navigate is not yet good enough and what
we'll get to that
so anyways but what's nice about naive
navigate is you get your you input a
destination so it's not just like a
singular move that you're gonna make you
input where do you want your ship to end
up and then from there it attempts to
calculate how its gonna actually get
itself there so anyway so let's go back
here so yeah so after this so at this
point I'm gonna say we're gonna want to
run this stuff if if the ID is
collecting so if ship states shipped out
ID equals collecting
then let's see then we'll just run this
but in this case okay if the halide
amount so the trip will stay still for
this or ship is full I'm gonna remove
this because this is not not really what
I want I don't think so
because at some point you're basically
gonna want to say if the ship is you
know has more than some amount of
highlights so now this is the game at
like what's the highlight on the game
map there so I think I'm just going to
remove the or ship is full bit and do
this and then maybe here so then will
let's see if a light amount is less than
constants max highlight well we
definitely don't want that is that where
we had the divide yeah that's where we
have the div by 10 so believe that and
then else so if it's less than a tenth
of you know bless than 100 then it's
gonna move in which case I'm not even
sure I like that one I mean part of me
wants to just do this or even more so if
it's just collecting let's just make it
collect because it's going to collect
based on the the most wise decision to
move anyways so that should be enough so
if it's collecting do all that then what
I'm gonna want to say is if ship dot
halite amount is greater than I don't
know if we're bringing and yeah we are
bringing in constant so constants dot
max halide and then let's say divided by
three for now so this is kind of a
parameter that you're gonna want to
decide for yourself and probably it's
gonna change depending on where you are
in the game as well but if two shifts
collide into each other they both sync
and that might sound like it's an equal
battle like if your enemy collides into
you you both just lost a ship but it's
not really true so if if you're always
collecting up to a thousand halite and
your enemy only collects like 100 halite
per ship and if it's a 1v1 then it
starts being advantageous for them to
just run their ships into your ships
because you're gonna sink with a
thousand halite and they're only gonna
sink with a hundred so anyway you
probably want to always collect and fill
up your ship completely so if the ship
dot halide amount is greater than a
third of the max so greater than 333
what do we want to do well let's just
say let's do this ship dot States and
then we'll call this depositing so then
if now at this point and in fact here
this could be problematic so if let's do
this so we'll call this Elif because
obviously this is depositing and I'm
about to ask if if it's if it is
depositing so now I'm gonna say if ship
States ship that ID equal don't do that
or now we got it depositing depositing
then we want to actually go and deposit
the reason why I wanted to flip that is
you can't so here we're sending the
command Q if you send the command Q you
have you can't you can't send two
commands per ship if you do that it's
not like it's gonna take the most recent
one or something
no it's gonna error so so don't do that
so so that's why I wanted to flip these
because here we change it to depositing
and then if after that you asked this
question well you're in trouble we could
also use an outlive but I'm gonna do it
this way so anyways if ship States ship
dot ID equals depositing what do we want
to do we're going to say now the move
equals and we're gonna use that game map
naive navigate naive underscore
eight and we want to navigate the ship
to me dot shipyard underscore position
there's also like get drop-offs I don't
know I forget where get drop-offs is
drop-offs yeah okay so it's in-game map
so you can get drop-off so later if
you've added more drop-off locations and
you're not sure you know which one you
want to navigate to you can do this you
also there's ways to calculate like the
Manhattan distance to all the drop-offs
associate you know close to your ship so
you can pick the closest one and so on
so anyways but for now we just have a
shipyard so we're going to say our move
is game map now you've navigate shipyard
position so this is going to navigator
ship back to the shipyard now what
you're going to want to do is from here
we add that command Q dot up hand ship
dot move whatever that move is but we
also are going to want to so naive
navigate since we're running this first
already is going to mark certain moves
unsafe for itself so we should get away
with running this one first so but the
other thing we want to do is at least
notify our other a little system that
we've got going on here the position
choices so again we want to where its
position choices where do we do it
before oh here we go so position dict so
we'll just take this copy-paste and
instead of so directional choices
actually move in this case and then
we'll append and we do the ship move and
that should be good let's see what we
screwed up this time something for sure
we didn't make it very far so ship
States invalid syntax
what's the invalid cinta I'm just not
seeing it
okay it's that one I'm looking up here
for the :
okay save Wow look at us we made it a
good distance this time okay so now
let's go back here into replays and 741
see what we did
doesn't look like we yeah we definitely
crash into ourselves
so at no point here do we actually
collect and why is this guy that doesn't
maybe that means he's full actually Oh
they crashed into each other very nice
very nice good good work team
so in this case and they just all went
to the same spot which is kind of weird
because they definitely weren't they
shouldn't have so they're at least
they're definitely still crashing into
each other and depositing and collecting
[Music]
so the other only other thing I think I
could try is converting the like we
could rather than moving so after you've
appended the move positional choice move
here is already a naive navigate what we
could do is convert our other move to a
naive navigate possibly it might be the
case that we aren't we are unable for
whatever reason to actually access this
I'm not really sure let me try that so
ship directional choice
so directional choice is the actual
direction position dict is the
directional choice that we wanted so
what if we did ship top move game map
naive navigate ship to that coordinate
that we chose so what if every move is
the night you've navigate because
they're definitely using that mark
unsafe thing I'm just curious if that'll
solve the problem or not
let's go here
man but they still don't want to
actually go in deposit that's really
frustrating
see he's got a thousand highlights so
something is clearly wrong in my logic
depositing yeah if oh oh my gosh okay so
we had double equal that's obviously a
true/false kind of thing not a sign man
depositing so now this is not happy okay
in this case the issue was me dot
shipyard dot position not an underscore
position so running that again the game
ends and this is an example of one of
those replays so in this case now we're
just getting all jammed up at the actual
drop-off location so the only other
thing that you would need to do at this
point is once you've dropped off it's
time to move over and you know make way
for the other ships so I think what I'm
going to do is stop it here and in the
next tutorial we'll focus on doing that
and some of the other little things that
we need to do to get our ships a little
more efficient and also out of the way
here so anyways questions comments
concerns would ever feel free to leave
those below otherwise I will see you
guys in the next video