Skip to content

Commit c65a21a

Browse files
committed
Reorganize Halite Documentation
Reorganize how Halite is documented and switch from using HTML to using Markdown.
1 parent bbe7cbe commit c65a21a

File tree

10 files changed

+320
-12
lines changed

10 files changed

+320
-12
lines changed

website/composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"require": {
33
"lusitanian/oauth": "~0.3",
44
"swiftmailer/swiftmailer": "^5.4.3",
5-
"aws/aws-sdk-php": "^3.19"
5+
"aws/aws-sdk-php": "^3.19",
6+
"erusev/parsedown": "^1.6.1"
67
}
78
}

website/game_overview.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<html lang="en">
2+
<head>
3+
<?php include 'includes/header.php'; ?>
4+
5+
<title><?php echo ucwords(str_replace('_', ' ', basename(__FILE__, '.php'))); ?></title>
6+
7+
<?php include 'includes/prism_styles.php'; ?>
8+
<link href="lib/bootstrap.min.css" rel="stylesheet">
9+
<link href="style/general.css" rel="stylesheet">
10+
<link href="style/learn.css" rel="stylesheet">
11+
<style>
12+
img {
13+
max-width: 500px;
14+
text-align: center;
15+
}
16+
</style>
17+
</head>
18+
<body>
19+
<div class="container">
20+
<?php include 'includes/navbar.php'; ?>
21+
<div class="row">
22+
<?php include 'includes/learn_sidebar.php'; ?>
23+
<div class="col-sm-9">
24+
<h1><?php echo ucwords(str_replace('_', ' ', basename(__FILE__, '.php'))); ?></h1>
25+
<?php echo $Parsedown->text(file_get_contents(__DIR__ . "/learn/game/what_is_halite.md")); ?>
26+
<?php echo $Parsedown->text(file_get_contents(__DIR__ . "/learn/game/game_rules.md")); ?>
27+
</div>
28+
</div>
29+
<?php include 'includes/footer.php'; ?>
30+
</div>
31+
32+
33+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
34+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
35+
<?php include 'includes/prism_scripts.php'; ?>
36+
<script src="script/backend.js"></script>
37+
<script src="script/general.js"></script>
38+
<script>
39+
$('div.container p img').parent().addClass('text-center');
40+
</script>
41+
</body>
42+
</html>

website/includes/learn_sidebar.php

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,48 @@
2525
}
2626
2727
/* active & hover links */
28-
.bs-docs-sidebar .nav>.active>a,
29-
.bs-docs-sidebar .nav>li>a:hover,
28+
.bs-docs-sidebar .nav>.active>a,
29+
.bs-docs-sidebar .nav>li>a:hover,
3030
.bs-docs-sidebar .nav>li>a:focus {
31-
text-decoration: none;
32-
background-color: transparent;
31+
text-decoration: none;
32+
background-color: transparent;
33+
border-left-color: #63ceca;
3334
}
3435
3536
/* nested active links */
36-
.bs-docs-sidebar .nav .nav>.active>a,
37+
.bs-docs-sidebar .nav .nav>.active>a,
3738
.bs-docs-sidebar .nav .nav>.active:hover>a,
3839
.bs-docs-sidebar .nav .nav>.active:focus>a {
3940
font-weight: 700;
40-
border-left-color: #63ceca;
41+
border-left-color: #63ceca;
4142
font-weight: 500;
4243
}
4344
4445
</style>
4546

4647
<nav class="col-sm-3 bs-docs-sidebar">
4748
<ul id="sidebar" class="nav nav-stacked">
49+
<li id="quickstart">
50+
<a href="quickstart.php">Quickstart</a>
51+
<ul class="nav nav-stacked">
52+
<li id="quickstart_dive_in">
53+
<a href="quickstart.php#dive_in">Dive In</a>
54+
</li>
55+
</ul>
56+
</li>
57+
<li id="game_overview">
58+
<a href="game_overview.php">Game Overview</a>
59+
<ul class="nav nav-stacked">
60+
<li id="game_overview_what_is_halite">
61+
<a href="game_overview.php#what_is_halite">What is Halite?</a>
62+
</li>
63+
<li id="game_overview_game_rules">
64+
<a href="game_overview.php#game_rules">Game Rules</a>
65+
</li>
66+
</ul>
67+
</li>
68+
69+
4870
<li class="">
4971
<span>The Basics</span>
5072
<ul class="nav nav-stacked">
@@ -113,6 +135,28 @@
113135
var fileName = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
114136
document.getElementById("githubLink").href = "https://github.com/HaliteChallenge/Halite/blob/master/website/"+fileName;
115137
116-
var name = fileName.split(".")[0];
117-
document.getElementById(name).className = "active";
138+
function markNavActive(event) {
139+
var name = fileName.split(".")[0];
140+
141+
if (event) {
142+
var l = document.createElement("a");
143+
l.href = event.oldURL;
144+
if (l.hash) {
145+
document.getElementById(name + "_" + l.hash.substr(1)).removeAttribute("class")
146+
} else {
147+
document.getElementById(name).removeAttribute("class")
148+
}
149+
}
150+
151+
if (location.hash) {
152+
document.getElementById(name).removeAttribute("class")
153+
document.getElementById(name + "_" + location.hash.substr(1)).className = "active"
154+
} else {
155+
document.getElementById(name).className = "active"
156+
}
157+
}
158+
159+
markNavActive();
160+
161+
window.addEventListener("hashchange", markNavActive, false);
118162
</script>

website/includes/prism_scripts.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/prism.min.js"></script>
2+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/autolinker/prism-autolinker.min.js"></script>
3+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/show-language/prism-show-language.min.js"></script>
4+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/highlight-keywords/prism-highlight-keywords.min.js"></script>
5+
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/autoloader/prism-autoloader.min.js"></script>
6+
<script>Prism.plugins.autoloader.languages_path = 'https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/components/'</script>

website/includes/prism_styles.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
require __DIR__ . '/../vendor/autoload.php';
3+
$Parsedown = new Parsedown();
4+
?>
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/themes/prism.min.css" />
6+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/autolinker/prism-autolinker.min.css" />
7+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.5.1/plugins/show-language/prism-show-language.min.css" />

website/install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
22
apt-get update
33

4-
apt-get install -y php5.6 php5.6-mysql apache2
4+
apt-get install -y php5.6 php5.6-mbstring php5.6-mysql apache2
55
a2enmod rewrite expires
66

7-
apt-get install -y python3 python3-pip
7+
apt-get install -y python3 python3-pip
88

99
pip3 install trueskill boto paramiko pymysql
1010

11-
apt-get install -y zip
11+
apt-get install -y zip
1212

1313
curl -sS https://getcomposer.org/installer | php
1414
mv composer.phar /usr/local/bin/composer

website/learn/game/game_rules.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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+
![Alt text](assets/combination.png)
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+
![Alt text](assets/overkill-2.png)
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+
![Alt text](assets/overkill-1.png)
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.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## <a name="what_is_halite"></a> What is Halite?
2+
3+
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.
4+
5+
Halite (the tournament) is an online programming competition where human coders write bots that play Halite (the game) against each other.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## <a name="dive_in"></a> Dive In
2+
3+
Joining the tournament is free! Sign up, download a starter package, make some changes, and upload your bot to the game servers to participate.
4+
5+
### Register Using GitHub
6+
7+
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](https://github.com/join). Sign up for Halite by clicking "Login with Github" at the top right of this page.
8+
9+
### What information do you store about me?
10+
11+
We store the email, username, and unique identifier that Github provides when you login to the halite.io website via Github OAuth.
12+
13+
### Download a Starter Package
14+
15+
There are Starter Packages available for many languages on the [Downloads page](downloads.php). Use any language you like, you can always switch to a different language later!
16+
17+
Each Starter Package contains:
18+
- A code template for your first bot (the `MyBot` file in your language of choice)
19+
- A code sample of a random bot (the `RandomBot` file in your language of choice)
20+
- Additional files to help your bot interact with the environment (e.g. `Networking` and `hlt` - feel free to modify these as needed for your bot)
21+
- Tools to run and test your bot on your local machine
22+
23+
### Download the Halite Environment
24+
25+
In order to run your bot locally you’ll want to download the Halite environment. Follow the instructions on the [Downloads page](downloads.php) for your OS.
26+
27+
### Improve Your Bot
28+
29+
Each `MyBot` starter template is just the `RandomBot`. You can submit this to the server, but it probably won’t win very much.
30+
31+
Make some changes to your bot and test it locally. Use `runGame.sh`/`runGame.bat` to run your bot against the `RandomBot`. Use the [Visualizer](local_visualizer.php) to watch your local game replays. Just drag or upload the `.hlt` file to watch your bot compete.
32+
33+
If you need some ideas about where to start, check out some of the Tutorials.
34+
35+
### Submit Your Bot
36+
37+
You need to upload your bot to start competing against other bots on the [Leaderboard](leaderboard.php).
38+
39+
Create a `zip` file containing your `MyBot` file and all dependencies (usually the `Networking` or `hlt` files and any additional files you created). As an example, the Starter Package `zip` file that you just downloaded is in the correct format.
40+
41+
See the documentation on _ for more details about everything you can include in your `zip` file to control your bot’s compilation and execution.
42+
43+
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. If the compilation of your source code fails, we will email you.
44+
45+
### Watch Your Bot Play
46+
47+
As your bot competes, it will move up in the [Rankings](leaderboard.php). Visit your [homepage](user.php) to view your matches and replays against other bots.
48+
49+
### Join the Community
50+
51+
If you need help or have feedback, please visit the [Forums](http://forums.halite.io/)! If you’d like to hang out and chat with other players, come join the [official Discord](https://discordapp.com/invite/rbVDB4n).
52+
53+
### Next Steps
54+
55+
Learn more about Halite:
56+
57+
- [Game Overview](game_overview.php)
58+
- [Tournament Overview](tournament_overview.php)
59+
- [Bot Overview](bot_overview.php)
60+
- [Server Overview](server_overview.php)
61+
- [Tutorials](tutorials.php)
62+
- [Developing a Bot](developing_a_bot.php)
63+
- [FAQs](faqs.php)

website/quickstart.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<html lang="en">
2+
<head>
3+
<?php include 'includes/header.php'; ?>
4+
5+
<title><?php echo ucwords(str_replace('_', ' ', basename(__FILE__, '.php'))); ?></title>
6+
7+
<?php include 'includes/prism_styles.php'; ?>
8+
<link href="lib/bootstrap.min.css" rel="stylesheet">
9+
<link href="style/general.css" rel="stylesheet">
10+
<link href="style/learn.css" rel="stylesheet">
11+
</head>
12+
<body>
13+
<div class="container">
14+
<?php include 'includes/navbar.php'; ?>
15+
<div class="row">
16+
<?php include 'includes/learn_sidebar.php'; ?>
17+
<div class="col-sm-9">
18+
<h1><?php echo ucwords(str_replace('_', ' ', basename(__FILE__, '.php'))); ?></h1>
19+
<?php echo $Parsedown->text(file_get_contents(__DIR__ . "/learn/quickstart/dive_in.md")); ?>
20+
</div>
21+
</div>
22+
<?php include 'includes/footer.php'; ?>
23+
</div>
24+
25+
26+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
27+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
28+
<?php include 'includes/prism_scripts.php'; ?>
29+
<script src="script/backend.js"></script>
30+
<script src="script/general.js"></script>
31+
</body>
32+
</html>

0 commit comments

Comments
 (0)