# Game of life... ish

**URL:** https://forum.makecode.com/t/game-of-life-ish/1884
**Category:** Show & Tell
**Tags:** javascript, game, graphics-and-math
**Created:** [April 30, 2020, 6:52am UTC](https://forum.makecode.com/t/game-of-life-ish/1884 "2020-04-30T06:52:28Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)
#### Post date: [April 30, 2020, 6:52am UTC](https://forum.makecode.com/t/game-of-life-ish/1884/1 "2020-04-30T06:52:28Z")

</div>

I know, I know… it’s been done several times already. … but here’s my take on a Game of Life simulation in makecode arcade:

> **[game-of-life-ish](https://arcade.makecode.com/26934-57867-01130-07317)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

**Controls:**

**D-pad** : move cursor  
**A** : toggle cell (hold while pressing directions to keep drawing)  
**B** : Start/stop simulation  
**Menu** : opens a list of preset layouts that you can choose from

**Notes** :  
[Conway’s Game of Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life) takes place on an infinite grid. I made no attempt to approximate that behavior. Cells on the boundary are highlighted yellow to indicate they’re not behaving like they would on a proper infinite grid.

I’m reading from / writing to the background image a lot. I have no idea if this is an anti-pattern.

I am fond of how I used the image editor to build/save the presets. That workflow on the development side was pretty nice.

This was my first makecode JS project. I’m still trying to figure out how to modularize my code; sorry if it seems poorly organized.

---

<div class="post-metadata">

### Author: ![jsea](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jsea](https://forum.makecode.com/u/jsea)
#### Post date: [April 30, 2020, 12:02pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/2 "2020-04-30T12:02:53Z")

</div>

Thanks - RIP Conway

---

<div class="post-metadata">

### Author: ![Blobiy](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Blobiy](https://forum.makecode.com/u/Blobiy)
#### Post date: [April 30, 2020, 6:22pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/3 "2020-04-30T18:22:43Z")

</div>

wait i’m so confused, who is conway, how do you play, is there points or a goal?

---

<div class="post-metadata">

### Author: ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)
#### Post date: [April 30, 2020, 6:48pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/4 "2020-04-30T18:48:33Z")

</div>

Ha. Sorry this is confusing! 😅 There’s already been a lot written about this, and if you’re interested you should definitely read some more about it, but I’ll give a shot at a brief explanation:

Conway was a mathematician (who recently passed away). He invented this “game” but it’s not really one that has score or points.

The “game” takes place on a grid (think of a piece of graph paper). You can fill in any cells (squares on the graph paper) you want.

The next step is to figure out the next generation. For each cell, you look at its **8 neighbors**.

If the cell you’re starting at is “alive” (filled in), it stays alive in the next generation if it has exactly **two** or **three** live neighbors (fewer than two and it dies from loneliness; more than three it dies from over crowding).

If the cell you’re starting from is “dead”, it comes to life in the next generation if it has exactly **three** live neighbors.

Once you’ve done this for every cell, you’re done. You’ve computed a new generation. You can repeatedly produce new generations as many times as you want.

As you can imagine, computers are pretty good at playing this game…

People have found some very interesting patterns (some of which I included in the Menu): some that are stable, or oscillate, or move across the grid, or produce new children… there are even some self-replicating patterns (though this grid is too small to showcase those).

In this version, you’re free to draw around on the grid ( **A button** will draw while the game isn’t running). You can play around with seeing how your own patterns evolve. Or you can load up one of the preconfigured ones and tweak it. There’s even one preset that will just randomly fill the grid with 30% live cells. The reset button will reset to whatever pattern you last selected (though it will lose any customizations you made).

If you find it fun, or interesting, or want to see some more examples of patterns, the wikipedia page is probably a good start: [https://en.wikipedia.org/wiki/Conway's\_Game\_of\_Life](https://en.wikipedia.org/wiki/Conway%27s_Game_of_Life)

---

<div class="post-metadata">

### Author: ![Blobiy](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Blobiy](https://forum.makecode.com/u/Blobiy)
#### Post date: [April 30, 2020, 7:16pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/5 "2020-04-30T19:16:03Z")

</div>

thx, it makes sense now

---

<div class="post-metadata">

### Author: ![jsea](https://avatars.discourse-cdn.com/v4/letter/j/a5b964/32.png) [@jsea](https://forum.makecode.com/u/jsea)
#### Post date: [April 30, 2020, 7:24pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/6 "2020-04-30T19:24:28Z")

</div>

Ah well, you can google John Conway mathematician. Covid took his life.

---

<div class="post-metadata">

### Author: ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)
#### Post date: [April 30, 2020, 7:28pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/7 "2020-04-30T19:28:50Z")

</div>

Nice! I made an implementation of Conway’s game of life a while back too, it’s under the `Graphics and Math` carousel (the codes very ugly though; I spent a while whittling it down / inlining things to get it to work properly on hardware, and should probably go back and clean it up / ideally some of the hackiness is no longer required).

I definitely like that yours has a cursor / can be customized in the simulator. It’s also nice that it’s zoomed in, rather than one cell == one pixel. Might steal some ideas from this version and update might a bit, if that’s all right with you 🙂.

---

<div class="post-metadata">

### Author: ![jacob\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jacob_c/32/1532_2.png) [@jacob\_c](https://forum.makecode.com/u/jacob_c)
#### Post date: [April 30, 2020, 8:05pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/8 "2020-04-30T20:05:59Z")

</div>

Absolutely!

Also, If when you’re looking at it, you have any feedback on the code, I’d love to hear it!

---

<div class="post-metadata">

### Author: ![Blobiy](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Blobiy](https://forum.makecode.com/u/Blobiy)
#### Post date: [May 4, 2020, 8:00pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/9 "2020-05-04T20:00:24Z")

</div>

R.I.P. John

---

<div class="post-metadata">

### Author: ![Adri314](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/adri314/32/182_2.png) [@Adri314](https://forum.makecode.com/u/Adri314)
#### Post date: [May 15, 2020, 2:58pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/10 "2020-05-15T14:58:28Z")

</div>

I love your menu with the different patterns. I while ago coded a version with blocks that starts with a random configuration treating each pixel on the screen as a cell and with toroidal boundary conditions. Here it is:

> **[Game of Life - Arcade](https://arcade.makecode.com/14248-10056-66949-53861)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![ggiscool](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/ggiscool/32/3431_2.png) [@ggiscool](https://forum.makecode.com/u/ggiscool)
#### Post date: [January 7, 2021, 4:15pm UTC](https://forum.makecode.com/t/game-of-life-ish/1884/11 "2021-01-07T16:15:43Z")

</div>

why did you have to die john, why??? 😭 😭 😭 😭 😭
