I'm checking this 0x88 algorithm and it's 'off-the-board' detection advantages. Might recreate something similar just cheching the [i][j] values. I'm writting the square contents on a matrix, but it seems it's feasible to write them on a unidimensional array and locate positions using equivalence classes. Thus, off-board detection may change depending on the way the board is stored.