@haelp/teto
Version:
A typescript-based controllable TETR.IO client.
27 lines (26 loc) • 694 B
JavaScript
import { RNG } from "../../utils/index.mjs";
import { Mino } from "../types.mjs";
export const classic = (seed)=>{
const TETROMINOS = [
Mino.Z,
Mino.L,
Mino.O,
Mino.S,
Mino.I,
Mino.J,
Mino.T
];
let lastGenerated = null;
const gen = new RNG(seed);
return ()=>{
let index = Math.floor(gen.nextFloat() * (TETROMINOS.length + 1));
if (index === lastGenerated || index >= TETROMINOS.length) {
index = Math.floor(gen.nextFloat() * TETROMINOS.length);
}
lastGenerated = index;
return [
TETROMINOS[index]
];
};
};
//# sourceMappingURL=classic.js.map