Category Archives: Game Development

Game Development: Links, News, Resources (6)

Previous Post

Building a Real-Time Location-Based Urban Geofencing Game with, Redis, Node.js and Sinatra Synchrony
How we planned, built and tested a truly real-time location-based game with, Redis, Node.js, and what we learned along the way.

Light Table
An Open Software project in San Francisco, CA by Chris Granger

ibdknox / live-cljs
a clojurescript version of bret victor’s editable game

Bidirectional binary streams with WebSocket

Graphwar Tutorial
Graphwar is an artillery game in which you must hit your enemies using mathematical functions.

Game development company

Rapid game development
Chilly Framework is a platform for HTML5 game development.

Basic Programming and Game Development with Scratch

Achieving Performance: An Approach to Optimizing a Game Engine

robashton / MolyHole

Node.js experiment: MMO Asteroids

Will the Next Generation of Top Guns Be Gamer Geeks? The Unmanned X-47B Makes Its First Flight

Kinect Star Wars

The life of a Sim in SimCity

Spaceship Pilot
Node.js, accelerometer, HTML5

Battlefield Simulator

Zynga compra la compañía OMGPOP por 180 millones de dólares

Learning Python: Child’s Play with RUR-PLE!

Lessons learned building a multiplayer game in NodeJS and WebGL

cocos2d is a framework for building 2D games, demos, and other graphical/interactive applications. It is built over pyglet. It provides some conventions and classes to help you structure a "scene based application".

C# y OpenGL (Parte I: Inicialización de OpenGL)

SharpGL: A C# OpenGL Class Library

My Links

Keep tuned!

Angel “Java” Lopez

Game Development: Links, News, Resources (5)

Previous Post
Next Post

Learn OpenGL and C#

The Open Toolkit is an advanced, low-level C# library that wraps OpenGL, OpenCL and OpenAL. It is suitable for games, scientific applications and any other project that requires 3d graphics, audio or compute functionality.

The Tao Framework
The Tao Framework for .NET is a collection of bindings to facilitate cross-platform game-related development utilizing the .NET platform.

JBullet – Java port of Bullet Physics Library

Bullet Physics Library

Aaron Dignan: How to Use Games to Excel at Life and Work
Real life isn’t always satisfying, but games almost always are. So how can we take the principles that make Angry Birds so addictive and apply them to work? Games researcher and author Aaron Dignan schools us at the 99% Conference.

adgeville is the world’s first behavior platform. We bring the best of gamification, social networking, reputation, and behavior analytics to any brand’s web and mobile experiences.

Initial Results From Co-operative Co-evolution
for Automated Platformer Design
We present initial results from ACCME,A Co-operative Co-evolutionary
Metroidvania Engine, which uses co-operative co-evolution to automatically evolve
simple platform games. We describe the system in detail and justify the use of
co-operative co-evolution.

Artificial intelligence project builds video games from scratch
A project from Imperial College in London puts together whole video games …

Building a multiplayer HTML5 game using Node,

Es un motor para hacer videojuegos de manera sencilla desde C++

hugoruscitti / sbfury
Shaolin’s Blind Fury

Video: Inventing on Principle

Connect With Your Creation Through a Real-Time Editor

Pygame is a set of Python modules designed for writing games.
Pygame adds functionality on top of the excellent SDL library.

Pilas Engine

Ruby for Kids

Is 2012 the Year for Gamification?

Wooga, A Case Study In No-Cash Bonus Culture

Lisp REPL in Vendetta Online

Vendetta Online

Asteroids, C#, 3D and OpenGL

My Links

Keep tuned!

Angel “Java” Lopez

Game Development: Links, News, Resources (4)

Previous Post
Next Post

Game development for fun, for profit. Exercises for our neuron.

Screencast: Coding Conway’s Game of Life in Ruby the TDD Way with RSpec

Ric-rac-roe in a soup of technologies
It all started with a desire to experiment a few things: Sinatra, Shoes, and the context testing framework. So I decided to write a simple application – the classic tic-tac-toe game. I ended up with 3 interfaces:
command line interface (cli)
web app (using Sinatra)
GUI desktop app (using Shoes)

Empresas de videojuegos pisan cada vez más fuerte en el país y buscan sumar desde ingenieros hasta músicos
Hace una década era una industria inexistente en la Argentina. Hoy, sin embargo, cuenta con 65 compañías, que sufren el déficit de mano de obra calificada y buscan perfiles de los más variados e insólitos. Conozca este mundo por dentro

Developing MMO Game Servers in PHP and JavaScript
Theory of Everything – an MMORPG written in CoffeeScript on node.js and HTML5/CSS3/WebGL

MMO server/client test

Javascript browser MMORPG [closed]


TileGen – Mystalia MMORPG Engine
Using PHPGD and called from Node.js (argv) we can dynamically create tilesets for each map to reduce load time.

An Interview with Rob Evans of Isogenic Engine: Building Real-Time, MMO Games with HTML5 and Node.js

NodeJS Pokemon: MMO iPad, iPhone, Chrome, Safari Card Game

NowJs, Multiplayer Map example

HTML5 Canvas MMORPG Games using Node.js and Nowjs

Multi-User Dungeon Definition Language

The MUDDL programming language, “Multi User Dungeon Definition Language”, is a domain-specific language for creation of text-based multi-user virtual worlds, i.e. MUDs.

Multi-User Dungeon, or MUD (referred to as MUD1, to distinguish it from its successor, MUD2, and the MUD genre in general) is the first MUD and the oldest virtual world in existence
…In 1980 Roy Trubshaw created MUD version 3 in BCPL (the predecessor of C), to conserve memory and make the program easier to maintain…
(ajlopez: I wrote programs in BCPL 😉

What Is a MMORPG?
MMORPG stands for massively multiplayer online role playing game, a type of massively multiplayer online game (MMOG). An MMORPG is a computer-based role playing game (RPG) which takes place in an online virtual world with hundreds or thousands of other players. In the game, a player uses a client to connect to a server, usually run by the publisher of the game, which hosts the virtual world and memorizes information about the player.
C# for Gaming: AltDevConf This Weekend

Rediscover the Early Days of Video Gaming using the Arduino Single-Board Computer

Using modern computing horsepower to stretch retro graphics hardware

Kinect for Windows SDK
Kinect For Windows Now Available
LOGO: Videojuego del Tetris

The Reality of HTML5 Game Development and making money from it
1991 Summer CES

Microsoft’s real-world 3D ‘Cut the Rope’ lets fans in London ‘jump’ into the game
Command and Conquer HTML5

Zynga buys four mobile gaming companies

My links

Keep tuned!

Angel “Java” Lopez

Game Development: Links, News, Resources (3)

Previous Post
Next Post

Recently, I was working on isometric games using HTML5 canvas. There is a lot ideas to implement (distributed game processing, artificial intelligence, etc.). Now, more links I found interesting about game development:

Kinect Is Coming to Windows Feb 1

Cut the Rope

What 2012 holds for social gaming

Asteroides : Codea Game – iPad 2


Gamification is Productivity, NOT (Just) Fun and Games

Corona SDK, una herramienta de desarrollo para iOS, Android y Kindle Fire

Game Developer Meets Demand and Prepares for Success with Scalable Cloud Solution

Writing an iPhone Game Engine (Part 7- Postmortem)

Platform Updates for Games Developers

QuakeCon 2011 – John Carmack Keynote

It’s ready when it’s ready, dammit!

Parallel Implementations
by John Carmack

Static Code Analysis
by John Carmack

Creating a Multiplayer Game with Sockets in C#

Canvas Tutorial

Gamification’s Three Disciplines

MonoGame: XNA multi-plataforma

Indie game Minecraft receiving over 240 million logins every month

Windows Azure Tookkit for Social Games 1.1 RELEASED

ThreeNodes.js: A Visual WebGL Scene Editor

The making of the Xbox: How Microsoft unleashed a video game revolution (part 1)



NGD and Regnum Online: past, present, and future

NGD Studios’ Andrés Chilkowski on Bunch of Heroes, Regnum Online & Designing Game Engines

NGD Studios

Anatomy of a Windows Phone Game Project

Erlang, the big switch in social games

Kinect unleashed for commercial Windows apps

Duck Hunt via HTML5 + JavaScript
with level creator

My Links

Keep tuned!

Angel “Java” Lopez

Game Development: Links, News, Resources (2)

Previous Post
Next Post

I’m working on my Game Server (Javascript/NodeJs), and preparing my next Node.js talk. Some links related to Game Development:

Logic in Games

Scratch Curriculum Guide Draft
This Scratch curriculum guide provides an introduction to creative computing with Scratch, using a design-based learning approach.

JSNES A Javascript NES emulator

Bye Bye Brain, first game on Windows 8

Writing Tetris in Clojure


gerad / lazeroids-node
massively-multiplayer html5 asteroids

Social Gaming Powered By Windows Azure

NodeJS on Windows Azure

Create a networked tic-tac-toe game for Android


What this Indie developer needs

Games in Google+: fun that fits your schedule

Stepping Onto the Google+ Platform

Google I/O 2011: Beyond JavaScript: Programming the Web with Native Client


The Best 30 HTML5 games

QuakeCon 2011 – John Carmack Keynote

NowJs for Node
NowJS creates a magic namespace “now”, accessible by server and client
Functions and variables added to now are automatically synced, in real-time
Call client functions from the server and server functions from client

HTML5 Canvas Demo: Tic-Tac-Toe

Coding4Fun’s ScriptTD
ScriptTD is an open source tower defense game engine for Windows Phone that allows non-developers to create TD games by changing settings, sounds, and graphics.

Orkis, a node.js multiplayer tetris

Infinite Mario in HTML5 JavaScript – using Canvas and Audio elements

Architecture of Tankster– Scale (Part 2)

WAT is to Social Gaming, as Windows Azure is to…

Architecture of Tankster – Introduction to Game Play (Part 1)

Episode 52 – Tankster and the Windows Azure Toolkit for Social Games

Each day a little more #gamedev love

simonguest / flagmatch
A flag matching game for WP7 demonstrating MVVM

Microsoft tailors Azure cloud services to social game developers

My Links

Keep tuned!

Angel “Java” Lopez

Computer Go: Links, News And Resources (2)

Previous Post

More links about this hard problem in Artificial Intelligence: play the game of Go.

In an Ancient Game, Computing’s Future
EARLY in the film ”A Beautiful Mind,” the mathematician John Nash is seen sitting in a Princeton courtyard, hunched over a playing board covered with small black and white pieces that look like pebbles. He was playing Go, an ancient Asian game. Frustration at losing that game inspired the real Mr. Nash to pursue the mathematics of game theory, research for which he eventually won a Nobel Prize.

What’s black, white and can stump computers?

Handicap for smaller board sizes

Two Representative Computer Go Games

Database pattern search software

Number of legal Go positions

Zen computer Go program beats Takemiya Masaki with just 4 stones!

Orego is a multi-year project to develop programs to play the classical Asian game of Go.

ICGA Tournaments
Tournaments between computer programs: chess, draughts, checkers, Go, backgammon, and more

Moyoman is an open-source Go playing program written in Java. The code for move generation is broken up into units called modules. The interfaces for these modules are well-defined, and correspond to standard Go concepts such as shape, the opening, or life and death. There can be multiple implementations of the same module type. The idea is to distribute the design decisions among many different developers. We are actively looking for new developers to write modules.

Computer Go Group at University of Alberta

Computer Go Bibliography

Fuego, GNU Go and other builds for Windows

Computer Go Research
Our Go program and framework Fuego. First computer program to win a 9×9 game on even against a top-ranked human player.

Monte Carlo Tree Search
Monte Carlo Tree Search (MCTS) is the basis of all state of the art Go programs, including Fuego. In our research, we also investigate Monte Carlo techniques in planning, and the close connections between Reinforcement learning and MCTS.

Latest Advance in Artificial Intelligence: Computer Wins a Game Against a Go Master

Cracking GO
Brute-force computation has eclipsed humans in chess, and it could soon do the same in this ancient Asian game

GoGui is a graphical user interface to programs that play the board game Go and support the Go Text Protocol such as GNU Go.

MoGo: a Grid5000-based software for the Game of Go

The Game of Go: A Programmer’s Perspective

Go news and sensations

Windows HPC: Playing GO on Surface against a Cluster

GTP engines
A go engine is a software that plays go. A GTP go engine is a software that plays go and dialogs through the "Go Text Protocol" with another software like GoGui or Dariush.

Dutch Supercomputer Beats Human at Go

Smart Games

My Links

Keep tuned!

Angel “Java” Lopez

Computer Go: Links, News and Resources (1)

Next Post

Computer Go is one of my favorites topics. A challenge for game artificial intelligence, the ancient game is enjoyable by itself, and I recommend you to learn how to play it. Some of my links about the topic of computer go:

(citeseer access needs a free account, you must register)

Go (圍棋 weiqi in Chinese, 囲碁 igo in Japanese, 바둑 baduk in Korean, common meaning: “encircling game”), is an ancient board game for two players that originated in China more than 2,000 years ago. The game is noted for being rich instrategy despite its relatively simple rules.

Computer Go is the field of artificial intelligence (AI) dedicated to creating a computer program that plays Go, a traditional board game.

Computer Go
Computer Go is one of the biggest challenges faced by game programmers. This survey describes the typical components of a Go program, and discusses knowledge representation, search methods and techniques for solving specific subproblems in this domain.

Computer Go: an AI Oriented Survey
Since the beginning of AI, mind games have been studied as relevant application fields. Nowadays, some programs are better than human players in most classical games. Their results highlight the efficiency of AI methods that are now quite standard. Such methods are very useful to Go programs, but they do not enable a strong Go program to be built. The problems related to Computer Go require new AI problem solving methods.

Global and Local Game Tree Search

The Move Decision Strategy of Indigo
This paper describes the move decision strategy of Indigo. By using the example of Indigo, the paper shows that the move decision process of a Go program can be very different from the processes used in other games with lower complexity than the complexity of Go, even if the basic modules are conventional (move generator, evaluation function and tree search). Indigo uses them in a specific way, adapted to computer Go, which may be of interest for researchers on other mind games as complex as Go.

Using Hard And Soft Artificial Intelligence Algorithms To Simulate Human Go Playing Techniques

Associating Domain-Dependent Knowledge and Monte Carlo Approaches within a Go Program

Bruno Bouzy Papers

Pursuing abstract goals in the game of Go

A positional Judgment System for Computer Go
Computer Go offers researchers a new challenge and opens up a very wide scope of possibilities for artificial intelligence. In a computer Go program, the most important element is a positional judgment system. Following the methods of human Go experts, we designed and implemented a new model of positional judgment for computer Go.

Value Function
Any strong Computer Go program must compute a win/lose value function as an intermediate step, that corresponds directly to the expected result at the end of the game (win, lose or draw).

The Question Hypothesis
All useful features of a state in Go can be interpreted as answers to questions about the current and future value of observations.

The value-function hypothesis
All efficient methods for solving sequential decision problems determine (learn or compute) value functions as an intermediate step.

Pattern Matching

On Meta-Game Approaches to Computer Go
Meta-game approaches are studied through the design of the Go playing program INDIGO. Computer Go is a challenge for AI and the machine still remains weak compared to humans in the game of Go. This difference is used to try new technics as such as the Metagame technique discussed in this paper. A conceptual structure and a notion of Conway’s game theory are described in order to show four approaches. Each approach is presented to show its method using games, its computational cost, its precision and its Meta-game’s utilisation.

Mathematical Morphology Applied to Computer Go
This paper shows how mathematical morphological operators can be applied to computer go. On one hand, mathematical morphology is a very powerful tool within image processing community. On the other hand, the Zobrist’s model is well-known within the computer go community for its “influence” recognition. We present a model, derived from the closing operator of mathematical morphology and from the Zobrist’s model, which yields very good results for “territory” recognition.

Computer Go
An international bulletin devoted to the generation and exchange of ideas about Computer Go

Computer Go: El gran problema de AI

Computer Go Programming

Computer Go Algorithms

Benson’s Definition of Unconditional Life

MultiGo is designed to view/edit Smart-Go format(SGF) go game file. It also supports other popular file format including *.BDX, *.NGF, *.GOS, *.GIB, *.UGF, *.GO. You can easily navigate through the game and branches, add/remove markers and comments, create or edit your own branches. You could use MultiGo to play with GNU Go, or even record/play go video.

Compendium of Rules for Wei-Qi (Go, Baduk)
GO: An hour to learn; a lifetime to master.

Go Variants
Here are some variants of our noble game, in case you want to do something else.

Computer Go/Writing a Go Engine

BiGo Software

Game Theories and Computer Go

The program GoTools and its computer-generated tsume go database

Forward Pruning and Other Heuristic Search Techniques in Tsume Go

Eyespace Values in Go

The complexity of Go

Computer Go as a Sum of Local Games: An Application of Combinatorial Game Theory

The Integration of A Priori Knowledge into a Go Playing Neural Network

Lambda-Search In Game Trees – With Application To Go

Race to Capture: Analyzing Semeai

Experiments in Computer Go Endgames
Recently, the mathematical theory of games has been applied to late-stage Go endgames [Berlekamp and Wolfe 1994; Wolfe 1991]. Based upon this theory, we developed a tool to solve local Go endgames. We verified all exact game values in [Wolfe 1991] and analyzed some more complex positions. We extended our method to calculate bounds for positions where optimal play depends on Ko. Our program Explorer uses this tool to play full board endgames. It plays a nontrivial class of endgame positions perfectly. In a last section we discuss heuristic play for a wider range of endgames.

Generation of Patterns With External Conditions for the Game of Go

Metarules to Improve Tactical Go Knowledge

Metaprogramming Domain Specific Metaprograms

Tristan Cazenave Articles

Honte, a Go-Playing Program Using Neural Nets

A small Go board Study of metric and dimensional Evaluation Functions
The difficulty to write successful 19×19 go programs lies not only in the combinatorial complexity of go but also in the complexity of designing a good evaluation function containing a lot of knowledge. Leaving these obstacles aside, this paper defines very-little-knowledge evaluation functions used by programs playing on very small boards. The evaluation functions are based on two mathematical tools, distance and dimension, and not on domaindependent knowledge.

The go-playing program called Go81

Developments On Monte Carlo Go

A Learning Architecture For The Game Of Go
In this paper, a three-component architecture of a learning environment for Go is sketched, which can be applied to any two-player, deterministic, full information, partizan, combinatorial game. The architecture called HUGO has natural and human-like reasoning components. Its most abstract component deals with the selection of subgames of Go. The second component is concerned with initiative. The notion of gote no sente (a move that loses initiative but creates new lines of play that will hold initiative) is formalized. In the third component, game values are computed with a new kind of – algorithm based on fuzzy, partial ordering. Our approach leaves some valuable control parameters and oers ways to apply further machine learning techniques.

My Links

More links are coming.

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 8) Adding Node.Js

Previous post

In the previous post, we explored the game processing in the current Windows Azure Toolkit for Social Gaming. Now, it’s time to add Node.js as game server, in our Tic Tac Toe simple game.

All the Game Service client code is game agnostic. And it can be changed to use another services. In this post, I will change the play move processing to be directed to a Node.js instance.

You need to download the node folder from my GitHub:

Then, follow these steps:

1 – Download and setup the Windows Azure Toolkit for Social Gaming version 1.1.1, from:

1 – Install Node.js for Windows, from

2 – Change to the server folder, and execute this command line:

npm install

The library is downloaded and installed in a node_modules subfolder:

This is the folder tree:

3 – Start the node.js server:

node gameex.js

The server starts to listen:

4 – Copy the client folder to your SocialGaming.Web project folder. Web.config, BaseController.cs, TicTacToeController.cs files will be replaced. New files will be added: Scripts\game\GameServiceNodeJs.js, Areas\Samples\Views\TicTacToe\NodeJs.cshtml.

5 – Open the solution in Visual Studio 2010 (run as administrator) and add these files to SocialGaming.Web project. The new Game Service for Node.js:

The new TicTacToe view that uses Node.js:

The new action in the replaced TicTacToe controller:

There is a new entry in the web.config file:

The replaced BaseController reads that setting:

6 – Start the application (it should run as to be accepted by the Federated Security running in ACS portal). See the invite URL:

7 – Browse to /Samples/TicTacToe/NodeJs:

8 – The client connects with the Node.js game server:

My browser doesn’t understand the WebSocket version implemented in the server library. Then, fallback to use xhr long polling.

9 – Open a new browser, in a private session, with the URL provided by the step 6

10 – These are the two players. The left one played at top left cell. The right player receives the new move and update its view.

11 – See the server console: the move was received and broadcasted to the game participants:

Nice! Homework: add the Node.js to a worker role (see @ntotten post NodeJS on Windows Azure).

Next topics: explain in detail the server code (it supports client that uses plain TCP sockets instead of, so you can program a client in other platforms, from Silverlight to iPhone to Android).

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 7) Game Moves Processing

Previous Post
Next Post

In this post, I want to discuss the game play processing in Tic Tac Toe. It involves many pieces, from Razor view using Javascript to Web Role, to Azure Blob Storage.

These are the javascript files referenced in Tic Tac Toe view (at SocialGame.Web/Areas/Samples/Views/TicTacToe/Index.cshtml):

<script src="@Url.AreaContent("Scripts/jQuery.tmpl.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/knockout-1.2.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/ServerInterface.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/GameService.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/UserService.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeBoard.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeGame.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeViewModel.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeController.js")" type="text/javascript"></script>

As I wrote in the previous post, ServerInterface, GameService and UserService are game-agnostic components. They could be used in any game. For each new kind of game X, you must implement XBoard, XGame logic, XViewModel and an appropiate XController.

At the end of that view, there is the creation of the game-agnostic services:

var apiURL = "@this.ViewBag.ApiUrl";
var blobURL = "@this.ViewBag.BlobUrl";
var si = new ServerInterface();
var gs = new GameService(apiURL, blobURL, si);
var user = new UserService(apiURL, blobURL, si);

The @this.ViewBag properties are filled in the ASP.NET MVC controller (see BaseController.cs)

The creation of the game controller:

// check for canvas, show an "Upgrade your browser" screen if they don't have it.
var canvas = document.getElementById('board');
if (canvas.getContext == null || canvas.getContext('2d') == null) {
var board = new TicTacToeBoard(canvas);
var game = new TicTacToeGame();
var controller = new TicTacToeController(viewModel, gs, board, game);

But the interesting part is in the controller constructor:

function TicTacToeController(viewModel, gameService, board, game) {
    this.viewModel = viewModel;
    this.gameService = gameService;
    this.board = board; = game;
    this.started = false;
    var controller = this;
    this.board.onMove = function (x, y) { controller.onMove(x, y); };

Notice the this.board.onMove: the controller register itself to process new moves detected by the board component. At its start method, the controller register itself to process game service updates:

        function (queue) { controller.processGameQueue(queue); },
        function (action) { controller.processAction(action); }

Let’s examine the processing of game moves.

1 – The board component detects a click, then it sends a new move to controller (using the onMove callbalk)

2 – The controller sends the new move to game logic, to update state (I omitted the view model in this sequence/graph)

3 – The controller sends the new move to game service.

4 – The game services sends a new command to web role, using the server interface

5 – The Web Role API receives the new command

6 – The command info is appended to the game status blob, at Azure storage

Now, the other client processing:

1 – The game service, using a timer, polls the game status, calling the service interface

2 – The service interface, using JSONP, retrieves the current game status from Azure Blob storage

3 – If a new move is detected, the game service calls a callback function provided by the controller (game service has no reference to controller).

4 – The controller sends the new move to game logic, updating state (I omitted the view state here)

5 – The controller sends the new move to board component, to update the canvas

A key point: the controller knows NOTHING about the service interface, WCF Web API, blob storage. So, you can change the game service to route and detect new moves in other ways. Next post: modify game service to use a Node.js server for game move processing.

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 6) Testing Game and Service with TDD and QUnit

Previous Post
Next Post

In my previous post, I presented the new version of Windows Azure Toolkit for Social Games. It has simple games to demonstrate the use of Javascript, HTML 5 canvas, game moves processing, Azure worker roles and web roles. Let’s explore in this post the making of client game logic, in Javascript, using TDD and QUnit.

There are online tests at:

Let’s run the Tic Tac Toe Game Logic tests:

This page is using QUnit for client Javascript unit testing. I wrote about that library at:

TDD with Javascript and QUnit

The above page is testing the Tic Tac Toe logic. Remember, each game is implemented in parts, the logic is one of them:

The client code resides in TicTacToeGame.js inside the SocialGames.Web project. Their first lines:

TTTColor = { Empty: 0, Cross: 1, Circle: 2 };
function TicTacToeGame() {
    this.board = [
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty]
TicTacToeGame.prototype.move = function (x, y, color) {
    this.board[x][y] = color;
TicTacToeGame.prototype.isEmpty = function (x, y) {
    return this.board[x][y] == TTTColor.Empty;

The client test page (TicTacToeGameTest.cshtml) was built at the same time, using a TDD (Test-Driven Development) approach. Look at first tests:

test("Create Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++)
            ok(game.isEmpty(x, y));
    equal(game.isTie(), false);
    equal(game.hasWinner(), false);
test("Valid Moves on Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++) {
            ok(game.isValid(x, y, TTTColor.Cross));
            ok(game.isValid(x, y, TTTColor.Circle));
test("No Winner in Empty Board", function () {
    var game = new TicTacToeGame();
    equal(game.getWinner(), TTTColor.Empty);
test("Get Winner in First Row", function () {
    var game = new TicTacToeGame();
    game.move(0, 0, TTTColor.Cross);
    game.move(1, 0, TTTColor.Cross);
    game.move(2, 0, TTTColor.Cross);
    equal(game.getWinner(), TTTColor.Cross);
    equal(game.isTie(), false);
    equal(game.hasWinner(), true);

The idea is to take baby steps, one test at a time, designing the game logic “API”, its expected behavior. In this way, you expend less time debugging in a dynamic language like Javascript, and you gain a test suite that can save your day in case of major refactoring. Look at the Four In A Row logic and client tests: you will find a similar approach.

Ok, not all can be easily tested, or build using TDD. Some of the game-agnostic services are using Ajax and Blob Storage, and to test them you must consider asynchronous Ajax calls. You can check:

(You must be logged in using your Facebook or Windows Live ID, an example of use of Federated Security and Access Control Service (ACS))

This time, the system under test is the game-agnostic Server Interface:

There are some tricks in the test code (ServerInterfaceTest.cshmlt), an excerpt:

test("Call User/Verify", function () {
    var success = function (result) { ok(true); start(); };
    var error = ajaxGetError;
    si.sendAjaxGet(apiURL + "user/verify", success);

expect is a QUnit function that prepare the framework to receive 1 ok(true) sometime during the test run. That confirmation is included in callback function success that it will be called after the successful processing of the asynchronous call .sendAjaxGet. Async life is not easy 😉

More code analysis is coming. And some adapt to use Node.js as game server.

Keep tuned!

Angel “Java” Lopez