Game of Life functional in Kotlin
✓ Published0🌍 Public
BBastiTee
Last edited Aug 8, 2018
Created on Aug 8, 2018
This example demonstrates Conway’s Game of Life as a purely functional Kotlin implementation, rendering 100 generations of a small initial board pattern as console text output. The code defines a `step` function that computes the next generation using `mapIndexed` and a `neighboursAlive` helper, checking alive neighbor counts against the standard 2–3 survival and 3 birth rules. It uses `Stream.iterate` from the Java Streams API to generate the infinite sequence of boards, limiting it to 100 steps. The rendering approach prints each board via `toMultiLineString`, encoding live cells as “Ö” and dead cells as “†”.
AI-generated description