06-14-2022, 09:50 AM
Hi! I am writing a ludii AI, but I have a problem. How can I get the history moves of the game? I can't get the correct history moves with the following code:
@Override
public Move selectAction
(
final Game game,
final Context context,
final double maxSeconds,
final int maxIterations,
final int maxDepth
)
{
final Trial trial = context.trial();
System.out.println("trail move number = " + trial.moveNumber());
State state = context.state();
System.out.println("trail mover = " + state.mover());
System.out.println("Moves = ");
for(int i = 0; i < trial.moveNumber(); i++)
{
Move move = trial.getMove(i);
int from = trial.getMove(i).from();
int to = trial.getMove(i).to();
System.out.println("(" + from + "." + to + ")");
}
FastArrayList<Move> legalMoves = game.moves(context).moves();
//System.out.println("Legal Moves = " + legalMoves);
// If we're playing a simultaneous-move game, some of the legal moves may be
// for different players. Extract only the ones that we can choose.
if (!game.isAlternatingMoveGame())
legalMoves = AIUtils.extractMovesForMover(legalMoves, player);
final int r = ThreadLocalRandom.current().nextInt(legalMoves.size());
return legalMoves.get®;
}
the from and to is always -1, strange.
@Override
public Move selectAction
(
final Game game,
final Context context,
final double maxSeconds,
final int maxIterations,
final int maxDepth
)
{
final Trial trial = context.trial();
System.out.println("trail move number = " + trial.moveNumber());
State state = context.state();
System.out.println("trail mover = " + state.mover());
System.out.println("Moves = ");
for(int i = 0; i < trial.moveNumber(); i++)
{
Move move = trial.getMove(i);
int from = trial.getMove(i).from();
int to = trial.getMove(i).to();
System.out.println("(" + from + "." + to + ")");
}
FastArrayList<Move> legalMoves = game.moves(context).moves();
//System.out.println("Legal Moves = " + legalMoves);
// If we're playing a simultaneous-move game, some of the legal moves may be
// for different players. Extract only the ones that we can choose.
if (!game.isAlternatingMoveGame())
legalMoves = AIUtils.extractMovesForMover(legalMoves, player);
final int r = ThreadLocalRandom.current().nextInt(legalMoves.size());
return legalMoves.get®;
}
the from and to is always -1, strange.