John Scholes' Conway's Game of Life: Difference between revisions

Jump to navigation Jump to search
integrate prominent link into body text
(integrate prominent link into body text)
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Perhaps the most famous APL video is [[John Scholes]] explaining his own implementation of [[Conway's Game of Life]] in [[Dyalog APL]].<ref>[[John Scholes|Scholes, John]]. [https://www.youtube.com/watch?v=a9xAKttWgP4 "Conway's Game of Life in APL"]. 2009-01-26.</ref> In the video, Scholes develops the following [[dfn]] one step at a time:
[https://www.youtube.com/watch?v=a9xAKttWgP4 '''John Scholes' Conway's Game of Life''' video] is perhaps the most famous APL video. In it, [[John Scholes]] explains his own implementation of [[Conway's Game of Life]] in [[Dyalog APL]], where he, one step at a time, develops the following [[dfn]]:
<source lang=apl>
<source lang=apl>
       life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}
       life ← {⊃1 ⍵ ∨.∧ 3 4 = +/ +⌿ ¯1 0 1 ∘.⊖ ¯1 0 1 ⌽¨ ⊂⍵}
Line 12: Line 12:


The code here is written for [[Dyalog APL]]. It also works in [[ngn/apl]], and other [[Nested array theory|nested]] array languages allow similar implementations: see [[#Translations]].
The code here is written for [[Dyalog APL]]. It also works in [[ngn/apl]], and other [[Nested array theory|nested]] array languages allow similar implementations: see [[#Translations]].
In 2021, Conor Hoekstra remade the video with additional explanations.<ref>Hoekstra, Conor. [https://www.youtube.com/watch?v=pMslgySQ8nc APL + Game of Life = ❤️] in the [https://www.youtube.com/channel/UC1kBxkk2bcG78YBX7LMl9pQ code_report YouTube channel]. 2021-04-25.</ref>


== The Glider ==
== The Glider ==
Line 59: Line 61:
=== Visualising it ===
=== Visualising it ===


To make the pattern easier to see, we can use [[Bracket indexing|indexing]] to place a <source lang=apl inline>⌺</source> symbol where there's a cell and a <source lang=apl inline>·</source> otherwise, for example:
To make the pattern easier to see, we can use [[Bracket indexing|indexing]] to place a <source lang=apl inline>⌺</source> symbol where there's a cell and a <source lang=apl inline>·</source> otherwise, for example (note that <source lang=apl inline>⎕IO</source> is [[Index Origin]]):
<source lang=apl>
<source lang=apl>
       Show←{'·⌺'[⎕IO+⍵]}
       Show←{'·⌺'[⎕IO+⍵]}

Navigation menu