Introduction to Artificial Intelligence -- Search Methods Maze search -- Mouse intelligence A mouse searches for an exit in depth-first manner. - - - - - - - - - - - - - - - - - - - | * | | | The mouse tries (up, right, down, | | _ _ _ _ _ | _ _ _ _ | | left) in this order. It never | | | | | | goes to an already visited point. | | | _ _ _ | | _ _ _ _ | | | | | | | | _ _ _ | | _ _ | _ _ _ | _ _ | | | | | | _ _ _ _ | _ _ _ _ _ _ _ | | | | | | | | | | | _ _ | _ _ _ _ _ | | | | | | | | | | | | | | _ _ _ _ _ _ | | | _ _ | | | | | | | | | _ _ _ _ _ | | | _ | | | | | | | | | | | | _ _ _ | | | | | | | | - - - - - - - - - - - - - - - - - - - exit - - - - - - - - - - - - - - - - - - - | * | * * * * * * * * * * * * * | | When it comes to a deadend, | * | * _ _ _ _ _ | _ _ _ _ | | | * | * | | | | | * | * | _ _ _ | | _ _ _ _ | | * * * | | | | | | _ _ _ | | _ _ | _ _ _ | _ _ | | | | | | _ _ _ _ | _ _ _ _ _ _ _ | | | | | | | | | | | _ _ | _ _ _ _ _ | | | | | | | | | | | | | | _ _ _ _ _ _ | | | _ _ | | | | | | | | | _ _ _ _ _ | | | _ | | | | | | | | | | | | _ _ _ | | | | | | | | - - - - - - - - - - - - - - - - - - - exit - - - - - - - - - - - - - - - - - - - | * | * * * * * * * * * | | it goes back to the nearest | * | * _ _ _ _ _ | * _ _ _ _ | | branching point, and goes down | * | * | | * | | | * | * | _ _ _ | * | _ _ _ _ | | * * * | | | | | | _ _ _ | | _ _ | _ _ _ | _ _ | | | | | | _ _ _ _ | _ _ _ _ _ _ _ | | | | | | | | | | | _ _ | _ _ _ _ _ | | | | | | | | | | | | | | _ _ _ _ _ _ | | | _ _ | | | | | | | | | _ _ _ _ _ | | | _ | | | | | | | | | | | | _ _ _ | | | | | | | | - - - - - - - - - - - - - - - - - - - exit - - - - - - - - - - - - - - - - - - - | * | * * * * * * * | | Finally it finds the exit. | * | * _ _ _ _ _ * | _ _ _ _ | | | * | * | * * * * * | | | | * | * | * _ _ _ | | _ _ _ _ | | * * * | * | | | | | _ _ _ | * | _ _ | _ _ _ | _ _ | | * * * * * | | * * * | | * _ _ _ _ | _ _ _ _ _ _ _ | * | * | | * | | | * | * | | * | _ _ | _ _ _ _ _ | * | * | | * | | * * * | | * | * | | * * * | * | * | _ _ _ _ _ | * | * | | _ _ * | * | * | * * * * * * * | * | | * | * | * | * _ _ _ _ _ _ | * | | _ * | * | * | * | | * | | | * | * | * | * | _ _ _ | * | | | * * * | * * * | | * | - - - - - - - - - - - - - - - - - - - exit There is no concept of back tracking in the mouse intelligence. The mouse program is listed below. ## This Python program tarces a maze search with symbol "*". ## The first part is the maze data in one-dim list c. ## The one-dim array is converted to two-dim list a. ## The depth-first seacrh is carried out by recursive calls ## to four directions (up, right, down, left). c=[ "-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-", "|"," ","|"," "," "," "," "," "," "," "," "," "," "," "," "," ","|"," ","|", "|"," ","|"," ","_","_","_","_","_"," ","|"," ","_","_","_","_","|"," ","|", "|"," ","|"," ","|"," "," "," "," "," ","|"," ","|"," "," "," "," "," ","|", "|"," ","|"," ","|"," ","_","_","_"," ","|"," ","|"," ","_","_","_","_","|", "|"," "," "," ","|"," ","|"," "," "," ","|"," "," "," ","|"," "," "," ","|", "|","_","_","_","|"," ","|"," ","_","_","|","_","_","_","|"," ","_","_","|", "|"," "," "," "," "," ","|"," "," "," "," "," "," "," ","|"," "," "," ","|", "|"," ","_","_","_","_","|","_","_","_","_","_","_","_","|"," ","|"," ","|", "|"," ","|"," "," "," ","|"," "," "," "," "," "," "," ","|"," ","|"," ","|", "|"," ","|"," ","_","_","|"," ","_","_","_","_","_"," ","|"," ","|"," ","|", "|"," ","|"," ","|"," "," "," ","|"," "," "," "," "," ","|"," ","|"," ","|", "|"," "," "," ","|"," ","|"," ","|","_","_","_","_","_","|"," ","|"," ","|", "|","_","_"," ","|"," ","|"," ","|"," "," "," "," "," "," "," ","|"," ","|", "|"," "," "," ","|"," ","|"," ","|"," ","_","_","_","_","_","_","|"," ","|", "|"," ","_"," ","|"," ","|"," ","|"," ","|"," "," "," "," "," ","|"," ","|", "|"," ","|"," ","|"," ","|"," ","|"," ","|"," ","_"," ","_","_","|"," ","|", "|"," ","|"," "," "," ","|"," "," "," ","|"," ","|"," "," "," "," "," "," ", "-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-","-"]; n=19; ### size of maze is 19 by 19 a=[] for i in range(0,n): a1=[] for j in range(0,n): a1=a1+[c[i*n+j]] a=a+[a1] for i in range(0,n): for j in range(0,n): print a[i][j], print "\n", def dfs(x, y): a[x][y]="*"; print "\n" ; for i in range(0,n): for j in range(0,n): print a[i][j] , if(i