Skip to content

Commit 10cbee2

Browse files
committed
Merge branch 'master' into c
2 parents cf65d78 + 403c5c2 commit 10cbee2

File tree

7 files changed

+28
-10
lines changed

7 files changed

+28
-10
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ If you find a bug or have a feature request, please [open an issue](https://gith
2020

2121
Want to help out? Have you implemented a patch or a new feature? Send us a pull request! If you are looking for things to do, check out [our open issues](https://github.com/HaliteChallenge/Halite/issues).
2222

23+
### Writing a Starter Package
24+
2325
If you'd like to write a starter package for a new language, see this [guide](https://halite.io/advanced_writing_sp.php).
2426

27+
### Adding Your Company or University
28+
29+
Edit [this whitelist](https://github.com/HaliteChallenge/Halite/edit/master/website/organizationWhitelist.txt) and send us a pull request. If you need to change your email, head [here](https://halite.io/email.php). We'll make sure to tag all members of your organization who have already signed up.
30+
2531
### Authors
2632

2733
Halite was primarily created by [Ben Spector](https://github.com/Sydriax) and [Michael Truell](https://github.com/truell20) for Two Sigma during their summer 2016 internship. However, many others contributed to Halite's developement, including [Matt Adereth](https://github.com/adereth) and [Trammell Hudson](https://github.com/osresearch) from Two Sigma and [Arnaud Sahuguet](https://github.com/sahuguet) and [Scot Spinner](https://github.com/awesomescot) from Cornell Tech.

environment/networking/Networking.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ void Networking::startAndConnectBot(std::string command) {
278278
if(pid == 0) { //This is the child
279279
setpgid(getpid(), getpid());
280280

281+
#ifdef __linux__
281282
// install a parent death signal
282283
// http://stackoverflow.com/a/36945270
283284
int r = prctl(PR_SET_PDEATHSIG, SIGTERM);
@@ -288,6 +289,7 @@ void Networking::startAndConnectBot(std::string command) {
288289
}
289290
if (getppid() != ppid_before_fork)
290291
exit(1);
292+
#endif
291293

292294
dup2(writePipe[0], STDIN_FILENO);
293295

@@ -317,9 +319,9 @@ void Networking::startAndConnectBot(std::string command) {
317319
}
318320

319321
int Networking::handleInitNetworking(unsigned char playerTag, const hlt::Map & m, bool ignoreTimeout, std::string * playerName) {
320-
322+
321323
const int ALLOTTED_MILLIS = ignoreTimeout ? 2147483647 : 15000;
322-
324+
323325
std::string response;
324326
try {
325327
std::string playerTagString = std::to_string(playerTag), mapSizeString = serializeMapSize(m), mapString = serializeMap(m), prodString = serializeProductions(m);
@@ -362,7 +364,7 @@ int Networking::handleInitNetworking(unsigned char playerTag, const hlt::Map & m
362364
int Networking::handleFrameNetworking(unsigned char playerTag, const unsigned short & turnNumber, const hlt::Map & m, bool ignoreTimeout, std::map<hlt::Location, unsigned char> * moves) {
363365

364366
const int ALLOTTED_MILLIS = ignoreTimeout ? 2147483647 : 1500;
365-
367+
366368
std::string response;
367369
try {
368370
if(isProcessDead(playerTag)) return -1;

environment/networking/Networking.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include <sys/stat.h>
1717
#include <fcntl.h>
1818
#include <sys/select.h>
19+
#ifdef __linux__
1920
#include <sys/prctl.h>
21+
#endif
2022
#include <unistd.h>
2123
#endif
2224

website/api/manager/ManagerAPI.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ protected function task() {
8686
$numPlayers = $possibleNumPlayers[array_rand($possibleNumPlayers)];
8787

8888
$seedPlayer = null;
89-
if((mt_rand() / mt_getrandmax()) > 0.5) {
89+
$randValue = mt_rand() / mt_getrandmax();
90+
if($randValue > 0.5) {
9091
$seedPlayer = $this->select("SELECT * FROM User WHERE isRunning = 1 order by rand()*-pow(sigma, 2) LIMIT 1");
91-
} else {
92+
}
93+
if ($randValue > 0.25 && $randValue <= 0.5) {
9294
$seedPlayer = $this->select("SELECT * FROM (SELECT u.* FROM (SELECT MAX(g.timestamp) as maxTime, gu.userID as userID FROM GameUser gu INNER JOIN Game g ON g.gameID=gu.gameID GROUP BY gu.userID) temptable INNER JOIN User u on u.userID = temptable.userID where numGames < 400 order by maxTime ASC limit 15) orderedTable order by rand() limit 1;");
93-
if(count($seedPlayer) < 1) $seedPlayer = $this->select("SELECT u.* FROM (SELECT MAX(g.timestamp) as maxTime, gu.userID as userID FROM GameUser gu INNER JOIN Game g ON g.gameID=gu.gameID GROUP BY gu.userID) temptable INNER JOIN User u on u.userID = temptable.userID order by maxTime ASC limit 1");
95+
}
96+
if($randValue <= 0.25 || count($seedPlayer) < 1) {
97+
$seedPlayer = $this->select("SELECT u.* FROM (SELECT MAX(g.timestamp) as maxTime, gu.userID as userID FROM GameUser gu INNER JOIN Game g ON g.gameID=gu.gameID GROUP BY gu.userID) temptable INNER JOIN User u on u.userID = temptable.userID order by maxTime ASC limit 1");
9498
}
95-
if(count($seedPlayer) < 1) return null;
9699

97100
$muRankLimit = intval(5.0 / pow((float)mt_rand(1, mt_getrandmax())/(float)mt_getrandmax(), 0.65));
98101
$players = $this->selectMultiple("SELECT * FROM (SELECT * FROM User WHERE isRunning=1 and userID <> {$seedPlayer['userID']} ORDER BY ABS(mu-{$seedPlayer['mu']}) LIMIT $muRankLimit) muRankTable ORDER BY rand() LIMIT ".($numPlayers-1));

website/local_visualizer.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
<input type="file" id="filePicker" style="display: none;">
2121
</div>
2222
</div>
23-
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
2423
</div>
2524

2625
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>

website/organizationWhitelist.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Two Sigma - twosigma.com
2+
Auburn - auburn.edu
23
Cornell - cornell.edu
34
NYU - nyu.edu
45
Stanford - stanford.edu
@@ -91,4 +92,6 @@ Carleton University - carleton.ca
9192
DoubleDutch - doubledutch.me
9293
RWTH Aachen - rwth-aachen.de
9394
University of Aveiro - ua.pt
94-
Allstate - allstate.com
95+
Allstate - allstate.com
96+
Dreamix - dreamix.eu
97+
KU Leuven - student.kuleuven.be

website/script/visualizer.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ function showGame(game, $container, maxWidth, maxHeight, showmovement, isminimal
401401
renderer.render(stage);
402402

403403
//Of course, we want to render in the future as well.
404-
requestAnimationFrame(animate);
404+
var idle = (Object.keys(pressed).length === 0) && !shouldplay;
405+
setTimeout(function() {
406+
requestAnimationFrame(animate);
407+
}, 1000 / (idle ? 6.0 : 80.0));
405408
}
406409
}
407410

0 commit comments

Comments
 (0)