Game Of Life Multiplatform
Conway's Game of Life implemented as a Kotlin Multiplatform project for desktop and Android. Developed as a university programming project exploring KMP's shared logic and platform-specific UI capabilities.


A university programming-project implementation of Conway's Game of Life built with Kotlin Multiplatform, sharing the simulation logic — grid state, generation stepping, the cell ruleset — between a desktop build and an Android app rather than writing it twice. The project exists primarily to explore where KMP's shared-code boundary actually sits in practice: the cellular-automaton core is pure Kotlin with no platform dependencies, while rendering the grid and handling input are platform-specific UI layers on top, making it a small but concrete case study in what's worth sharing across targets and what isn't.
Architecture
graph TD Game["commonMain
Game.kt (pure Kotlin rules)"] --> Android["androidMain UI"] Game --> Desktop["desktopMain UI"] Timer["GameTimer"] -->|"onTick: step()"| Game Game -->|mutableStateOf per Cell| Android Game -->|mutableStateOf per Cell| Desktop
Under the hood
The cellular-automaton rules live once in commonMain and are shared verbatim by every platform target — only the rendering differs. Four rule variants (Conway 23/3, 3/3, 13/3, 34/3) are selectable at runtime.
when (rule) {
0 -> { // Conway (23/3)
if (p.isAlive() && (p.neighbors != 2 && p.neighbors != 3)) set(i, !c.state)
else if (p.isDead() && p.neighbors == 3) set(i, !c.state)
}
1 -> { // 3/3
if (p.isAlive() && p.neighbors != 3) set(i, !c.state)
else if (p.isDead() && p.neighbors == 3) set(i, !c.state)
}
2 -> { // 13/3
if (p.isAlive() && (p.neighbors != 1 && p.neighbors != 3)) set(i, !c.state)
else if (p.isDead() && p.neighbors == 3) set(i, !c.state)
}
3 -> { // 34/3
if (p.isAlive() && (p.neighbors != 4 && p.neighbors != 3)) set(i, !c.state)
else if (p.isDead() && p.neighbors == 3) set(i, !c.state)
}
else -> throw IndexOutOfBoundsException("There exists no rule with index $rule")
}