Created
May 21, 2021 01:02
-
-
Save tabatkins/e85eb4d01f6c68547b0191e6e8035f14 to your computer and use it in GitHub Desktop.
Unobfuscated version of HATETRIS's default AI
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
function construct(getNextStates) { | |
return function ai(currentState) { | |
const pieces = [ | |
{name:"S", annoyance:7}, | |
{name:"Z", annoyance:6}, | |
{name:"O", annoyance:5}, | |
{name:"I", annoyance:4}, | |
{name:"L", annoyance:3}, | |
{name:"J", annoyance:2}, | |
{name:"T", annoyance:1}, | |
]; | |
for(const piece of pieces) { | |
const wellHeights = getNextStates(piece.name, currentState) | |
.map(getWellHeight); | |
piece.bestWellHeight = Math.min(...wellHeights); | |
} | |
// Find the piece that, at best, still gives the highest well height. | |
// Tie-break by selecting the most annoying piece. | |
pieces.sort((a,b)=>a.bestWellHeight - b.bestWellHeight || a.annoyance - b.annoyance); | |
return pieces[0].name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment