0.0.4 • Published 9 years ago

mauler v0.0.4

Weekly downloads
17
License
-
Repository
github
Last release
9 years ago

Mauler

Mauler is a JavaScript framework for abstract strategy games.

Installation

$ npm install mauler

Games

Algorithms

Play a Random Game

var game = new ma.games.TicTacToe();
console.log(game.toString());
while (!game.isGameOver() {
  var moves = game.moves();
  var randomMove = moves[Math.floor(Math.random() * moves.length)];
  game.move(randomMove);
  console.log(game.toString());
}

Play a Game Between Two Players

var game = new ma.games.TicTacToe();
var players = [new ma.players.random(), new ma.players.alphaBeta()]
console.log(game.toString());
while (!game.isGameOver() {
  var player = players[game.currentPlayer()];
  var move = player(game);
  game.move(randomMove);
  console.log(game.toString());
}