wireworld-in-emacs.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. title: Wireworld in Emacs
  2. date: 2017-03-10 17:01
  3. author: Christine Lemmer-Webber
  4. tags: emacs, wireworld, foss
  5. slug: wireworld-in-emacs
  6. ---
  7. <p>
  8. It is a truth universally acknowledged, that a hacker under the pressure
  9. of a deadline must be in want of a distraction.
  10. So it has been with me; I've a TODO list a mountain high, and I've been
  11. especially cracking under the stress of trying to get things moving along
  12. with <a href="https://www.w3.org/TR/activitypub/">ActivityPub</a>.
  13. I have a test suite to write, and it's turned out to be very hard,
  14. and this after several other deadlines in a row.
  15. I've also meant to blog about several things; say the talks I gave
  16. <a href="https://fosdem.org/2017/schedule/event/networkfreedom/">at
  17. FOSDEM</a> or
  18. <a href="https://archive.org/details/feb_2017-live_network_coding_8sync">
  19. at ChicagoLUG</a>.
  20. I've got a leak in my inbox that's been running for so long that the
  21. basement of my email has developed an undertow.
  22. So today, instead of getting what I knew I should be doing done,
  23. I instead went off and did something much more interesting, which
  24. is to say, I
  25. <a href="https://gitlab.com/dustyweb/wireworld-el">implemented
  26. Wireworld in emacs</a>.
  27. </p>
  28. <p class="centered">
  29. <img src="http://dustycloud.org/misc/emacs-wireworld.png" alt="Wireworld in emacs screenshot" />
  30. </p>
  31. <p>
  32. What is <a href="https://en.wikipedia.org/wiki/Wireworld">Wireworld</a>?
  33. It's a
  34. <a href="https://en.wikipedia.org/wiki/Cellular_automaton">cellular automaton</a>,
  35. not unlike
  36. <a href="https://en.wikipedia.org/wiki/Conway's_Game_of_Life">Conway's Game of Life</a>.
  37. Except with Wireworld, the "cells" in play are a bit more
  38. constrained... you have a set of wires, and electrons run along them,
  39. multiply, and die out, but the paths stay the same.
  40. The rules are very simple to implement
  41. (<a href="https://en.wikipedia.org/wiki/Wireworld#Rules">Wikipedia says
  42. all there is to know</a>).
  43. But you can build incredible things with it... even a
  44. <a href="https://www.quinapalus.com/wi-index.html">
  45. fully working computer</a>!
  46. </p>
  47. <p>
  48. Anyway, like many hacks, this one appeared out of boredom/distraction.
  49. I had long wanted to play with Wireworld, and I was reminded of it by
  50. <a href="https://codegolf.stackexchange.com/questions/88783/build-a-digital-clock-in-conways-game-of-life/">
  51. seeing this cool hack with a digital clock implemented in Conway's Game of Life</a>.
  52. It reminded me just how much I wanted to
  53. <a href="https://www.quinapalus.com/wi-index.html">
  54. try implementing that computer</a>,
  55. or even much simpler circuitry,
  56. but I had never been able to get started, because I couldn't find a
  57. working implementation that was easy for me to package.
  58. (I started packaging <a href="http://golly.sourceforge.net/">Golly</a>
  59. for <a href="https://www.gnu.org/software/guix/">Guix</a> but got stuck
  60. for reasons I can't remember.)
  61. I started thinking about how much I liked typing out ASCII art in Emacs,
  62. and how cool would it be to just "draw out" circuits in a buffer?
  63. I started experimenting... and within two hours, I had a working
  64. implementation!
  65. Two more hours later, I had a major mode with syntax highlighting
  66. and a handy C-c C-c keybinding for "advancing" the buffer.
  67. Live hacking in Emacs is amazing!
  68. </p>
  69. <p>
  70. More could be done.
  71. It would be nice to have a shortcut, say C-c C-s, that starts up a
  72. simulation in a new buffer and runs through the simulation automatically
  73. without clobbering your main buffer.
  74. (It could work the way M-x life does.)
  75. Anyway,
  76. <a href="https://gitlab.com/dustyweb/wireworld-el">the code is here</a>
  77. should you want to play around.
  78. </p>
  79. <p>
  80. Happy (circuit) hacking!
  81. </p>