5
\$\begingroup\$

This question already has an answer here:

enter image description here

Wireworld is fun for the whole family! Your goal is to create a Wireworld implementation in the shortest amount of code possible.

A Wireworld cell can be in one of four different states, usually numbered 0–3 in software, modeled by colors in the examples here:

  • Empty (Black)
  • Electron head (Blue)
  • Electron tail (Red)
  • Conductor (Yellow)

As in all cellular automata, time proceeds in ticks. Cells behave as follows:

  • Empty → Empty
  • Electron head → Electron tail
  • Electron tail → Conductor
  • Conductor → Electron head if exactly one or two of the neighbouring cells are electron heads, or remains Conductor otherwise.

Your grid must be at least 20 by 20 and must follow the rules of Wireworld. The grid doesn't have to be colored, but make sure it follows these numbers/symbols:

  • Empty (0 or ' ')
  • Electron head (2 or 'H')
  • Electron tail (3 or 'T')
  • Conductor (1 or '_')
\$\endgroup\$

marked as duplicate by Peter Taylor code-golf Jul 3 '15 at 6:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    \$\begingroup\$ What does the implementation need to do? Take an input state onto the output state one tick later? \$\endgroup\$ – xnor Jul 3 '15 at 5:05
  • \$\begingroup\$ Also, beware that Mathematica and probably other languages have built-ins for cellular automata. \$\endgroup\$ – xnor Jul 3 '15 at 5:09
  • \$\begingroup\$ @xnor it needs to run on a clock and tick ever few seconds or so \$\endgroup\$ – phase Jul 3 '15 at 5:10
  • \$\begingroup\$ does the board wrap? \$\endgroup\$ – Maltysen Jul 3 '15 at 5:30
  • \$\begingroup\$ As this is an unusual duplicate case, I'm going to ask a question on Meta about it. \$\endgroup\$ – Peter Taylor Jul 3 '15 at 6:08