Skip to content

Instantly share code, notes, and snippets.

@SYZYGY-DEV333
Created October 30, 2019 17:59
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 SYZYGY-DEV333/1011123f70f9c43eabeef31a927bb5be to your computer and use it in GitHub Desktop.
Save SYZYGY-DEV333/1011123f70f9c43eabeef31a927bb5be to your computer and use it in GitHub Desktop.
very bad ai for 9007199254740992
var x = 0;
var active = true;
var prev = JSON.stringify(GM.grid.cells);
function moved() {
if (prev == JSON.stringify(GM.grid.cells)) {
prev = JSON.stringify(GM.grid.cells);
return false
} else {
prev = JSON.stringify(GM.grid.cells);
return true
}
}
function isEven(n) {
return n % 2 == 0;
}
function filled(column) {
if (GM.grid.cells[column].includes(null)) {
return false
} else { return true }
}
function lastFilled() {
for(i = 7; i >= 0; i--) {
if (filled(i)) {
return i
}
}
}
function normalMove() {
GM.move(3);
GM.move(3);
GM.move(3);
GM.move(0);
}
function altMove() {
GM.move(3);
GM.move(3);
GM.move(3);
GM.move(2);
}
setInterval(function() {
if (active == true) {
if (isEven(lastFilled())) {
if (moved()) {
normalMove();
} else {
altMove();
}
} else {
if (moved()) {
altMove();
} else {
normalMove();
}
}
}
}, x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment