Chess Engine in R
Pushing R Shiny beyond its statistical roots to model a complex, rule-based system from first principles.

After watching the AlphaGo documentary, I became obsessed with how complex systems are represented mathematically. Coming from a Mechanical Engineering background, I wanted to treat the rules of Chess like a physical assembly-building the 'gears' of the logic from scratch in R to see if a tool built for statistics could handle a purely stateful UI game.
The most significant hurdle was mapping the recursive logic of king-safety. Every move requires simulating a temporary board state to ensure the king isn't left in check. As a self-taught programmer, solving this using matrix evaluations within Shiny’s single-threaded reactive loop was a massive lesson in how logic and performance intersect.
I would shift from an S3 object-oriented approach to R6 classes to better encapsulate piece behaviors, similar to how I'd model individual components in an engineering project. I'd also offload the move-generation to C++ via Rcpp to allow for a proper AI opponent without freezing the browser.