Skip to content

Instantly share code, notes, and snippets.

@SpicyKitten
Created October 29, 2019 18:17
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 SpicyKitten/966e8f3ad189b9535c2e1fad3ffc065a to your computer and use it in GitHub Desktop.
Save SpicyKitten/966e8f3ad189b9535c2e1fad3ffc065a to your computer and use it in GitHub Desktop.
Hocus Pocus why does this workus
const turn = api.turn();
if (turn === 0) {
this.generator = (function*() {
yield* [[3, 8], [2, 16], [3], [0], [1], [0, 27]];
while (true) {
yield* [[3, 36], [2, 36], [1, 36], [0, 36]];
for (let i = 0; i < 20; ++i) {
yield* [[2, 2], [1]];
}
for (let i = 0; i < 20; ++i) {
yield* [[2, 2], [3]];
}
for (let i = 0; i < 20; ++i) {
yield* [[0, 2], [1]];
}
for (let i = 0; i < 20; ++i) {
yield* [[0, 2], [3]];
}
for (let i = 0; i < 10; ++i) {
yield* [[1], [3, 2]];
yield* [[2], [0, 2]];
yield* [[3], [1, 2]];
yield* [[0], [2, 2]];
}
}
})();
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