Simulate the Wireworld cellular automaton Wireworld is a cellular automaton that was designed to be resemble electrons flowing through wires. Its simple mechanics allow the construction of digital circuits.  It has even permitted the construction of an entire computer.

Your mission is to create the shortest Wireworld implementation in your language of choice.

Each cell in the grid has one out of four states.  The four states are "blank," "copper," "electron head," or "electron tail."


A blank cell will always remain a blank cell
An electron head will always become an electron tail
An electron tail will always become copper
A copper cell will become an electron head iff exactly one or two out of its eight neighbors are electron heads, otherwise it will remain copper


This competition will have a similar style to the Shortest Game of Life competition, but with a few changes. 


The grid must be at least 40 by 40 cells
The edges of the grid must NOT wrap around (not a torus). Treat cells outside of the field as being constantly "blank."
It must be possible for the users to enter their own starting configuration.
Staring at blank screens is not fun.  The program must visually display the simulation as it is running.


This is code golf,  fewest bytes wins.
APL, Dyalog (131)

{h t c←1↓⍵∘=¨F←' htc'⋄⎕SM∘←1 1,⍨⊂N←F[1+⊃+/H h(t∨c≠H←c∧S↑1 1↓1 2∊⍨⊃+/+/K∘.⊖(K←2-⍳3)∘.⌽⊂¯1⌽¯1⊖h↑⍨2+S←25 79)×¨⍳3]⋄∇N⊣⎕DL÷4}↑{79↑⍞}¨⍳25


The output is displayed in the ⎕SM window. The simulation runs endlessly. The grid is 79x25 because that's the default size of the ⎕SM window. The electron head is h, tail is t, copper is c. The program reads the starting configuration from the keyboard as 25 lines. 

Explanation:


↑{79↑⍞}¨⍳25: read the 79x25 grid
h t c←1↓⍵∘=¨F←' htc': get three matrices, one with the heads, one with the tails and one with the copper. Also set F to the string ' htc'.
⎕SM∘←1 1,⍨⊂N←F[1+⊃+/...×¨⍳3]: The "..." part is a vector of length three, where the elements are matrices showing the new heads, tails, and copper respectively. The heads are multiplied by 1, the tails by 2, and the copper by 3, then we sum these matrices together and add one, giving a matrix of indices into F. N becomes the new state, in the same format as the input, and it is shown on the ⎕SM screen starting from the top-left corner. 
¯1⌽¯1⊖h↑⍨2+S←25 79: Add a border of blanks to h by growing it by two rows and columns, then rotating it one right and one down.
⊃+/+/K∘.⊖(K←2-⍳3)∘.⌽⊂: Rotate the matrix in all eight directions and then sum the resulting matrices together, giving the amount of neighbours that are heads on each position.
1 2∊⍨: Set only those positions to 1 which have 1 or 2 neighbours.
S↑1 1↓: Remove the border we added earlier.
H←c∧: The new heads are all those copper cells that have 1 or 2 head neighbours.
t∨c≠H: The new copper cells are all old tails, and all old copper cells that have not become heads.
H h(...): The new heads are H as calculated above, the new tails are the old heads, and the new copper cells are as calculated above.
∇N⊣⎕DL÷4: Wait 1/4th of a second, then run the function again on N.