You live inside a terminal that is 80 characters wide. You are bored, so you decide to play dominoes. No, not the boring kind that look like Scrabble, the fun kind where you spend an hour setting them to watch them fall in a second.
In terminals, dominoes look like this:
| upright domino
\ left-tilted domino
/ right-tilted domino
__ fallen domino
As we all know, if a tilted domino touches an upright one, the second domino gets tilted as well. The only exception to this is if two tilted dominoes touch it:
|\ --> \\ /| --> // /|\ --> /|\
Adjust your terminal's gravitational constant so this transition takes 100 ms.
If a tilted domino is supported by another domino or the terminal's walls, its journey ends.
None of the tilted dominoes in
\||||____||||/__ /|\ /\ /|\ __\||||____||||/
(80 characters) will move, since the two outmost tilted dominoes are supported by the terminal's walls and all others are supported by other dominoes.
However, if the space in the tilting direction is empty, the domino falls down:
| \\ --> |__\ // | --> /__|
Terminal. Gravitational constant. You get the point…
Finally, there's a slight wind from the left, so right-tilted dominoes fall faster than left-tilted ones:
|/ \| --> |__\|
Task
Write a program/function that shows an animation of playing dominoes in a terminal.
Your code should do the following:
Read a string from input, representing the initial state of the dominoes.
This string will contain no more than 80 characters and consist solely of the dominoes described above and empty spaces.
Print the state and wait for 100 ms.
Transform the state as explained above.
If the state changed, go back to 2.
Additional rules
The length of the input string does not affect the terminal's width; even if the string is shorter than 80 characters, the walls of the terminal are still 80 characters apart.
Each time step 2 is executed, the state should get printed to the same location, overwriting the previous state.
Since some languages are incapable of waiting exactly 100 ms, feel free to wait any amount between 50 and 1000 ms.
Standard code-golf rules apply.
Examples
For the initial state
||\/||
print the following (one over the other):
||\/|| |\\//| \\\/// __\\//__
For the initial state
/||||\
print the following
/||||\ //||\\ ///\\\
For the initial state
/|||\
print the following
/|||\ //|\\
For the initial state
|/ \|/ \|/ \|/ \|
print the following:
|__\|__\|__\|__\|
For the initial state (80 characters)
\||||____||||/__ /|\ /\ /|\ __\||||____||||/
print the following
\||||____||||/__ /|\ /\ /|\ __\||||____||||/