Skip to content

rbobillot/PureGameOfLife

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cats Friendly Badge

Pure Game Of Life

Game Of Life running in Terminal, done using Cats (having fun with the IO Monad)

Grid input and output characters are set in application.conf

Simply run and test the project with sbt run and sbt test

Otherwise, compile the project with sbt assembly, and then run it with java -jar or scala <gameoflife.jar> <grid.txt> [interval]

Example

This example will run a short GoL:

  • 8x5 cells grid, containing 5 living cells (Z shape)
  • 4 iterations (700ms refresh speed) that will produce an empty grid
sbt 'run src/main/resources/test.txt 700'

// or create a jar, so you dont load sbt the next time
// sbt assembly && scala target/scala-2.13/gameoflife.jar src/main/resources/rorschach.txt

Notes:

  • If an error is raised (invalid file...), a NonZero exit code is returned (sbt run will then return an error)
  • I could have used the Validated Applicative, I might add it later
  • I might create a more customizable GUI

Exemple Gif

GUI

You can also choose to run it with a simple Swing GUI, by setting it in application.conf

gui = true

pgol-gui-bw You can interact with the GUI, using the keyboard

Arrow keys : navigate left, right, up, down
Space bar  : toggle pause

I/O : zoom In/Out
+/- : zoom In/Out

N : toggle negative mode (b&w switch)

About

Game Of Life, the pure FP way

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages