this post was submitted on 23 Mar 2024
5 points (100.0% liked)

Kotlin

665 readers
2 users here now

Kotlin is a statically typed programming language for the JVM, Android, JavaScript, and native.

Subreddit rules:

Resources:

founded 1 year ago
MODERATORS
 

I've had a long time fascination with Conway's Game of Life, and with the Sigbla APIs starting to stabilize I thought it would be fun to play around a bit and implement it as an example.

You can find the Conway example code here, and it should hopefully, even if you're unfamiliar with Sigbla, be fairly straight forward to understand.

It's using various core features, such as views, batching, transformers and cloning, with about 100 lines of code to get it all working. It's not really what I would envision Sigbla being used for, but it's a fun little example..

Conway's Game of Life in Sigbla

top 3 comments
sorted by: hot top controversial new old
[–] breadsmasher@lemmy.world 4 points 7 months ago (1 children)

interesting! Hadnt seen sigbla before - nice use.

Just curious,


// Add some logic to detect when we're stuck in a loop
boards.add(conway.map { true in it }.toList().hashCode())

… 

    if (boards.size < 5) {
        // Stuck in loop, add some randomness

What do you mean with stuck in a loop? Is it where the game reaches a state where its cycling continuously through the same variations repeatedly?

[–] the_ocs@lemmy.world 2 points 7 months ago

Yep, exactly that.

[–] lthlnkso@programming.dev 2 points 7 months ago

Neat! I love Conway's Game of Life. Something very zen watching it and thinking about it. I was surprised to see Conway say that he's not really a fan of the Game of Life himself.