Add algorithm that handles board edges separately.