Created
October 30, 2019 17:59
-
-
Save SYZYGY-DEV333/1011123f70f9c43eabeef31a927bb5be to your computer and use it in GitHub Desktop.
very bad ai for 9007199254740992
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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