Skip to content

Instantly share code, notes, and snippets.

@Brilliand

Brilliand/bot.js

Created Oct 29, 2019
Embed
What would you like to do?
"CBC Forever" bot for Grid Game KotH
const turn = api.turn();
const opening =
"SSSEEESSSEEEEEEEEEESSEEE"+
"SSSEEESSSEEEEEEESSEEEEEE"+
"SSSEEESSSEEEESSEEEEEEEEE"+
"SSSEEESSSESSEEEEEEEEEEEE";
const pattern = "NWSSSSEEESSSWNEESSEEEEEEEEEEEE";
if(turn < opening.length) {
switch (opening[turn]) {
case 'W':
api.awayX();
break;
case 'N':
api.awayY();
break;
case 'E':
api.towardsX();
break;
case 'S':
api.towardsY();
break;
}
} else {
switch (pattern[(turn-opening.length)%pattern.length]) {
case 'W':
api.awayX();
break;
case 'N':
api.awayY();
break;
case 'E':
api.towardsX();
break;
case 'S':
api.towardsY();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment