Skip to content

Instantly share code, notes, and snippets.

@Brilliand
Created October 29, 2019 01:35
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/cb68f09d808b5de34daf5c45b46f2bea to your computer and use it in GitHub Desktop.
Save Brilliand/cb68f09d808b5de34daf5c45b46f2bea to your computer and use it in GitHub Desktop.
"Feint" bot for Grid Game KotH
const turn = api.turn();
if (turn === 0) {
this.generator = (function* () {
yield* [[3, 8], [2, 16], [3], [0], [1], [0, 27]];
let laps = 1;
while(true) {
for (let i = 0; i < laps*10; ++i) {
yield* [[3, 2], [0]];
}
laps++;
for (let i = 0; i < laps*10; ++i) {
yield* [[2, 2], [3]];
}
laps++;
for (let i = 0; i < laps*10; ++i) {
yield* [[1, 2], [2]];
}
laps++;
for (let i = 0; i < laps*10; ++i) {
yield* [[0, 2], [1]];
}
laps++;
}
})();
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