Claraman is a multiplayer game project around two concepts. A rule engine named Clara and event sourcing.
The running game can be found at https://bomberman.lambda-group.se/
Clara is a rule engine written in Clojure/Script.
Resources:
- http://www.clara-rules.org/
- https://www.youtube.com/watch?v=Z6oVuYmRgkk
- https://thesearch.space/episodes/2-ryan-brush-on-retaking-rules-for-developers
Events in the system tries to follow the CloudEvent specification. Take a look at Johan Halebys Occurent for nice documentation on event sourcing.
In this bomberman game all events are saved into a list, the list is called the event store. Each time the list updates the changes are sent through a reduce function together with the old game state. The reduce function updates the game state by taking the old game state and the new events and returns a new game state. In CQRS terms the game state would be called a read model. It’s a derived state used by the game to represent the current state of the game. The game is always reading from the game state and never does writes to it. To update the game state the app creates new events that are appended to the list in the event store.
+------------------+
| List with events |
+-------+----------+
|
|
↓
+-------+---------+ ------------
| Reduce function +------>( Game state )
+-----------------+ ------------
here is a handful of the libraries used in this project and what they do.
- component for orchestrating stateful server side components
- sente for websocket communication
- re-frame for single pages client application
Server setup is done with Ansible. Look in the ansible
folder for details.
Continuous delivery is made with help from CircleCi. CirclCi tests the code
and builds an artifact. CirclCi then ships the artifact to the server via SSH.
When the server gets the new artifact Systemd picks up the changes and
restarts the application with the new artifact.
Instructions on how to update dependencies.
clojure -Moutdated --write
- Starta a repl from command line
clojure -A:reveal:test:dev -m nrepl.cmdline --middleware '[vlaaad.reveal.nrepl/middleware]'
- Connect to the repl from Emacs with
cider-connect-clj
- Start a ClojureScript repl with
cider-jack-in-cljs
- Start Clj and Cljs repls with
cider-jack-in-clj&cljs