Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

kalah

Example kalah game implementation using Micronaut and virtual-thread actors.

Info

  • When the application receives a request to create a new game, it spawns a new GameActor — a virtual thread draining a per-game mailbox. After that, each game-related action is routed to the corresponding GameActor.
  • There is no persistence. Unknown game ids return 404; a failed message returns its error to the caller without killing the actor or losing game state (per-message error isolation, replacing the old supervisor's restart-with-a-fresh-board behavior).
  • Game rules are implemented as a plain Java chain of responsibility under the com.serdarormanli.kalah.rules package.
  • Default number of pits per player and number of stones per pit is configurable. They can be overridden in application.yaml.
  • Rest api served at localhost:8080/kalah by default.
  • Rest api has 3 resources.
  • /kalah POST creates new game returns board. Takes numberOfPitsPerPlayer and numberOfStonesPerPit as optional query parameters.
  • /kalah/{gameId} GET returns latest snapshot of game.
  • /kalah/{gameId}/indexOfPit/{indexOfPit} POST picks stones and distributes. Returns latest snapshot of the game.
  • There is a basic frontend served at localhost:8080 by default.
  • Registered games are never evicted — each holds one parked virtual thread plus a small Game object, which is cheap but unbounded; a long-running instance will accumulate memory for every game ever created.

Used Technologies

  • Java 25
  • Virtual threads — actor-per-game with mailboxes
  • Micronaut

About

Kalah game implementation using actors

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Used by

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /