- Created for December CIJUG Connect Four Code Off
- Install Java 8 JDK
- Install SBT
- Clone this GitHub repo
- Open a shell (command prompt) and navigate to project directory
- execute the following command:
sbt run
- Have fun!
- Scala
- Everything is immutable
- Uses Type Classes for printing the game state, giving instructions, and transitioning from one state to another.
- Decouples data and behavior
- Compartmentalizes logic per game state
- Implicit proof required in order to compile
- Use of types in place of primitives to prevent mistakes
- Value Classes erase to primitives at runtime
- Everything is values and only real side effects is printing in Main
- Game loop is tail recursive
- Functional looping rather than while or for statement
- No libraries
- Use specs2 for testing
- Tests run in parallel by default
- Has a Given When Then syntax but chose not to do that to save time
- Formatted source with scalafmt
- Can setup to auto-format on compile but didn't want to introduce plugin for simplicity
- Set up compiler settings so if basic warnings and bad practices used then will just not compile
- Set up Wart Remover (compiler linter) to catch other bad practices and prevent compilation if violated
- Could look at using state monad or indexed state monad possibly for state transitions
- Bad input goes back to original state with no really notifications
- Could use Validation from ScalaZ or Cats
- Could introduce packages and scope type creation to go through smart constructors
which provide errors or validations if the type can not be realized
- Could also use ScalaZ Tags
- Could also use refinement types
- Eliminate some of the boilerplate of pattern matching on sealed trait co-product with shapeless type class derivation
- Updating nested immutable collections is a bit painful
- Use Lens to update easier
- Still a little bit of primitive obsession with newlines and empty strings.
- Should make this a list of case classes and add the newlines in Main