Return to Xholon webEdition.

In this version of meTTTa (a game of Tic Tac Toe), you can drag in new strategies. The game comes with two built-in strategies for computer play, a default strategy (defaultStrategy), and a strategy based on an example in a book I wrote (bookStrategy). Select one or the other by clicking on one of the Strategy buttons.

You can add a third strategy by selecting the following text, dragging it to the Strategies box, and dropping it there. There should now be a new Strategy button, with a randomStrategy. In some browsers, you may need to first copy the text to an external text editor, and then drag and drop from there.

randomStrategy{doComputerMove : function(constants, grid) {
  var availMoves = $("div.GridCell[state=" + constants.PL_NULL + "]");
  var pos = availMoves.eq(Math.floor(Math.random() * availMoves.length));
  pos.attr('state', constants.PL_COMPUTER).css('background-color', constants.BC_COMPUTER);

You can create your own strategies by using the randomStrategy as a template. The first line of the strategy must contain the unique name of the strategy (ex: myStrategy), immediately followed by "{doComputerMove : function(constants, grid) {".