what's going on everybody and welcome to
part 4 of the halite 2018 or highlight 3
tutorial series leading up to this point
we at least got our ships to begin to
navigate to something a little more
reasonable than random and we've noticed
we have two major issues one is ships
never go and actually deposit their the
collected halite and two they tend to go
to the exact same position crashing into
each other and sinking to the bottom of
the ocean so we kind of want to start
working on those two things now and I
think the first thing is we need to stop
losing ships so we're going to we're
going to stop our ships hopefully from
crashing into each other now there's a
few ways that we can do this the first
way that I'm gonna try is just as we
iterate over ships first of all we
should always know where all of our
ships are as well as where they intend
to be and if there's any conflicts we
should maybe pick a different direction
so so the first thing that I want to add
here is right before we start iterating
over the ships we're just gonna say
position choices cuz our biggest issue
is gonna be when two ships opt to move
to the exact same position now if you
recall though we don't actually move
ships until the very end when we've
appended everything to the command Hugh
so position choices will not contain
like 0 1 or 1 0 and so on instead
position choices is actually going to
contain the physical coordinate on the
actual map itself so with that we've got
position choices basically now what we
want to do is before we actually append
the command that we want to move so now
we're moving at this like max halite
dict instead what we want to do is let
me just cut that out and I think really
what I'm gonna do is if ship I think I'm
gonna put trying to decide if I want to
put the movement here that price
shouldn't matter too much
maybe I'll put it over here so anyway
it's just it doesn't matter that much
we're gonna say directional choice or
really even better put mm yeah yeah
we'll go with the rational choice and
then that'll be equal to max why did
that oh how much made the same mistake I
made before so ship move close that off
so that's the directional choice that we
want to make but that's not the actual
coordinate choice that we want to make
so directional choice what we're going
to do is we're going to say position
choices dot append and then we want to
append the position dict
of that directional choice so position
dict directional choice so if we go back
to the position dict that is on a per
ship basis it Maps the actual movement
you want to make to the actual
coordinate you'll wind up at so now we
have the coordinates of the ships or at
least the coordinate for this specific
ship where is it going to be headed now
we know so so let me just where was that
okay here position directional choice so
then now the ship just wants to move
that directional choice so at that point
we have we now at least know the
coordinates that that ship is going to
go go to but of course all we do is all
we have right now is we just know where
those coordinates are we don't actually
we're not doing anything with them so
the next thing we want to do is do
something with them well the way we make
our decision is based on the maximum
halite value in that halide dict and
that halide icked is based on the move
so instead what we probably would want
to do is when we start iterating over
the direction in that position dict we
probably let's just like not populate
the halide dict if it's a conflicting
coordinate so what we should say now is
before we actually append
we want to make sure that if position if
position dict
for the direction that it's thinking of
you know storing hay at these
coordinates this is how much highlight
we have so if position direction is not
in already made position choices
position choices so position take
Direction maps to coordinates so if that
direction is not or if those coordinates
are not already being planned to be
headed towards then let's go ahead and
say okay well store that to the position
choices otherwise we obviously don't
wanna make that move now that won't help
us if a ship is going to stay still and
continue to collect halite especially if
we've our it's by per turn so we would
still need to also collect current ship
positions and then probably change those
as well but this should help quite a bit
so only time we're gonna add that is if
no other ship is planning to head to
that exact same point okay so let's go
ahead and save that and see how many
errors I've hit for myself this time
what if it just ran that would be great
wouldn't it I want to make sure we
didn't hit any errors let's see where in
fact what we could do is let's just
delete all these and then I can just run
it here that's still open game has ended
it looks like that was like a legitimate
ending let's just watch real quick let's
pull up the replay
so they're still definitely running into
each other curious what would they run
into each other get surrounding
Cardinals it
because before we actually navigate to
that spot let me just do this
do we not append possibly to the know we
definitely appended it position choices
so if let's do this else
logging info attempted attempting to
move to same spot date I don't have my
lot of attempting to move the same spot
let's save that yeah let me just run
this again
I don't want to do it there I want to
come into here zero so there it staying
still and I think our issue is I think
they're opting to stay still okay so
let's see so position dick directional
choice so what we need to do is we need
to handle for if the ship opts to not
move
so if holly or
because I think with staying still let's
try this real quick let me do this this
and then this would be the directional
choice would be Direction diet still if
I recall right yes so let's go ahead and
append that it's still over so quickly
so watch our replay if you guys go to
the same spot I'm gonna be so angry with
you guys okay I it search seemed like it
went really quick but maybe it just
processed really quickly faster I wish
this one would go to 10x as well are we
so we paused for some reason second when
we stopped or are we actually stopped
okay they just stopped here for some
reason that's curious
oh they got full that's the issue okay
so I guess that's why it went so fast it
just didn't actually have to do anything
okay great so so at this point we have
we at least are to the point where we're
collecting everything now what we have
to do is code the logic that's gonna be
required to go back and deposit
everything so at some point probably not
even at this point you know before your
ship is full you probably want to start
making the trek to go back and deposit
or drop off the hell that you've
collected so in the next tutorial that's
what we're gonna do and in order to do
that we need to start tracking like some
state and stuff like that for the ship
so the ship kind of stays on its
whatever its task is to do whether it's
you know go out and collect some more or
find the closest place to drop off so
that is what we're gonna be doing in the
next video if you've got questions
comments concerns whatever feel free to
leave those below otherwise I will see
you all in the next video