Bug1 algorithms in a grid