This challenge is inspired from this answer at the Ask Ubuntu Stack Exchange.
Remember the Windows ME screensaver with the pipes? Time to bring the nostalgia back!
You should write a program or function which will output an ASCII representation of the screensaver. In the screensaver there should be a single pipe which will grow in semi-random directions.
The start of the pipe will be randomly placed at any of the borders of the screen and the pipe piece should be perpendicular to the border (corner first-pipes can either be horizontal or vertical). Each tick the pipe will grow in the direction it is facing (horizontal/vertical) at an
80% chance or take a corner at a
To create the pipe, 6 unicode characters will be used
─ \u2500 horizontal pipe │ \u2502 vertical pipe ┌ \u250C upper left corner pipe ┐ \u2510 upper right corner pipe └ \u2514 lower left corner pipe ┘ \u2518 lower right corner pipe
The program / function will take 3 values of input, which can be gathered through function parameters or prompted to the user.
- Amount of ticks
- Screen width
- Screen height
Amount of ticks
For every tick, a piece of pipe will be added to the screen. Pipes will overwrite old pipe pieces if they spawn at the same position.
For example, take a screen of size 3x3
ticks == 3 ─┐ ┘ ticks == 4 ─┐ └┘ ticks == 5 │┐ └┘
Whenever a pipe exits the screen, as in the last example at 5 ticks, then a new pipe will spawn at a random border. For example:
ticks == 6 │┐ └┘ ─
The new pipe should have a 50% chance of being horizontal or vertical.
The screen width and height can be combined into a single value if that's preferrable in your language of choice. The screen width and height will always have a minimum value of 1 and a maximum value of 255. If your language of choice supports a console or output screen which is smaller than a 255x255 grid of characters then you may assume that the width and height will never exceed the boundaries of your console. (Example: Windows 80x25 cmd window)
The output of your program/function should be printed to the screen, or returned from a function. For every run of your program, a different set of pipes should be generated.
The following test cases are all random examples of valid outputs
f(4, 3, 3) │ ─┘ │ f(5, 3, 3) │ ─┘┌ │ f(6, 3, 3) ─│ ─┘┌ │ f(7, 3, 3) ── ─┘┌ │
Obviously, the more ticks that have occured, the harder it becomes to prove the validity of your program. Hence, posting a gif of your output running will be preferred. If this is not possible, please post a version of your code which includes printing the output. Obviously, this will not count towards your score.
- This is code-golf, shortest amount of bytes wins
- Standard loopholes apply
- If you use the unicode pipe characters in your source code, you may count them as a single byte
This is quite a hard challenge that can possibly be solved in many creative ways, you are encouraged to write an answer in a more verbose language even though there are already answers in short esolangs. This will create a catalog of shortest answers per language. Bonus upvotes for fancy coloured gifs ;)
Disclaimer: I am aware that Unicode characters aren't ASCII, but in lack of a better name I just call it ASCII art. Suggestions are welcome :)