Professional Documents
Culture Documents
and stacks
Norbert Wiener’s method
• This is the simplest approach to maze
solving, but unfortunately it only works for
a restricted class of mazes. You do not need
to be able to see where the walls are, you
simply move so that there is always a wall
on one side of you.
Nobert Wiener
Born: 26 Nov 1894 in Columbia, Missouri, USA
Died: 18 March 1964 in Stockholm, Sweden
• Norbert Wiener received his Ph.D. from Harvard at the
age of 18 with a dissertation on mathematical logic. From
Harvard to went to Cambridge, England to study under
Russell, then he went to Göttingen to study under
Hilbert. He was influence by both Hilbert and Russell
but also, perhaps to an even greater degree, by Hardy.
• After various occupations (journalist, university teacher,
engineer, writer) in which he was very unhappy, he
began a long association with MIT in 1919.
The Norbert Wiener Centenary Congress
11/27/94 - 12/3/94) Michigan State University, East Lansing,
MI 48824 Sponsored by AMS, WOSC, MSU
Wiener's concept of the stochastic universe
This Maze is a
Complete Maze, since
there is at least one
path from Start Point
to End Point.
First algorithm
• if((!maze[h][h] && (!
• Inner loop checks all 8 mark[g][h]))
possible positions • {
• while (there are more • mark[g][h]=1;
moves) • dir = next direction;
• { • add)i,j.dir) to stack;
• (g,h) //coordinates of • i = g;
next move • j=h;
• if((g==m) && (h==p))) • dir = north;
• success; • }
Outer loop
Now the outer loop is the one that
keeps track of current moves and
continues as long as the stack is not
empty. The stack is initialized to the
entrance and direction east
while(stack is not empty){
(I,j,dir) =coordinates and direction from top of stack
code from previous slides
}
no path found;
What comes next???
Now we need to represent the list of
new triples {x,y, and direction).
mark[1][1] =1;
Stack<items>stack(m*p);
items temp;
temp.x=1; temp.y=1; temp.dir =E;
stack.Add(temp)
//this declares the first point going on the
stack
While (!stack.IsEmpty())
{
temp =*stack.Delete(temp);// take off first pt.
Int I=temp.x;
int j=temp.y;
int d =temp.dir;
while(d<8)
int g = I+move[d].a; int h =j +move [d].b;
//now check if reached exit.
(inside while (d<8) loop
cout<<Stack;
//last two squares on path
cout<<I<<“”<<j<<endl;
cout <<m<<“ “ <<p<<endl;
return;
}
stack.Add(temp);
i=g;j=h;d=N; //(new point)
Now this previous code takes care of the
problems we had to address.