What if cell is a wall (#)? You can't stand on a wall, so no paths can reach it. Set for any wall cell. Walls block paths completely.
When computing for a passable cell, treat each blocked neighbor as contributing paths. Since , the formula works unchanged. Initialize all wall cells to before running the DP.