src/Game.js
/** `serialized(game)` builds a serialized version of a simultaneous game, i.e. one in which two
	or more players may be active in the same turn. It converts a simultaneous game to an alternated
	turn based game. This may be useful for using algorithms like MiniMax to build AIs for
	simultaneous games.
	*/
`serialized(game)` builds a serialized version of a simultaneous game, i.e. one in which two
or more players may be active in the same turn. It converts a simultaneous game to an alternated
turn based game. This may be useful for using algorithms like MiniMax to build AIs for
simultaneous games.
` serialized ( game ) ` builds a serialized version of a simultaneous game i . e . one in which two or more players may be active in the same turn . It converts a simultaneous game to an alternated turn based game . This may be useful for using algorithms like MiniMax to build AIs for simultaneous games .
function serialized(game) {
		var super_moves = game.prototype.moves,
			super_next = game.prototype.next;
		return declare(game, {
			moves: function moves() {
				var fixedMoves = this.__fixedMoves__ || (this.__fixedMoves__ = {}),
					allMoves = super_moves.call(this),
					activePlayer;
				for (var i = 0; i < this.activePlayers.length; i++) {
					if (fixedMoves.hasOwnProperty(this.activePlayers[i])) {
						activePlayer = this.activePlayers[i];
						break;
					}
				}
				return activePlayer && allMoves ? obj(activePlayer, allMoves[activePlayer]) : null;
			},
			next: function next(moves) {
				var nextFixedMoves = copy({}, this.fixedMoves || {}, moves),
					allMoved = iterable(this.players).all(function (p) {
							return nextFixedMoves.hasOwnProperty(p);
						}),
					result;
				if (allMoved) {
					result = super_next.call(this, nextFixedMoves);
					result.fixedMoves = {};
				} else {
					result = this.clone();
					result.fixedMoves = nextFixedMoves;
				}
				return result;
			}
		});
	} 
function serialized ( game ) { var super_moves = game . prototype . moves , super_next = game . prototype . next ; return declare ( game , { moves : function moves ( ) { var fixedMoves = this . __fixedMoves__ || ( this . __fixedMoves__ = { } ) , allMoves = super_moves . call ( this ) , activePlayer ; for ( var i = 0 ; i < this . activePlayers . length ; i ++ ) { if ( fixedMoves . hasOwnProperty ( this . activePlayers [ i ] ) ) { activePlayer = this . activePlayers [ i ] ; break ; } } return activePlayer && allMoves ? obj ( activePlayer , allMoves [ activePlayer ] ) : null ; } , next : function next ( moves ) { var nextFixedMoves = copy ( { } , this . fixedMoves || { } , moves ) , allMoved = iterable ( this . players ) . all ( function ( p ) { return nextFixedMoves . hasOwnProperty ( p ) ; } ) , result ; if ( allMoved ) { result = super_next . call ( this , nextFixedMoves ) ; result . fixedMoves = { } ; } else { result = this . clone ( ) ; result . fixedMoves = nextFixedMoves ; } return result ; } } ) ; }
`serialized(game)` builds a serialized version of a simultaneous game, i.e.
` serialized ( game ) ` builds a serialized version of a simultaneous game i . e .
/** The `moves()` of a serialized game returns the moves of the player deemed as the
			active player, if there are any moves.
			*/ /** The `next(moves)` of a serialized game advances the actual game if with the given
			move all active players in the real game state have moved. Else the next player that has
			to move becomes active.
			*/ // static serialized