A fully playable 2048 like game, running in the terminal, built entirely with pure functional programming principles in Haskell.
This project was developed to deepen my understanding of functional programming, immutable state management, and pure functions. It serves as a refactoring exercise, moving away from imperative memory management (C) to a declarative and type-safe architecture (Haskell).
Key Learnings & Architectural Choices:
- Pure Functions: The core game logic (moving, merging, generating elements)
- Terminal UI: Handled using
brickTUI library
- Smooth predictable terminal rendering
- Score tracking and FOV calculation
- Strict type safety preventing invalid moves
- Language: Haskell
- Build Tools: Cabal
- Libraries:
brick,random,vty
To build and play the game on your machine, ensure you have ghc and cabal installed.
- Clone the repository:
git clone https://github.com/RoNiN-shadow/k-game.git
cd k-game- Build the project:
cabal build- Run the game:
cabal run↑/Up Arrow- Move Up↓/Down Arrow- Move Down←/Left Arrow- Move Left→/Right Arrow- Move Rightq- Quit Game
