what's going on everybody and welcome to
a halite 2018 tutorial series in this
video we're going to be introducing you
to the halite competition as well as
writing a very very simple bot so if
you're not familiar with halite
basically it's just a competition where
it's like you versus one or you versus
three other players in a sort of
environment and the ideas who can write
the best AI and by AI I mean anything
from rule based AI to ml or deep
learning bots in general at least
historically the last to the winners
sure about the first one I'm pretty sure
the winners in the first highlight as
well
we're rule-based but I might actually be
wrong on that I can't remember anyways
but highlight two definitely rule-based
one so anyways what we're going to be
doing here is just do making like a
really basic pie but first I just want
to talk briefly about the rules or like
how it's done so this at least this is
like a visualization of you know again a
single game frame but basically you've
got a bunch of frames and then you start
off with just a shipyard like this green
thing here is the green player shipyard
you can create some ships these like
turtles are your ships and then you run
around and try to collect this halite
and from it you know each ship can hold
up to a thousand how light goes to the
drop-off which is either a unique
drop-off location or in this case the
shipyard you can also drop off at and
then you just kind of repeat that
process you build more ships you can get
more high light you could build more
drop-offs but ships cost and drop-offs
cost and and so on so it gets fairly
dynamic but most of this task boils down
to micro and pathing it's all about the
path so anyways I I think that's enough
for us to just kind of jump in and run
through some information now just a case
I forget to mention and at the end there
is plenty of let's see here learn
documentation here you'll also maybe go
to downloads and download the Python
version for your operating system
so yeah the Python 3 version for let's
say windows 64 boom you might
grab that and look through otherwise I'm
just gonna go ahead and jump in also one
more thing the API documentation so this
just contains information about your
game various commands that you have at
your disposal and so on but if you do
download the halite 3 I do want to just
point it out where did I put it is it
still maybe in download yeah so you
could open up my bot most of what we're
gonna run through here is gonna be very
similar at least most bots starting off
are going to look pretty identical
they're gonna have all the same kind of
start information but you can also go
into HLT which is kind of the API so to
speak for Python and you can get more
information about what's available to
you I keep going to open with because
I'm on my main computer I have sublime
that's what I use anyways and you can
kind of see here what various attributes
are you can make drop off and and like
all that stuff it's probably just a good
idea to go through here and read these
but I'm not gonna do that together with
you guys I think you can do that on your
own time so now let's go ahead and run
through some codes so I'm gonna hit this
play here and then go to the editor if
you want to develop locally you can and
probably in one of the future ones we
will definitely we do the when we get to
like ml and deep learning BOTS we'll
definitely need to do local development
because we'll have to train and stuff
locally get a model then we can eed to
be able to upload that model and at
least right now or at least last time I
looked see V 2 wasn't included so we'd
have to do some other fancy stuff to get
that working but for now we can click on
the editor and we will go with Python 3
let's see what we start with here okay
so we start with basically let's see if
I can zoom in at all without destroying
everything good enough okay so this is
just that that package that I was just
showing you if you download it locally
you can see there are various constant
values things like your how much does a
ship cost and and so on you can download
a
not downloaded but you can get the
directional basically just the
directions from HLT positional so any
ship can move either up down left or
right and these are referred to as north
south west or east so that's those and
random I think that's just to pick a
random movement in a moment logging this
is your best friend right now because
basically the entire game is gonna
happen you've got multiple players play
against each other I'm not many ships
everything's kind of happening all at
the same time so later on when things
don't go well you're gonna want to have
been using logging kind of like you
might use you know print statements or
print functions in your actual code now
it's it's gonna be a little harder to
use prints so instead we're going to use
logging and save it to a log file and
then when the game's over we can go into
that log file and make sure things are
happening the way we intended
so here the game is initialized and then
you send in your whatever name you want
for your bot now at this point it's
important to note that the two-second
per turn timer starts so you have 2000
milliseconds per turn to make all of
your your movements so again with like a
deep learning buy it might take longer
than two seconds to load in your model
so you would want to have loaded in a
model prior to game dot ready you might
also grab some certain initial game
state variables make some calculations
or whatever and maybe for whatever
reason those take longer than two
seconds you would want to do that before
you said game dot ready so here there's
just a simple example of a logging
logging string and then begins the game
loop this is just a simple wild true
loop this updates every frame you're
gonna have this every single time this
gives you some basic data about the game
what's going on this has some basic data
about the game map itself a little bit
later we'll get a little more deeper
into into how that works and stuff but
for now simple stuff command Q basically
here
as you iterate through your ships you
can only you know send your command q
one time so first you take your command
q you build you fill it with all your
command so like if you got five ships
each of those five ships could have a
certain command that it's going to do so
we send each of those ships you know one
command per ship into the command q now
here is basically they're just asking
hey if the ship position so where is the
ship so if we check the game map so the
ship position is going to be a
coordinate if that ship positions so if
those coordinates on the game map and
then we can check at those coordinates
what's the halide amount if that halide
amount is less than the max halite which
is a thousand divided by ten or if the
ship is full meaning the ship has a
thousand halite we want to move that
ship now if that's not true then we want
that ship to go ahead and just stay
still continue collecting halide so so
this is pretty basic logic now if we
want that ship to move at the moment
it's just gonna randomly move and it's
just gonna move you know north south
east her West just simply randomly no no
real logic associated with it it's just
kind of move then we come down here if
if you're in the first 200 turns and you
have enough halite spawn a ship don't
spawn a ship if you have a ship at port
because the ships will collide now if
two ships collide they both sink to the
bottom of the ocean and their halide is
just kind of released so you would want
to go like when two ships collide
chances are there's a big pile of high
light there so you'd want to go collect
it but you'd rather your chips don't
collide so okay
so with that let's go ahead and we can
just run this real quick possibly it
might have screwed some things up Liz
right yeah zoom messed it up so when we
run it here is the replay basically
you're just playing yourself in this
little replay and then you can also
click down here and
move up to 10x just so you can kind of
see how things went now you can see up
here Green has somehow 562 I'm not quite
sure how that could have occurred we
must have accidentally gone over the
depot and deposited some just by chance
you can also see here to our ships
definitely collided there okay so this
is just some like super super basic and
it's just gonna be by chance whether or
not one of these ships actually goes and
deposit it deposits some halite now when
you are ready if you've built everything
in here you can just go and hit submit
and that's totally fine and you'll
you'll basically start playing but
you'll probably want to do something a
little more complex than this before you
submit so in the next tutorial we're
going to talk about is you know doing
things like intentionally making
drop-offs and maybe moving around
slightly more logically so anyways if
you have any questions comments concerns
whatever up to this point feel free to
leave them below otherwise I'm gonna see
you guys in the next tutorial where
hopefully we we do a little better than
we have here till next time