Microsoft Research today launched Code Hunt, a browser-based game for anyone interested in learning how to code by playing. The premise is straightforward: the player must write code to advance in the game.

The built-in tutorial introduces you to the game:

Greetings, program! You are an experimental application known as a CODE HUNTER. You, along with other code hunters, have been sent into a top-secret computer system to find, restore, and capture as many code fragments as possible. Your progress, along with your fellow code hunters, will be tracked. Good luck.

Code Hunt uses puzzles, which players explore by means of clues presented as test cases, and encourages players to iterate on their code to “capture” it. Their work is then scored depending on the elegance of their solution, and players are encouraged to continue on to the next challenge.

code hunt Microsoft Research launches Code Hunt, an educational Web game for learning programming

Instead of presenting you with a problem and comparing your solution to a set of fixed test cases, Code Hunt presents an empty slate and a set of constantly changing test cases. It thus teaches coding as a side consequence of solving a problem by matching inputs and outputs, Microsoft explains.

Let’s be honest, learning certain aspects of programming can often be a long and arduous journey. Code Hunt aims to make the boring parts fun.

Code Hunt is based on Pex, Microsoft Research’s implementation of dynamic symbolic execution (analyzing a program to determine what inputs cause each part of a program to execute), and runs on Microsoft Azure. Researchers Nikolai Tillmann, Judith Bishop, R. Nigel Horspool, Daniel Perelman, and Tao Xie also released a paper describing what they learned while developing Code Hunt.

Here is the abstract:

Learning to code can be made more effective and sustainable if it is perceived as fun by the learner. Code Hunt uses puzzles that players have to explore by means of clues presented as test cases. Players iteratively modify their code to match the functional behaviour of secret solutions.

This way of learning to code is very different to learning from a specification. It is essentially re-engineering from test cases. Code Hunt is based on the test/clue generation of Pex, a white-box test generation tool that uses dynamic symbolic execution. Pex performs a guided search to determine feasible execution paths.

Conceptually, solving a puzzle is the manual process of conducting search-based test generation: the “test data” to be generated by the player is the player’s code, and the “fitness values” that reflect the closeness of the player’s code to the secret code are the clues (i.e., Pex-generated test cases).

This paper is the first one to describe Code Hunt and its extensions over its precursor Pex4Fun. Code Hunt represents a high-impact educational gaming platform that not only internally leverages fitness values to guide test/clue generation but also externally offers fun user experiences where search-based test generation is manually emulated. Because the amount of data is growing all the time, the entire system runs in the cloud on Windows Azure.

You can read the full document yourself at the link below.

Code Hunt: Searching for Secret Code for Fun (PDF)

See also – Microsoft Research reveals 3D browser SurroundWeb that displays content across multiple surfaces in a room and Microsoft Research built a smart elevator that uses AI to figure out what floor you’re going to

Top Image Credit: Robert Scoble