diff --git a/website/advanced_command_line.php b/website/advanced_command_line.php deleted file mode 100644 index 36eef4278..000000000 --- a/website/advanced_command_line.php +++ /dev/null @@ -1,62 +0,0 @@ - -
- - -The Halite environment is responsible for running games between bots and outputting appropriate data and files upon the end of a game. The downloadable version is the same version used on the servers.
- -- It may be passed a number of flags, including: -
-d: allows the automatic input of the dimensions of the map. The following argument is expected to be a string containing the width and height (space-separated).-t: disables timeouts for the duration of the game.-q: turns on quiet output. Output will take the form of:
- n players in the game, n lines like so: playerID rank lastFrameAlive-s: provides the seed to the map generator. If this is not provided, it will use a time-based seed.To run your bot against itself on a 40 by 40 map with no timeouts, run: -
./halite -d “40 40” -t “python3 MyBot.py” “python3 MyBot.py”.\halite.exe -d “40 40” -t “python3 MyBot.py” “python3 MyBot.py”To run your python bot against a java bot (assuming it’s been compiled) on a 25 by 25 map with a predefined seed (2168), run: -
./halite -d “25 25” -s 2168 “python3 PythonBot.py” “java JavaBot”.\halite.exe -d “25 25” -s 2168 “python3 PythonBot.py” “java JavaBot”All compilation and game execution is done on AWS EC2 m3.medium servers running Ubuntu 16.04. They have the following specs: -
During compilation and games, players are run as unprivileged users in a sandbox which limits memory, processing power, execution time, disk space, and internet access. The sandbox is a docker container defined by this Dockerfile, running on top of Docker 1.6.2. If you think that there is an issue with the sandbox, please email us at halite@halite.io. - -
Bot compilation is done using this autocompile script.
-To facilitate the installation of custom software, we allow users to include an install script. If a file named install.sh exists in your submission, it is run as a bash script under the root user in a sandbox with internet access and 10 minutes of runtime. Bots may only read and write to their current directory, so all files that you want to be available at runtime must be installed locally. For more on using 3rd party libraries, click here.
- Your main file must be called MyBot. Your language is recognized using the file extension of your MyBot file. The appropriate file extensions for each language are:
-
- The following compilers are used: -
- The following build automators are used: -
- The following versions of each language are supported: -
Bots are given 250 MB of RAM and equal amounts of CPU.
-Currently, 20x20, 25x25, 30x30, 35x35, 40x40, 45x45, and 50x50 games are run. Games may be 2-6 player.
-Games are always run using the most recent environment build.
- -A Halite replay file is a JSON object which describes what occurred during the game. Halite replay files are easy to parse and reasonably compact (and extremely compact when compressed), making them ideal for both using machine learning on Halite as well as sharing interesting games. The extension .hlt is used to distinguish Halite replay files.
- -A Halite replay file contains only a single JSON object. This object has the following attributes: -
version - Describes the version of the replay file. The present version is 11, which is expected to be stable for a while.width - A positive integer representing the width of the map.height - A positive integer representing the height of the map.num_players - A positive integer of at least 2 representing the number of players taking part in the game.num_frames - The number of frames encoded in this replay.player_names - An array of strings which correspond to the names of the players, starting with the player with tag 1 and ending with the player with tag num_players.productions - A 2D array of integers which represent the productions of the tiles on the map. These integers fill in the map from row 1 (i.e. the top) to row height and within a row from column 1 to column width and are all guaranteed to be positive and less than 255.
- frames - A 4D arrays of integers. This is the most complex piece of the file specification, so here it is step by step:
- num_frames, and it contains individual frames.height, and it contains individual rows of the frame. The first element is the first (top) row and the last is the bottom row.width, and it contains individual sites of the frame. The first element is the first (leftmost) column and the last is the rightmost row.moves - A 3D arrays of integers. The outermost array has length num_frames - 1 and contains the moves for an individual frame. Each element is a 2D array of integers which represent the directions chosen to move for every site on the map. As always, the outer layer of the 2D array fills in the rows from top to bottom and the inside layer fills in individual rows from left to right. The integer values for each site are: STILL = 0, NORTH = 1, EAST = 2, SOUTH = 3, and WEST = 4. Sites not owned by any player are assigned the value of 0.Please try to generally adhere to the API used in the Java, Python, and C++. This is as follows: -
Of course, if changes to this API will make the starter package fit more nicely into your language, feel free to make them. A Java API will not translate directly into Lisp nicely.
- -Bots communicate with the environment via stdin and stdout using series of space separated integers. There are two stages of communication - initialization and turn formats, and these are detailed below.
- -At the beginning of the game, bot is sent the following, with each item newline-terminated: -
WIDTH and HEIGHT of the map.Every bot is expected to respond with a string representing their name (newline-terminated) within fifteen seconds.
- -Every turn, every bot is sent the the present game map (newline-terminated). Every bot is expected to respond with a set of moves (newline-terminated) within one second.
- -The state of the map (including owner and strength values, but excluding production values) is sent in the following way: -
COUNTER, representing the number of tiles with the same owner consecutively.OWNER, representing the owner of the tiles COUNTER encodes.The above repeats until the COUNTER total is equal to the area of the map. It fills in the map from row 1 to row HEIGHT and within a row from column 1 to column WIDTH. Please be aware that the top row is the first row, as Halite uses screen-type coordinates.
This is then followed by WIDTH * HEIGHT integers, representing the strength values of the tiles in the map. It fills in the map in the same way owner values fill in the map.
Consider the following 3x3 map as an example (where [O=x,S=y] represents a tile owned by player x with strength y):
[O=0,S=122] [O=1,S=25] [O=1,S=18]
-[O=0, S=13] [O=0,S=45] [O=1,S=22]
-[O=2,S=255] [O=2,S=85] [O=0, S=0]
- This map would be encoded using the following string: -
1 0 2 1 2 0 1 1 2 2 1 0 122 25 18 13 45 22 255 85 0
-
- The production values of the map are sent using WIDTH * HEIGHT integers which fill in the production values of the map from row 1 to row HEIGHT and within a row from column 1 to column WIDTH
-Consider the following 3x3 production map as an example (where [x] represents a tile with x production):
[2][3][4]
-[1][2][3]
-[0][1][2]
- This map would be encoded using the following string:
-
2 3 4 1 2 3 0 1 2
-
- Bots should send their moves as a list of integers in sets of 3. In each set, every first integer is the x location (starting at 0) of the site the bot desires to move, every second integer is the y location (starting at 0) of the site the bot desires to move, and every third integer is the direction the bot wishes to move the site in. The order of the sets does not matter.
- -Valid directions include: -
Please note that these directions correspond most directly to screen coordinates; that is, NORTH decrements the y value of the site by 1 and SOUTH increments the value by 1. Attempts to move nonexistent or enemy pieces or to move pieces in nonexistent directions will be ignored. If multiple separate moves are issued for the same piece, the lower direction value will be preferred.
-Consider the following case as an example:
I wish to order a piece located at (3, 4) to move EAST, a piece located at (4, 0) to remain STILL, and a piece located at (4, 5) to move NORTH.
This would be encoded with the following string:
3 4 2 4 0 0 4 5 1
-
- Note: if you would like an alternate way of communicating with the environment, please see a future post on the forums for how to communicate with the environment over sockets instead of pipes if you need to use a debugger or similar to work on your bot.
- -Fork our repo, place your starter package in the airesources/ folder, and send us a pull request! If we accept your PR, your starter package will be added to the site.
Note: please include the runGame.sh and runGame.bat scripts (each run a 30 by 30 game between MyBot and RandomBot) and the MyBot and RandomBot files (both just random bots).
Halite (the game) is a multiplayer turn-based strategy game played on a rectangular grid; the objective of the game is to take over the entire grid and eliminate the other players in the game.
Halite (the tournament) is an online programming competition where human coders write bots that play the Halite game against each other.
The Halite game was created by Benjamin Spector and Michael Truell during a summer internship at Two Sigma in 2016.
The game format is inspired by the 2011 Ants AI Challenge sponsored by Google.
Halite’s creators heard about the Ants AI Challenge a few years too late :-(
They couldn’t find any other competitions quite like it, so they decided to create one.
The goal of Halite is to provide a fun and deep testbed to try new ideas and compete in problem-solving. Furthermore, Halite is being used for recruitment of talent by its sponsors.
- -The Halite game has been designed and implemented by Two Sigma, a highly-innovative, technological investment firm based in New York City.
The Halite tournament is jointly run with Cornell Tech, a new graduate school that brings together faculty, business leaders, tech entrepreneurs, and students in a catalytic environment to produce visionary results grounded in significant needs that will reinvent the way we live in the digital age.
The tournament will run from November 2, 2016 to February 2, 2017.
- -Rankings are based on the outcome of organized games where bots play against each other. A good analogy is the Elo rating system used for chess.
More precisely, rankings are computed using a Bayesian algorithm variant of the Glicko system, specifically using the TrueSkill Python library available here.
Winners are simply the highest ranked players on the leaderboard at the end of the competition. So, submit early and often!
- -Pride! Bragging rights! Internet royalty!
The results of the competition will be officially announced with a link to best players Github profiles.
We store the email, username, and unique identifier that Github provides when you login to the halite.io website via Github OAuth.
- -We check to see if the domain of the email associated with your Github account is on our whitelist.
-Is your organization not on there? Edit the whitelist and send us a pull request! We'll make sure to tag all members of your organization who have already signed up.
- -Yes. Halite is a programming competition. You need to program a bot that will play the game in the Halite tournament.
However, you definitely don’t have to be a very good programmer to play Halite effectively. Success is more about coming up with a good strategy to play the game than coding this strategy expertly.
Any and all! If the language can read from stdin and print to stdout, we can support it.
We provide out-of-the-box starter packages for the following languages: Python, Java and C++. See here for our growing list of starter packages.
We’re counting on the community to add support for as many languages as people want. Visit this page for more information on writing your own starter package and the protocol used by the game environment to talk to your bot.
-
-
To submit your bot, you'll first need to zip your source code. Then, after signing in, click the "Submit" button on the top-right part of the page. Then, simply select your zipped source code to submit.
- -Yes.
Check out our Github repo and you are also welcome (even encouraged) to open issues and/or submit pull requests.
You can open an issue or submit a pull request on our Github Repo. If you are looking for things to do, checkout our open issues.
- -Please check/post on the Halite forums or contact-us at halite@halite.io. - -
In this tutorial, we'll go through the code that powers the random bot and add a couple heuristics to it. This will hopefully help you fully understand Halite and set you on your way to leaderboard domination.
- -The code in this tutorial can be found at the following links for Python, Java, and C++.
-Make sure that you have read Introducing Halite and followed the setup procedures described there.
-Now open up the MyBot file in your favorite editor and let's get started!
- -When writing a halite bot, be sure to stay away from functions like System.out.print, cout, print, etc. Bots use stdout and stdin to communicate with the game environment. You will be ejected from a game of Halite if you print debugging info to stdout. Instead, print to a log file.
Now that you know how the game works, how do the two random starter bots work? How does one code a Halite bot? Here is the source from the main file of our python starter bot:
- -Let's walk through it line by line.
- -First we import a couple of helper files that are included in the starter packages:
- - - -Then we get our ID (each player has a unique identifier that is associated with their pieces) and the game initial map from the environment.
-We send back the name of our bot. This is used in game replays.
- - - -Now we start our game loop. Each frame let's initialize a list of moves and get the current map:
- - -Let's cycle through all of the pieces on the map. If a piece is owned by us, let's order it to move in a random direction.
- - - -Finally, let's send all of our moves to the environment:
- - - -And that's random bot!
- -From the rules outlined in Introducing Halite, we know that when a piece moves, it gains no strength and leaves behind a piece with zero strength. It easily follows from this that moving zero strength pieces is a terrible idea, since:
-Let's wrap the movement logic inside a function of its own. This function will take the location of a piece and will return the piece's movement.
-Now we can improve our bot by making sure that we tell all of our zero strength pieces to remain still.
- - -Our bot still moves its pieces around a lot (only a bit over one out of five turns will a piece stay still). This costs us a lot of strength (since a piece doesn't gain any strength on turns that it moves). To increase our utilization of our production, let's have pieces only move once their strength equals their production times some factor X. We're using 5 as the value of X in this example, but this is arbitrary.
- - -When building a Halite bot, one of our goals should be moving strength out of your territory quickly and with little production loss. Our current bot is terrible at this. Its pieces move randomly around our territory, going nowhere, costing us production, and often losing strength to the strength cap.
-To improve this, let's just mandate that our pieces move only north and west. Since the map is wrap-around, we can still capture all of the board with this strategy!
- - -Once our pieces get to our borders, we don't want them to randomly attack just any square (or worse, move back into our territory), as we do now. One problem with this random strategy is that we may attack a map square that has more strength than us. This is unproductive (pun implied) since moving onto the map square costs us a turn of production and we don't actually gain anything. We just diminish the squares strength.
-To improve on our current combat, if there is an enemy or map square that is adjacent to one of our pieces with less strength than our piece, let's take it.
- - -That's really up to you! How you improve your bot from here is where you step into the competition.
-That said, if you're looking for more ideas or a stronger starting base, nmalaguti wrote a tutorial here that we highly recommend.
-Good luck!
- -In the last tutorial, we showed how to submit a demo bot to the leaderboard. In this short tutorial, we will go over the files included in a starter package, running a game of halite, and the rules of halite.
-Your starter package should contain these files.
- -| Filename | Description |
|---|---|
| MyBot | Your main file. Starts containing the code for a random bot. |
| RandomBot | A random bot to test changes to your bot against. |
| runGame.sh | Script to run a game on Linux/macOS |
| runGame.bat | Script to run a game on Windows. Assumes halite.exe is in the same folder. |
The file you need to change is MyBot. Regardless of what you do with your code, MyBot will be considered your main file on our game servers.
- -To play games of Halite locally, you will need the game environment. As of this writing we support Windows, Linux and OSX platforms. You can download the game environment here. Place the downloaded binary (halite or halite.exe) in your starter kit folder.
-To simulate a game, simply runGame.sh (Linux and macOS) or runGame.bat (Windows). This command will run a game between my MyBot and RandomBot (both are just copies of each other at this point) on a grid of size 30x30.
-The output should look like this and the details of the game will be stored in a file with the "hlt" extension (35538-124984302.hlt in the example below).
- -$ . runGame.sh
-python3 MyBot.py
-python3 RandomBot.py
-Init Message sent to player 2.
-Init Message sent to player 1.
-Init Message received from player 1, MyPythonBot.
-Init Message received from player 2, RandomPythonBot.
-Turn 1
-Turn 2
-Turn 3
-Turn 4
-…
-Turn 299
-Turn 300
-Map seed was 124984302
-Opening a file at 35538-124984302.hlt
-Player #1, MyPythonBot, came in rank #1!
-Player #2, RandomPythonBot, came in rank #2!
-
-
- The console output from the game environment gives just the outcome of the game. To replay the game, drag and drop the file to the visualizer to get a visualization like this one:
-
What do all of these pretty squares mean?
-Halite is played on a rectangular grid. Players own pieces on this grid. Some pieces are unowned and so belong to the map until claimed by players. Each piece has a strength value associated with it.
-At each turn, bots decide how to move the pieces they own. Valid moves are: STILL, NORTH, EAST, SOUTH, WEST. When a piece remains STILL, its strength is increased by the production value of the site it is on. When a piece moves, it leaves behind a piece with the same owner and a strength of zero.
-When two or more pieces from the same player try to occupy the same site, the resultant piece gets the sum of their strengths (this strength is capped at 255).
-When pieces with different owners move onto the same site or cardinally adjacent sites, the pieces are forced to fight, and each piece loses strength equal to the strength of its opponent. When a player's piece moves onto an unowned site, that piece and the unowned piece fight, and each piece loses strength equal to the strength of its opponent.
-When a piece loses all of its strength, it dies and is removed from the grid.
- -Move on to Improving the Random Bot.
-In this short tutorial, we will explain how to submit your first bot and get your name on the Halite leaderboard.
- -You will need a Github account in order to participate in the Halite tournament. If you don't have a Github account, please create a new account here. Sign up for Halite by clicking "Login with Github" at the top right of this page.
- -Download a starter package for your language of choice from the downloads page.
- -Each starter package consists of a zip file that includes: (a) one code template for your your first bot (the MyBot file), (b) one code sample for a random bot (the RandomBot file), (c) some support libraries for the bot and (d) some tools to test your bot locally.
- -To get on the leaderboard, you need to submit a bot to the Halite tournament.
-Click the "Submit" button in the navigation bar. In general, you need to package your submission as a zip file that contains everything needed to run your bot (your bot’s source code, starter package source files, supplemental libraries, etc.). For your first submission, you can simply upload the zipped starter package that you just downloaded. You will receive an email notification that your submission has been received.
-The Halite servers will compile the source code of your submission and continuously play your bot against other contestants, which will generate your leaderboard ranking. If the compilation of your source code fails, we will email you.
-To track your bot's progress, navigate to your homepage.
- -Congratulations. You are now an official contestant!
-It may be up to 10 minutes before your bot has played a few games. In the meantime, move onto Introducing Halite.
- -Please post on the forums. For more unstructured conversations, join our discord.
-In this guide, we will detail a couple of useful practices to follow when building your Halite bot.
-Stdout and stdin in are used to communicate with the game environment. As such, you cannot use functions like System.out.println, print(), or std::cout. Instead, print debugging information to a log file.
-Before submitting a new bot to the online leaderboard, we recommend running some games against the version of your bot that is currently on the leaderboard. If your new bot consistently wins, then put it up!
-When debugging latency issues with your bot, it can be helpful to disable game environment timeouts. To do so, append the -t flag to your environment command (e.g. ./environment -d "30 30" "python3 MyBot.py" "python3 RandomBot.py" -t).
-When your bot times out or errors on our game servers, we save and display a log file with debugging information including the time your bot took each turn, its output each turn, and its final output from stdout and stderr.
-To find these log files, visit your homepage: https://halite.io/user.php. Just click the download log button to grab your error log for a game:
-There is a community contributed method for running a Halite bot from a custom debugger locally. More on this can be found here on the forums.
-If you add a bash file named install.sh to the same directory as your bot source, it will be run with internet access and write access to its current directory before any bot compilation. It may run for a maximum of 10 minutes.
- -You must install all libraries locally, even if through a package manager. Because of this, package managers that only support global installation (such as apt-get) may not be used.
-The following package managers are installed ahead of time on the Halite game servers:
-- If you would like us to add another package manager to this list, post on the forums. -
- -Here is an example install.sh file for a bot that uses the numpy library:
- -It's just one line!
- -If your library isn't on a package manager that supports local installation, you are going to have to compile it on our game servers. Include the source of you library in your bot's zip file and put compilation instructions in the install.sh file.
-In this short tutorial, we describe how to evaluate the position of player during a game, how to think about combat and remind the reader of a few subtleties of the game.
- -Just like for other board games like Chess or Go, not all Halite positions (i.e. the game state) are equally valuable. For a given player, there are 3 components which are most important in defining the quality of their position. These are: -
Territory is the measure of how close a player is to winning the game, since the goal of the game is to capture the full grid.
The ultimate goal of a player should be focused on maximizing its own territory and minimizing the territory of other players.
Simply controlling a lot of territory is not enough to give a player a high degree of certainty of winning, as the other characteristics (production and strength) can be just as influential in determining the outcome of a game, but controlling territory can also provide subtle advantages to a player which will be outlined later.
Production is the measure of a player's capacity to produce new strength.
It tends to determine the long-term outcome of a player's position, as a player with a high total production can often just wear down other players in a war of attrition and then take their territory once their strength is reduced to zero.
Strength is the measure of a player's capacity to immediately capture new territory.
It tends to determine the short-term outcome of a player's position, as a player with a high total strength can immediately attack and take new territory.
Players should note that the placement of this strength is relevant; strength in the center of a player's territory cannot be utilized nearly as quickly as strength near the border.
In Halite, a single piece can deal damage to as many as 4 other pieces simultaneously, this means that it can output up to 4 times its own strength in damage. This single principle (we call it `overkill`) is at the core of Halite tactics.
- -This is a short (and far from complete) list of some less-important but still valuable characteristics of the game to be aware of when playing Halite. -