Last active
July 26, 2016 07:40
-
-
Save 5hirish/35a16ccd835ee33d381ebcf9d3c69ae9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
def explore(i, j, grid_map_exp, grid_map): | |
if i <= 3 and j <= 3: | |
current = grid_map[i][j] | |
if current == 's' or current == '-': | |
explore(i, j+1, grid_map_exp, grid_map) | |
explore(i, j-1, grid_map_exp, grid_map) | |
explore(i+1, j, grid_map_exp, grid_map) | |
explore(i-1, j, grid_map_exp, grid_map) | |
if grid_map[i][j]=='-': | |
parent = (i,j) | |
grid_map_exp[parent] = grid_map[i][j] | |
grid_map_exp = {} | |
grid_map = [['w','-','d','-'], | |
['w','-','w','-'], | |
['w','-','-','-'], | |
['-','-','w','s']] | |
root = (3,3) | |
grid_map_exp[root] = None | |
i , j = root | |
explore(i, j, grid_map_exp, grid_map) | |
print(grid_map_exp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment