src/players/RuleBasedPlayer.js
/** To choose a move, the `rules` are checked in order. The first rule that fits decides the
	move to make. If no rule fits, a move is chosen randomly. If a rule returns a move that is not
	valid, it is ignored.
	*/
To choose a move, the `rules` are checked in order. The first rule that fits decides the
move to make. If no rule fits, a move is chosen randomly. If a rule returns a move that is not
valid, it is ignored.
To choose a move the ` rules ` are checked in order . The first rule that fits decides the move to make . If no rule fits a move is chosen randomly . If a rule returns a move that is not valid it is ignored .
function decision(game, role) {
		var result = null,
			features = this.features(game, role),
			moves = this.movesFor(game, role);
		for (var i = 0, len = this.rules.length; i < len; i++) {
			result = this.rules[i].call(this, features);
			if (result !== null && moves.indexOf(result) >= 0) {
				return result;
			}
		}
		return this.random.choice(moves);
	}
function decision ( game , role ) { var result = null , features = this . features ( game , role ) , moves = this . movesFor ( game , role ) ; for ( var i = 0 , len = this . rules . length ; i < len ; i ++ ) { result = this . rules [ i ] . call ( this , features ) ; if ( result !== null && moves . indexOf ( result ) >= 0 ) { return result ; } } return this . random . choice ( moves ) ; }
To choose a move, the `rules` are checked in order.
To choose a move the ` rules ` are checked in order .