Optimizing Board.equals and changing array to be linear