A new crop of puzzle games is blurring the line between entertainment and education by putting players in the role of a virtual programmer. They also happen to be among the best puzzle games I've ever played.

People often think of computer programming as a dull and laborious activity, but writing your own code has more in common with puzzle games than you might guess. Puzzle games are built on presenting players with a series of problems and a set of tools to solve them. Programming is no different, except instead of lining up colored objects or pushing around blocks, you use variables, statements, and basic mathematical operations to reach the desired outcome.

That might still sound dull and laborious, but the games outlined below are among the richest and most rewarding puzzle games I've ever played. Why? Most puzzle games introduce a set of mechanics and then ply players with variations on the same theme. The best puzzle games, however, continually evolve their formulas, providing a steady stream of "a-ha" moments as you expand your understanding of the tasks at hand.

Suffice it to say, coding is an incredibly deep and complex activity – the possibilities for what you can do with even a basic programming language are as varied as the software applications and games you engage with every day. Turning that learning experience into an entertaining game is simply a matter of introducing the commands at your disposal in a gradual and understandable way, along with increasingly complex challenges to apply them to.

The games listed below do just that (though sometimes the learning curve may occasionally morph into a learning cliff). While all four games build off of the same principles, they differ in some significant ways.

Robozzle
Platform: iOS, Android, Web
While its simple visuals may not look like much, Robozzle provides an excellent introduction to coding because it doesn't require learning an actual programming language. Instead, players use arrows and colored tiles to teach their triangular robot how to navigate increasingly intricate paths and pick up stars. At first, the functions you program are straightforward (move forward three times, then turn right, etc.), but soon you'll be learning and employing more complex coding concepts like loops, stacks, and recursion. The Robozzle website allows players to create and share their own levels, which has resulted in thousands of engaging and devious challenges to take on. A similar game called LightBot has been developed with the goal of teaching programming to kids, but as such is far more simplistic.

Human Resource Machine
Platform: PC, Wii U
By far the most polished and professionally done game on this list, Human Resource Machine teaches basic coding through a charming art style that should be familiar to World of Goo fans (thanks to the overlapping talent of artist/designer Kyle Gabler). As with the subsequent two games on this list, Human Resource Machine tasks players with taking numbers and letters provided by the game (delivered to your inbox) and manipulating them to correspond to the desired outcome (which you drop off in your outbox). Like with Robozzle, the challenges gradually become more complex: Taking a number and doubling it is easy enough, but what happens when you have to multiply two numbers without a multiplication command? Or rearrange a stack of letters into a specific order? Unlike Robozzle, HRM has you compiling actual programming commands to add, subtract, copy, and jump your dutiful protagonist to victory. However, achieving the correct output is only half the challenge – as with real programming, you'll also want to optimize your code to make it as concise and fast as possible. HRM's drag-and-drop approach to coding can make sifting through complicated solutions more confusing than it should be, but the game contains a satisfying collection of puzzles to test your new-found coding wit.

Hacked
Platform: Android
Hacked was designed primarily to make coding easier on a mobile platform, and as such it provides the most true-to-life programming of any game on this list. Like Human Resource Machine, the game portion of Hacked requires you to take strings of inputs and manipulate them to produce the proper outputs. However, you'll be declaring variables, dealing with stacks, and using a variety of conditional statements just like real programmers in order to reach the proper solution. Hacked has a steep learning curve (the game states that some coding knowledge is required), but thankfully this step-by-step guide by web developer Andrew Johns should help bridge any gaps in your knowledge. Hacked also includes a freestyle mode that lets you program and share your own games with other players from within the app.  

TIS-100
Platform: PC
A fun alternative take on programming, TIS-100 tasks you with recoding a clunky old computer from the early '80s. Like Human Resource Machine and Hacked, manipulating inputs into the proper outputs is still the task du jour, but your resources are extremely limited – you only have a handful of commands at your disposal, and each programming "node" can only hold a few lines of code. Optimization is also rewarded, giving you a reason to revisit completed challenges in hopes of minimizing your lines of code and CPU usage. Of all the games on this list, TIS-100 has been the most rewarding; stringing together your bite-sized portions of code to solve complex problems is extremely satisfying, and conveys the elegance of well-written code. 

The four games listed above won't make you a coding master, but they do a good job of teaching you some of the fundamental concepts of programming. If your interest is piqued or you have a child who might be interested in programming, check out Code.org for a wealth of more education-focused games designed to teach coding, including lessons for specific programming languages like JavaScript and Python.