* @param lastMove last move that was made on the board
* @return list of generated moves.
*/
public MoveList generateMoves(TwoPlayerMove lastMove) {
MoveList moveList = new MoveList();
boolean player1 = (lastMove == null) || !lastMove.isPlayer1();
// There is one path from every piece to every opponent home (i.e. n*NUM_HOMES)
PathList opponentPaths = board.findAllOpponentShortestPaths(player1);
List<BoardPosition> pawnLocations = new LinkedList<BoardPosition>();
for ( int row = 1; row <= board.getNumRows(); row++ ) {
for ( int col = 1; col <= board.getNumCols(); col++ ) {
BoardPosition p = board.getPosition( row, col );
if ( p.isOccupied() && p.getPiece().isOwnedByPlayer1() == player1 ) {
pawnLocations.add(p);
addMoves( p, moveList, opponentPaths, weights_ );
}
}
}
if (moveList.isEmpty())
GameContext.log(1, "There aren't any moves to consider for lastMove=" + lastMove
+ " Complete movelist =" + board.getMoveList() + " \nThe pieces are at:" + pawnLocations);
return moveList;
}