Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
so, with all this, how can I programatically map the shortest path? (or, if there IS no path determinable from the present data, return an appropriate error message?) any & all help appreciated!sub isNorth { # Passed x & y coords, determines if able to go north my($x,$y) = @_; if($grid[$x][$y] =~ /n/) { return 1 # Can go north, return 1 for true } else { return 0 # Can't go north, return 0 for false } } sub isSouth { # Passed x & y coords, determines if able to go south my($x,$y) = @_; if($grid[$x][$y] =~ /s/) { return 1 # Can go south, return 1 for true } else { return 0 # Can't go south, return 0 for false } } sub isEast { # Passed x & y coords, determines if able to go east my($x,$y) = @_; if($grid[$x][$y] =~ /e/) { return 1 # Can go east, return 1 for true } else { return 0 # Can't go east, return 0 for false } } sub isWest { # Passed x & y coords, determines if able to go west my($x,$y) = @_; if($grid[$x][$y] =~ /w/) { return 1 # Can go west, return 1 for true } else { return 0 # Can't go west, return 0 for false } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mapping paths?...
by merlyn (Sage) on May 18, 2001 at 01:49 UTC | |
|
Re: Mapping paths?...
by no_slogan (Deacon) on May 17, 2001 at 22:23 UTC | |
by myocom (Deacon) on May 17, 2001 at 22:28 UTC | |
|
Re: Mapping paths?...
by DrZaius (Monk) on May 17, 2001 at 22:27 UTC | |
by no_slogan (Deacon) on May 17, 2001 at 22:48 UTC | |
by orkysoft (Friar) on May 22, 2001 at 03:34 UTC | |
by orkysoft (Friar) on May 18, 2001 at 16:57 UTC |