Stream: contributing

Topic: ✔ Game of Life for website examples


view this post on Zulip Elias Mulhall (Nov 27 2023 at 22:41):

(oops, see https://roc.zulipchat.com/#narrow/stream/316715-contributing/topic/Game.20of.20Life.20for.20website.20examples/near/404511795)

view this post on Zulip Elias Mulhall (Nov 27 2023 at 23:03):

Zulip that's not what I was trying to do :pensive:

view this post on Zulip Elias Mulhall (Nov 27 2023 at 23:03):

Sorry for the noise y'all I'll have to repost after dinner

view this post on Zulip Hannes (Nov 27 2023 at 23:40):

I started working on an implementation of Conway's game of life in Roc, but got distracted by other things and didn't finish it :sweat_smile: interested to see what you post after dinner ;)

view this post on Zulip Luke Boswell (Nov 28 2023 at 00:04):

This is cool. I've got a WIP TUI graphics library which might be cool to use with this.

example-tui-3.gif

It's just using basic-cli, and I'm still working on the API but basically this is the above App

State : {
    screen : { width : I32, height : I32 },
    cursor : { row : I32, col : I32 },
}

init : State
init = {
    cursor: { row: 10, col: 10 },
    screen: { width: 0, height: 0 },
}

render : State -> List DrawFn
render = \state ->
    cursorStr = "CURSOR \(Num.toStr state.cursor.row), \(Num.toStr state.cursor.col)"
    screenStr = "SCREEN \(Num.toStr state.screen.height), \(Num.toStr state.screen.width)"
    [
        drawCursor "+",
        drawText cursorStr { row: state.screen.height - 2, col: 2 },
        drawText screenStr { row: state.screen.height - 1, col: 2 },
        drawBorder "*",
    ]

view this post on Zulip Elias Mulhall (Nov 28 2023 at 00:23):

So here's the thing I originally shared and then accidentally deleted :laughter_tears:
https://gist.github.com/mulias/0007046725a6ca5500a35c125f033196

view this post on Zulip Elias Mulhall (Nov 28 2023 at 00:29):

I made a Game of Life sim to demo Array2D, with the thought being it would be more interesting than a "here's how to use some functions from the package" example. I'm on the fence if it's a good demo for the package, since it's a bit long and doesn't show off the package as clearly as it could.

Would this be a good example to add to the website? We had talked about adding something related to 2d data before AoC, but I'm wondering if it makes more sense to add this example to the Array2D repo, link that repo on roc-awesome, and encourage AoC people to look there for resources.

view this post on Zulip Luke Boswell (Nov 28 2023 at 00:40):

My thoughts are this would be a good example for the package, and I would love to add to roc-awesome.

view this post on Zulip Notification Bot (Nov 28 2023 at 02:27):

Elias Mulhall has marked this topic as resolved.

view this post on Zulip Luke Boswell (Nov 28 2023 at 02:49):

Added to roc-awesome. :hearts:

view this post on Zulip Anton (Nov 28 2023 at 09:51):

Game of Life is definitely something I'd like to add to the examples repo as well.


Last updated: Jul 06 2025 at 12:14 UTC