Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function walkThroughWall (R)
- if ~R.is_bord('n')
- R.step('n')
- else
- length = 1;
- Door = 0;
- direction = 'w';
- while ~Door
- Door = move(R, direction, length);
- direction = changeDirection(direction);
- length++;
- end
- end
- end
- function Door = stepAndFind (R, direction)
- R.step(direction)
- Door = ~R.is_bord('n');
- end
- function Door = move (R, direction, steps)
- flag = 0;
- for i = [1:steps]
- if stepAndFind(R, direction) && ~flag
- R.step('n');
- flag = 1;
- end
- end
- Door = flag;
- end
- function Direction = changeDirection (direction)
- if direction == 'o'
- Direction = 'w';
- else
- Direction = 'o';
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement