src/Match.js
/** `Match.run(plys=Infinity)` runs the match the given number of plys, or until the game
	finishes. The result is a future that gets resolved when the game ends.
	*/
`Match.run(plys=Infinity)` runs the match the given number of plys, or until the game
finishes. The result is a future that gets resolved when the game ends.
` Match . run ( plys = Infinity ) ` runs the match the given number of plys or until the game finishes . The result is a future that gets resolved when the game ends .
function run(plys) {
		plys = isNaN(plys) ? Infinity : +plys;
		if (plys < 1) { 
			return Future.when(this);
		}
		var ply = this.ply(),
			game = this.state(),
			results, next;
		if (ply < 1) {
			this.onBegin(game);
		}
		game = this.__advanceContingents__(game); 
		results = game.result();
		if (results) { 
			this.onEnd(game, results);
			return Future.when(this);
		} else { 
			var match = this;
			return this.decisions(game).then(function (moves) {
				if (match.__advance__(game, moves)) {
					return match.run(plys - 1);
				} else {
					return match;
				}
			});
		}
	}
function run ( plys ) { plys = isNaN ( plys ) ? Infinity : + plys ; if ( plys < 1 ) { return Future . when ( this ) ; } var ply = this . ply ( ) , game = this . state ( ) , results , next ; if ( ply < 1 ) { this . onBegin ( game ) ; } game = this . __advanceContingents__ ( game ) ; results = game . result ( ) ; if ( results ) { this . onEnd ( game , results ) ; return Future . when ( this ) ; } else { var match = this ; return this . decisions ( game ) . then ( function ( moves ) { if ( match . __advance__ ( game , moves ) ) { return match . run ( plys - 1 ) ; } else { return match ; } } ) ; } }
`Match.run(plys=Infinity)` runs the match the given number of plys, or until the game
finishes.
` Match . run ( plys = Infinity ) ` runs the match the given number of plys or until the game finishes .
// If the run must stop... // Remove all non-determinism. // If the match has finished ... // Else the run must continue ...