Skip to content

Instantly share code, notes, and snippets.

function countPieces() {
it = b.pieces();
var i = 0;
while (it.current()){ i++; it.next() }
return i;
}
function getRandPiece() {
var it = b.pieces();
var n = Math.floor(Math.random()*countPieces());