Skip to content

Instantly share code, notes, and snippets.

@Brilliand
Last active October 23, 2019 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Brilliand/68c85c2bdb0214466e2f48421b1931ed to your computer and use it in GitHub Desktop.
Save Brilliand/68c85c2bdb0214466e2f48421b1931ed to your computer and use it in GitHub Desktop.
"Biased Drive" bot for Grid Game KotH
const turn = api.turn();
if (turn === 0) {
this.generator = (function* () {
yield* [[0, 30], [1, 30]];
for (let i = 0; i < 10; ++i) {
yield* [[3], [1, 2]];
}
for (let i = 0; i < 4; ++i) {
yield* [[2], [0, 2]];
}
yield* [[2], [3, 4], [0, 4]];
for (let i = 0; i < 4; ++i) {
yield* [[2], [0, 2]];
}
yield* [[2], [3, 2], [0], [3, 2], [0], [3, 2], [0, 3]];
while (true) {
for (let i = 0; i < 100; ++i) {
yield* [[2, 2], [1]];
}
for (let i = 0; i < 60; ++i) {
yield* [[3, 2], [2]];
}
for (let i = 0; i < 100; ++i) {
yield* [[0, 2], [3]];
}
for (let i = 0; i < 60; ++i) {
yield* [[1, 2], [0]];
}
}
})();
this.nextCall = 0;
}
if (turn === this.nextCall) {
const [dir, delay = 1] = this.generator.next().value;
[api.awayX, api.awayY, api.towardsX, api.towardsY][dir].bind(api)();
this.nextCall += delay;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment