|
| 1 | +## <a name="game_rules"></a> Game rules |
| 2 | + |
| 3 | +While Halite has some very simple rules, they interact in complicated ways allowing for very rich gameplay. You should re-read this section frequently as you think about ways to improve your bot. |
| 4 | + |
| 5 | +<div id="gameReplay" class="text-center"></div> |
| 6 | + |
| 7 | +### The Map |
| 8 | + |
| 9 | +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. The origin of the map (the point at coordinates (0, 0)) is the north west (top left) corner of the map. |
| 10 | + |
| 11 | +Maps are randomly generated at the start of each game. The generator does the following: |
| 12 | +1. Tries to match the given width and height as closely as it can while still creating a symmetric map. Maps are guaranteed to be the given size or smaller in each dimension; never larger. |
| 13 | +2. Tries to create interesting maps in which there are patches of high production squares and patches of low production squares, with fairly low noise on the small scale. |
| 14 | +3. Always creates symmetric maps. Specifically, the generator generates a chunk of the map and then tessellates, reflects, and shifts it to produce the entire map. |
| 15 | + |
| 16 | +Each piece has a **strength** value associated with it. Each square on the grid has a **production** value. |
| 17 | + |
| 18 | +The map wraps around on the sides and top and bottom. If a piece moves WEST off the left side of the map, it will appear on the right side of the map (like Pacman) in the same row. Same for the top and bottom. |
| 19 | + |
| 20 | +Each match will have 2 - 6 players spread throughout the map. Map sizes generated by the server are 20x20, 25x25, 30x30, 35x35, 40x40, 45x45, and 50x50. |
| 21 | + |
| 22 | +### Making Moves |
| 23 | + |
| 24 | +At each turn, bots decide how to move the pieces they own. Valid moves are STILL, NORTH, EAST, SOUTH, and WEST. When a piece moves, it leaves behind a piece with the same owner and a strength of zero, expanding the player’s territory. |
| 25 | + |
| 26 | +Each turn that a piece stays STILL on a square, its strength is increased by the production value of that square. Avoid moving pieces with zero strength. If you move a piece with zero strength or make an invalid move you will not gain any production on that square that turn and you won’t do any damage in combat. |
| 27 | + |
| 28 | +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). |
| 29 | + |
| 30 | + |
| 31 | + |
| 32 | +All moves from all players are executed simultaneously at the end of the turn. |
| 33 | + |
| 34 | +### Combat |
| 35 | + |
| 36 | +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. |
| 37 | + |
| 38 | +When pieces with different owners move onto the same square or a cardinally adjacent square (immediately to the NORTH, EAST, SOUTH, or WEST), the pieces automatically fight. The battle will be resolved according to the relative strengths of the pieces. Each piece decreases the strength of every adjacent or coinciding opposing piece by its own strength. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +When a piece loses all of its strength due to combat, it dies and is removed from the grid. The square it was on becomes unowned with zero strength unless it is occupied by a non-zero strength player piece. Therefore at the start of each turn there will always be a border of unowned pieces surrounding each player. |
| 43 | + |
| 44 | +#### Summary |
| 45 | + |
| 46 | +Each turn, the following events happen, in this order: |
| 47 | + |
| 48 | +1. Pieces that did not move gain production from their site. |
| 49 | +2. Pieces that did move are moved to their destination. |
| 50 | +3. Pieces with the same owner and the same location are combined. |
| 51 | +4. All pieces are capped at strength 255. |
| 52 | +5. Each owned piece inflicts damage, equal to its strength, to co-located enemies and neutrals, and to adjacent enemies. |
| 53 | +6. Each neutral piece inflicts damage, equal to its strength, to co-located enemies. |
| 54 | +7. Each piece has its strength reduced by the damage it received this turn. |
| 55 | +8. If a piece has strength 0 or less, it is removed, unless it didn't engage in combat this turn. |
| 56 | + |
| 57 | +It is important to note that the strength reduction phase only happens after all damage has been calculated. |
| 58 | + |
| 59 | +### Overkill |
| 60 | + |
| 61 | +Pieces do damage to all coinciding (on the same square) and adjacent opposing player pieces. This allows a piece to do several times its own strength in damage if positioned correctly. This is referred to as “overkill.” |
| 62 | + |
| 63 | +**Example 1:** |
| 64 | + |
| 65 | +> A piece with 20 strength is adjacent to 2 opposing player pieces each with 5 strength. It does a total of 10 damage and loses 10 strength. No “overkill” damage was output. |
| 66 | +
|
| 67 | +**Example 2:** |
| 68 | + |
| 69 | +> A piece with 5 strength is adjacent to 2 opposing player pieces each with 10 strength. It does a total of 10 damage and loses 5 strength (and dies). 5 “overkill” damage was output. |
| 70 | +
|
| 71 | +The image below shows 2 possible outcomes of a 10 strength piece against three 15 strength pieces. |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +Bots can (and should) move their pieces tactically to use the combat rules and overkill to their own advantage. |
| 76 | + |
| 77 | +### Strength Cap Details |
| 78 | + |
| 79 | +All pieces have a strength cap of 255. If two pieces with the same owner combine, their strength is capped at 255. If a piece is STILL and gains strength equal to the production of the square it occupies, the strength is capped at 255. |
| 80 | + |
| 81 | +The 255 strength cap is applied before combat with unowned pieces or other players. |
| 82 | + |
| 83 | +**Example:** |
| 84 | + |
| 85 | +> 2 pieces with the same owner, each with 150 strength, move onto the same unowned square with 200 strength. The resulting piece will have 55 strength, not 100 strength. |
| 86 | +> |
| 87 | +> 150 + 150 > 255 therefore the strength becomes 255. 255 - 200 = 55. |
| 88 | +
|
| 89 | +### Winning |
| 90 | + |
| 91 | +Players are ranked 1st through Nth where N is the number of bots in the match. |
| 92 | + |
| 93 | +The game ends if one of two conditions are met: |
| 94 | + |
| 95 | + - If only one player has any pieces left |
| 96 | + - If `10 * sqrt(WIDTH * HEIGHT)` turns have been played |
| 97 | + |
| 98 | +The maximum number of turns is generally high enough that only the best-matched of bots will reach the turn limit; the majority of games will end before the turn limit is reached. |
| 99 | + |
| 100 | +Bots are ranked in the order in which they were eliminated. In the event that the turn limit is reached or multiple bots are destroyed on the same turn, they are ranked based on their territory at that point in the game. |
| 101 | + |
| 102 | +If there is a tie in the amount of territory each bot possesses, the full territory integral is used as the tiebreaker, although this is a rare occurrence. |
| 103 | + |
| 104 | +### How Match Results Impact Leaderboard Ranking |
| 105 | + |
| 106 | +Due to the way TrueSkill works, it isn’t necessary to come in first every match to do well. The extent of actual updates depends on how "surprising" the outcome is to the system. Unbalanced games, for example, result in either negligible updates when the favorite wins, or huge updates when the favorite loses surprisingly. |
| 107 | + |
| 108 | +After a few dozen matches you should be playing against bots of similar rank and skill and should expect to both win and lose regularly. |
0 commit comments