Skip to content
my bot to the halite3 competition by Two Sigma
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore First commit Jan 6, 2019 Added 7,8 bot Jan 24, 2019

My bot to the Halite III Competition

Quick start

  1. Make sure python version = 3.6.7 is installed
  2. Download python started kit here
  3. Put the scipts of this repo under the same folder of the starter kit
  4. Modify (inside starter kit) as below and run it
# Play with different parameters, setting RANDOM_SEED so it is reproducible
a="python3 --RANDOM_SEED 1"
b="python3 --RANDOM_SEED 1 --MIN_HALITE_TO_STAY 30"
c="python3 --RANDOM_SEED 1 --MIN_HALITE_TO_STAY 40"
d="python3 --RANDOM_SEED 1 --MIN_HALITE_TO_STAY 50"

./halite --replay-directory replays/ -vvv "$a" "$b" "$c" "$d"

Final ranking


Version details

Script Rating Ranking Description 79.31 76
  • Updated make dropoff logic, will move deeper into halite dense region to make dropoff
  • Updated spawn ship logic, more conversative in 4p game 78.21 80
  • Will collide into enemy in 2p game 75.7 94
  • Added make dropoff logic (details in below sections)
  • Updated default value of MAX_SHIP_ON_MAP=200, MAX_SPAWN_SHIP_TURN=0.9
  • Ship will explore using gaussian filtered map
  • Ship will not move to cell which has enemy ship nearby while exploring 67.58 250
  • Ships with low halite do not return to shipyard at the end of game
  • Set ship status to exploit when few places >= MIN_HALITE_TO_STAY within farthest place it can go
  • Decide spawn ship or not based on expected return (i.e. if not much halite left to explore), this gives better results in a small map or 4v4 game 65.56 322
  • Implemented new exploring function (new_exploring, exploring_next_turns, get_optimize_naive_move, new_expected_value, distance_map_from_position)
  • New exploring mechanism (details under below sections)
  • Returning ship will use get_optimize_naive_move to find path with lower cost
  • Avoided blocking ship at shipyard, and will try to move around enemy ship during return
  • Stop spawning ship if cells that can be collected (>= MIN_HALITE_TO_STAY) is <= ship number
  • Updated default value of MAX_SHIP_ON_MAP=40, HALITE_DISCOUNT_RATIO=1.5, MAX_EXPECTED_HALITE_ROUND=8 57.55 627
  • Revamp safe_move_check, leverage mark_unsafe method of hlt
  • Exploring will try to move farther away from shipyard (measured by manhattan distance)
  • Improve returning (will try to move around if block by enemy's ship)
  • New function: exec_instruction, set_instruction, naive_navigate_wo_mark_unsafe, gen_random_direction_list 54.14 775
  • Refactor code
  • Ships will move based on "Expected Halite" (discounted by round).
  • Ships will return to shipyard near end of the game 44.7 1369 Based on starter code provided on halite website

Explore mechanism (implemented from

Apply logic below to ships 1 by 1

For distance d range from 0 to MAX_EXPECTED_HALITE_ROUND away from the ship:

  • Found the cell (distance = d and not occupied) with max halite
  • Calculate expected cost if move to that cell
  • Calculate expected gain if stay in that cell and collect halite, minus the cost above
  • Order the possible cells to move by expected gain (descending order)

For all possible cells from above:

  • If there exists a naive move to that cell, do it, if not, try next possible cell

Dropoff mechanism (implemented from


Collision mechanism (implemented from


You can’t perform that action at this time.