https://github.com/mlange-42/ark
Ark -- Archetype-based Entity Component System (ECS) for Go.
https://github.com/mlange-42/ark
ecs entity-component-system go golang
Last synced: 3 months ago
JSON representation
Ark -- Archetype-based Entity Component System (ECS) for Go.
- Host: GitHub
- URL: https://github.com/mlange-42/ark
- Owner: mlange-42
- License: apache-2.0
- Created: 2025-02-18T17:43:07.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-05-15T14:28:21.000Z (5 months ago)
- Last Synced: 2025-05-15T15:32:54.342Z (5 months ago)
- Topics: ecs, entity-component-system, go, golang
- Language: Go
- Homepage: https://mlange-42.github.io/ark/
- Size: 793 KB
- Stars: 73
- Watchers: 3
- Forks: 3
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE-APACHE
Awesome Lists containing this project
- awesome-go - mlange-42/ark - - Archetype-based Entity Component System (ECS) for Go. ☆`145` (Game Development / Search and Analytic Databases)
- awesome-go - mlange-42/ark - - Archetype-based Entity Component System (ECS) for Go. ☆`85` (Game Development / Search and Analytic Databases)
README
[](https://github.com/mlange-42/ark)
[](https://github.com/mlange-42/ark/actions/workflows/tests.yml)
[](https://badge.coveralls.io/github/mlange-42/ark?branch=main)
[](https://goreportcard.com/report/github.com/mlange-42/ark)
[](https://mlange-42.github.io/ark/)
[](https://pkg.go.dev/github.com/mlange-42/ark)
[](https://github.com/mlange-42/ark)
[](https://doi.org/10.5281/zenodo.14994239)
[](https://github.com/mlange-42/ark/blob/main/LICENSE-MIT)
[](https://github.com/mlange-42/ark/blob/main/LICENSE-APACHE)
[](https://github.com/avelino/awesome-go)Ark is an archetype-based [Entity Component System](https://en.wikipedia.org/wiki/Entity_component_system) (ECS) for [Go](https://go.dev/).
It is the successor of [Arche](https://github.com/mlange-42/arche).——
[Features](#features) • [Installation](#installation) • [Usage](#usage) • [Tools](#tools)
## Features
- Designed for performance and highly optimized. See the [Benchmarks](https://mlange-42.github.io/ark/benchmarks/).
- Well-documented, type-safe [API](https://pkg.go.dev/github.com/mlange-42/ark), and a comprehensive [User guide](https://mlange-42.github.io/ark/).
- [Entity relationships](https://mlange-42.github.io/ark/relations/) as a first-class feature.
- Fast [batch operations](https://mlange-42.github.io/ark/batch/) for mass manipulation.
- No systems. Just queries. Use your own structure (or the [Tools](https://github.com/mlange-42/ark#tools)).
- World serialization and deserialization with [ark-serde](https://github.com/mlange-42/ark-serde).## Installation
To use Ark in a Go project, run:
```shell
go get github.com/mlange-42/ark
```## Usage
Below is the classical Position/Velocity example that every ECS shows in the docs.
See the [User Guide](https://mlange-42.github.io/ark/), [API docs](https://pkg.go.dev/github.com/mlange-42/ark) and [examples](https://github.com/mlange-42/ark/tree/main/examples) for details.
```go
package mainimport (
"math/rand/v2""github.com/mlange-42/ark/ecs"
)// Position component
type Position struct {
X float64
Y float64
}// Velocity component
type Velocity struct {
X float64
Y float64
}func main() {
// Create a new World
world := ecs.NewWorld()// Create a component mapper
// Save mappers permanently and re-use them for best performance
mapper := ecs.NewMap2[Position, Velocity](&world)// Create entities
for range 1000 {
// Create a new Entity with components
_ = mapper.NewEntity(
&Position{X: rand.Float64() * 100, Y: rand.Float64() * 100},
&Velocity{X: rand.NormFloat64(), Y: rand.NormFloat64()},
)
}// Create a filter
// Save filters permanently and re-use them for best performance
filter := ecs.NewFilter2[Position, Velocity](&world)// Time loop
for range 5000 {
// Get a fresh query
query := filter.Query()
// Iterate it
for query.Next() {
// Component access through the Query
pos, vel := query.Get()
// Update component fields
pos.X += vel.X
pos.Y += vel.Y
}
}
}
```## Tools
- [ark-serde](https://github.com/mlange-42/ark-serde) provides JSON serialization and deserialization for Ark's World.
- [ark-tools](https://github.com/mlange-42/ark-tools) provides systems, a scheduler, and other useful stuff for Ark.
- [ark-pixel](https://github.com/mlange-42/ark-pixel) provides OpenGL graphics and live plots via the [Pixel](https://github.com/gopxl/pixel) game engine.## Cite as
Lange, M. & contributors (2025): Ark – An archetype-based Entity Component System for Go. DOI: [10.5281/zenodo.14994239](https://doi.org/10.5281/zenodo.14994239), GitHub repository: https://github.com/mlange-42/ark
## License
Ark and all its sources and documentation are distributed under the [MIT license](./LICENSE-MIT) and the [Apache 2.0 license](./LICENSE-APACHE), as your options.