Thanks a lot Mr Getzler,I really appreciate your help,but one downside of this algorithm is that bug (program) has to scan entire maze and exit (destination) have to be known in advance.
I was thinking something more like real life,so someone puts you (my little bug) in front of the maze and you dont know anything else.
Anyway I came up with something else:
Bug goes strait in one direction until it bumps the wall.Then it changes direction by +90 deg if possible,or -90 deg if possible,or finally +180 deg and moves further.
if previous field had 3 walls it is dead end,so in present field bug puts a mark in direction opposite of its heading,so it knows it is a dead end.
A bit complicated to explain,but I am posting my aia,and really would like to her your comment.
Didnt bother with resizing maze to fit screen for now,and I adjusted bug size to always be in center of one field