tests/lib/ludorum.js
/** All pieces move one square forward. Piece A can move straight backwards or diagonally 
	forward, and B pieces move only diagonally forward. Pieces can move to any square that is empty 
	or occupied by an opponent's piece of the same type. If the piece moves to an occupied square, 
	it captures the piece in it.
	*/
All pieces move one square forward. Piece A can move straight backwards or diagonally
forward, and B pieces move only diagonally forward. Pieces can move to any square that is empty
or occupied by an opponent's piece of the same type. If the piece moves to an occupied square,
it captures the piece in it.
All pieces move one square forward . Piece A can move straight backwards or diagonally forward and B pieces move only diagonally forward . Pieces can move to any square that is empty or occupied by an opponent ' s piece of the same type . If the piece moves to an occupied square it captures the piece in it .
function moves() {
		var activePlayer = this.activePlayer(),
			pieceRegExp = this.__PLAYER_PIECES_RE__[activePlayer],
			board = this.board,
			_moves = [];
		board.string.replace(pieceRegExp, function (piece, i) {
			var coord = [(i / 5)|0, i % 5], pieceMoves;
			switch (piece) {
				case 'A': pieceMoves = [[+1,-1], [-1, 0], [+1,+1]]; break;
				case 'B': pieceMoves = [[+1,-1], [+1,+1]]; break;
				case 'a': pieceMoves = [[-1,-1], [+1, 0], [-1,+1]]; break;
				case 'b': pieceMoves = [[-1,-1], [-1,+1]]; break;
			}
			iterable(pieceMoves).forEachApply(function (dx, dy) {
				var coordTo = [coord[0] + dx, coord[1] + dy],
					squareTo = board.square(coordTo);
				if (board.isValidCoord(coordTo) && !squareTo.match(pieceRegExp) &&
						(squareTo == '.' || piece.toLowerCase() == squareTo.toLowerCase())) {
					_moves.push([coord, coordTo]); 
				}
			});
			return piece;
		});
		return _moves.length > 0 ? obj(activePlayer, _moves) : null;
	}
function moves ( ) { var activePlayer = this . activePlayer ( ) , pieceRegExp = this . __PLAYER_PIECES_RE__ [ activePlayer ] , board = this . board , _moves = [ ] ; board . string . replace ( pieceRegExp , function ( piece , i ) { var coord = [ ( i / 5 ) | 0 , i % 5 ] , pieceMoves ; switch ( piece ) { case 'A' : pieceMoves = [ [ + 1 , - 1 ] , [ - 1 , 0 ] , [ + 1 , + 1 ] ] ; break ; case 'B' : pieceMoves = [ [ + 1 , - 1 ] , [ + 1 , + 1 ] ] ; break ; case 'a' : pieceMoves = [ [ - 1 , - 1 ] , [ + 1 , 0 ] , [ - 1 , + 1 ] ] ; break ; case 'b' : pieceMoves = [ [ - 1 , - 1 ] , [ - 1 , + 1 ] ] ; break ; } iterable ( pieceMoves ) . forEachApply ( function ( dx , dy ) { var coordTo = [ coord [ 0 ] + dx , coord [ 1 ] + dy ] , squareTo = board . square ( coordTo ) ; if ( board . isValidCoord ( coordTo ) && ! squareTo . match ( pieceRegExp ) && ( squareTo == '.' || piece . toLowerCase ( ) == squareTo . toLowerCase ( ) ) ) { _moves . push ( [ coord , coordTo ] ) ; } } ) ; return piece ; } ) ; return _moves . length > 0 ? obj ( activePlayer , _moves ) : null ; }
All pieces move one square forward.
All pieces move one square forward .
// Valid coordinate and not occupied by a friendly piece.