This challenge takes place on a grid.
+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+
This one's 10 x 10, but it can be any rectangular shape.
There are four directions on this grid. Up, down, left and right.
The task is to draw a path starting with an upper case direction initial. In this example, will go directly upward from the U.
+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+
The path will go upwards and be comprised of full-stop characters (.), until it hits a wall, when it will terminate with an asterisk (*).
+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+
In addition to path starts, there's also direction changers, represented by a lower case direction initial.
+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+
Also, an upper case X us an obstacle which will terminate the path.
+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+
Rules
- The input is a string consisting of a frame, (consisting of |, - and + characters) containing characters denoting path starts, direction changers, and obstacles.
- Your code should add full stop characters to follow the path described by starts and direction changers, and an asterisk when/if the path meets a wall or obstacle.
- There can be multiple path starts.
- The code will still terminate without error if the path describes a loop.
- If a path meets a path start, it will act as a direction changer.
- It's code golf, low-byte code and no standard loopholes, please.
- I always prefer links to an on-line interpreter.
Test Cases
1: Simple
+----------+
| |
| |
| |
| |
| |
| |
| |
| |
| U |
+----------+
+----------+
| * |
| . |
| . |
| . |
| . |
| . |
| . |
| . |
| U |
+----------+
2: Right turn
+----------+
| |
| |
| |
| r |
| |
| |
| |
| |
| U |
+----------+
+----------+
| |
| |
| |
| r.....*|
| . |
| . |
| . |
| . |
| U |
+----------+
3: Crossroads
+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+
+----------+
| * |
| . |
| . |
| . r..d |
| . . . |
| u....l |
| . |
| . |
| U |
+----------+
4: 4 Crossing paths
+----------+
| D |
| |
| |
|R |
| |
| L|
| |
| |
| U |
+----------+
+----------+
| * D |
| . . |
| . . |
|R........*|
| . . |
|*........L|
| . . |
| . . |
| U * |
+----------+
5: First Loop
+----------+
| |
| |
| |
| r d |
| |
| u l |
| |
| |
| U |
+----------+
+----------+
| |
| |
| |
| r..d |
| . . |
| u..l |
| . |
| . |
| U |
+----------+
6: Starter as changer
+----------+
| |
| |
| |
| L |
| |
| |
| |
| |
| U |
+----------+
+----------+
| |
| |
| |
|*..L |
| . |
| . |
| . |
| . |
| U |
+----------+
7: Straight Loop
+----------+
| |
| |
| |
| |
| r l |
| |
| |
| |
| U |
+----------+
+----------+
| |
| |
| |
| |
| r..l |
| . |
| . |
| . |
| U |
+----------+
8: Tight Knot
+----------+
| |
| |
| |
| d l |
| r u |
| r u |
| |
| |
| U |
+----------+
+----------+
| * |
| . |
| . |
| d..l |
| .r.u |
| r.u |
| . |
| . |
| U |
+----------+
9: An Obstacle
+----------+
| |
| |
| |
| |
| r X |
| |
| |
| |
| U |
+----------+
+----------+
| |
| |
| |
| |
| r...*X |
| . |
| . |
| . |
| U |
+----------+
10: S Shape
+----------+
|r d |
| |
| XXXXXXXX|
| d l |
|ul |
|XXXXXXX |
| |
|R u |
| |
+----------+
+----------+
|r.....d |
|. * |
|. XXXXXXXX|
|.d......l |
|ul . |
|XXXXXXX . |
| . |
|R.......u |
| |
+----------+
11: 4-Way Knot
+----------+
| D |
| |
| r |
|R d |
| |
| u L|
| l |
| |
| U |
+----------+
+----------+
| * D |
| . . |
| r.....*|
|R....d. |
| .... |
| .u....L|
|*.....l |
| . . |
| U * |
+----------+
12: Busy Junctions
+----------+
|rrrrr rrrd|
| rlrl |
|ul rrd |
|ruX X |
|udl ll |
|ull |
|rlr |
|rdr d |
|Uruull |
+----------+
+----------+
|rrrrr.rrrd|
|.rlrl .|
|ul rrd .|
|ruX.X. .|
|udl.ll .|
|ull. .|
|rlr. .|
|rdr..d .|
|Uruull *|
+----------+
13: Starts Into Edge
+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+
+----------+
| U |
| |
| |
| |
| |
| |
| |
| |
| |
+----------+
14: Crossing Dead Paths
+----------+
| |
| |
| |
| R |
| |
| |
| |
| |
| U|
+----------+
+----------+
| *|
| .|
| .|
| R..*|
| .|
| .|
| .|
| .|
| U|
+----------+