what's going on everybody and welcome to
part three of our halite 2018 slash
highlight 3 tutorial series in the
previous tutorial we covered getting the
surrounding Cardinals as well as working
locally with halite and we're going to
continue building on that and hopefully
actually getting our ships to navigate
here so let's get into it so once we
have the choices these are going to be
ship positions and when you have once
you have a position you could do now
this is gonna be kind of pseudocode e
but game map and then you would take
that position and then you can do a dot
how I amount and with that you can get
how much halite is at that exact
position it doesn't have to be a
position that surrounds your ship your
ship has access to the data because it's
all in-game map and game map updates
every single frame so anyway so that's
what we're going to wind up using now
before we start iterating over ships
basically we need to know so this gets
your surrounding Cardinals which are
your positions but then we also want to
get information on so not only do we get
those positions those positions are just
simply positions they're not like as far
as I understand it you don't actually
get like so if we just search
surrounding Cardinals what it returns to
you is the surrounding positions but I
don't believe they're relative to your
ship so later on you tell your ship to
move up down left right not move to you
know to x-coordinate right so anyways we
need to know the order that surrounding
Cardinals are given to us so looking
here it returns the directional offset
for current location in Direction get
all Cardinals so now we need get all
Cardinals which is here and it returns
in this very specific order north south
east west so now we know basically the
actual movements associated so these
Direction movements are also a part of
positional z' and they correspond to
exactly
what you are going to pass to your ship
so north to get your ship to move north
it's actually move nothing in your
x-coordinates and move negative one or
up in your y-coordinate south the
opposite of that and so on and that's we
need to that's the thing that we passed
our ship at the very end to actually get
it to move but before we move we need to
get the actual when we get the
surrounding coordinates those are not
nor you know north south east west it's
not mapped to that anyway
that might sound really confusing let's
just write out the code so so the first
thing we want to do is we're gonna do
Direction underscore word and that is
going to just be what I just copied so
so I didn't need to add the list I
already had it so it's gonna be north
south east west now the only thing that
I'm gonna add is a final one which is
Direction dot still and let me make sure
yeah we did in port direction to make
sure we had it because that's gonna be
the final thing so this is the order
that we're we already we're gonna
collect highlight now for the north
position the south position the east
position the west position or don't move
position okay so once we have that we've
got choices now your choices are going
to be I'm gonna change this to position
options and that's going to be ship dot
position get surrounding Cardinals plus
the current ship dot position so all of
the positional choices that we might
make are the surrounding positions plus
or current ship position because many
times you don't actually want to have to
move your ship sometimes you might
actually want your ship to hold still if
you're on enough halite you should you
should stay on that highlight and click
as much as you can until you think it's
a wise decision to move off so then I'm
gonna make a position Dick's right now
that's going to be empty and then I'm
gonna make a halite dict and basically
the position dict is going to contain
the movement mapped to the actual
coordinate so for an example
here would be let's say the movement is
0-1 that's going to be mapped to a
natural physical coordinate on the game
map like 1938 or something something
like that
so we'll have one for each of the five
choices move up down left right or stay
still
that's that's the position date now the
highlight dict is going to be the actual
movement zero one let's say associated
with how much highlight so five hundred
for example so those are those what
we're planning to pass into those two
dictionaries now what we want to do is
populate those two dictionaries so I'm
just going to come down here and say for
n in direction in enumerate Direction
order we're gonna say position dict
for that direction is equal to position
options n so this maps this you know
fills out that positional indict and
then now we want to actually fill out
the the halite dict itself as well so
now what we're gonna say is for
direction in position dict we're gonna
say the actual position itself is just
you know position position dict for that
direction so that gives us the position
itself now we want to know how much
halite is located at that position so
we're gonna say highlight amount that
makes me nervous
I just for some reason that was
predefined I'm not really sure why
halide amount was pre to like a thing
that we've used already oh maybe it's
this dot halide amount makes sense okay
anyway palette amount is equal to game
map at that position dot halite amount
that's a typo position
so now we have the halide amount and
then now we're ready to actually
populate the halide dict so now we say
halide dict for the position equals how
i amount okay so then the final thing
that we want to do is we actually want
to be able to choose which of you know
which movement should we go with well
the movement that we want to go with is
whatever key has the highest value so to
get the key for the highest value it
would be max for halide dicts where the
key well basically this is the max of
halide dict in the max that we're
looking for is how light dicts gets so
we're curious what the highest because
halide dict if you were to iterate over
halide dict
that would be the keys but in this case
key is in reference to the thing that
we're going to get the max of and that
is the value the actual value from that
halide icked based on each key as you
iterate over it so now rather than a
random dot choice move all we want to do
is ship top move and we want to do a
ship 'don't move
and the the halide dict itself these are
the movements that you would actually
pass to your ship you have to pass a
tuple that is 0 1 is 0 negative 1
negative 1 0 or 1 0 so all we have to do
is pass exactly what I just wrote so
this really let's just cut this paste
and that's it so now if the let's see so
if the ship is full it's gonna hold
still that's fine eventually our ships
are gonna probably stop moving but well
we'll work on that in a little bit we
don't need to log that anymore so let's
go ahead and save that and let's run
that and make sure that we're not
hitting some other issue
so run the game again a really quick
finish there hopefully we're not having
tab issue again that would be annoying
so let's go ahead and open this let's
edit this I guess the game is just
simply ending last input received syntax
error so we've got some sort of else
issue going on here if game map else
what would be the issue here I'm
assuming we don't have any replays
did we may be okay community so this is
not fully closed off I deleted too many
things I'm guessing that's probably the
extent of the issue let's try this again
now still still giving me this man may
be a typo now direction
and go back here
I don't know if this is just getting
truncated or what direction direction
direction maybe still might be a casing
issue there let's save that again and
just so it's clear this is you know
these you know correspond to north south
east west but then we also want to get
you know we want to add ship top
position for hold still okay let's run
this one more time are you are you
serious with me right now
okay I just made another typo position
okay
70th times no 70th time's the charm is
not going to work on hashable type
position
hmm not seeing it immediately let's see
how I dict position equals mouth
I'm not sure why that would be giving me
a hard time I'm not seeing it clearly
let's see hell I did
oh let's see so how I Dix I'm not sure
why that's airing but we actually want
that to be highlight dict
equals halide amount that was way too
complicated okay let's see so let's go
to the replays pull this up and let me
throw the most recent one in which would
be 256 so we see we've made some BOTS
part of the issue is they quickly they
just run into each other because they
all see like the the most highlight from
the same position basically and these
guys are probably full now wouldn't my
guess usually you can get let's see yeah
so these ships are full with halide so
anyways so the next thing is we need to
get these ships to actually start
navigating back to the action you know
the actual Depot or drop-off location so
these are actually shipyards and then
for some reason I started calling them
depots and I have no idea where I got
that terminology from but they're called
drop offs and shipyards but I'm gonna
call Depot's probably a lot and I'm not
sure why but anyways we need to turn
these ships around and get them back to
drop off and then come back out to
collect more highlights so that's what
we're gonna be focusing on in the coming
videos hopefully my errors weren't too
annoying for you but I I'm gonna leave
them in I'm not gonna edit those about
because you're gonna find that you've
got to do a lot of debugging and this is
not the easiest way to do the debugging
it won't be a way that you're used to
so because you can't just run this
script straight you've got to get the
debugging error either from the console
and then sometimes later on from here
although the main error that I tend to
get here is a timeout so if something's
happening and you don't know why and you
didn't get an error in the console you
didn't get anything in your logs that
would suggest what the air is you go
into replays and read the error log and
there you'll probably see that you timed
out but maybe something else
anyway so I'm actually gonna leave those
in because some of those were errors
that you'll probably come across you
know maybe not the exact ones but you'll
come across errors like that and have to
debug them so anyway that's all for now
if you've got questions comments
concerns whatever feel free to leave
them below otherwise I will see you guys
in the next video where we one fix ships
heading towards the same spot but also
two we're gonna start working on sending
them back and actually dropping off
their highlight both of equal importance
we don't want to beat our ships to be
sinking but we also need to return our
you know drop off the highlights so
that's we're going to be doing the next
tutorials I will see you there