06-15-2022, 04:35 PM
(01-29-2020, 08:14 PM)DennisSoemers Wrote: Yes that's correct, it always just gives the last move that was played, regardless of who selected that move.
Currently we don't have a method that directly returns the last move made by a mover different from the current mover. I suppose that would be a sensible method for us to add for convenience in a future version, but for now it should be relatively easy to implement yourself. The full history of ALL moves in a trial can be obtained using context.trial().moves(). That just returns an ArrayList<Move>. So you'd probably want to do something like:
it seems that there is no moves() functions in Trial class. So how to obtain the moves history from Trial?
Code:public static Move lastOpponentMove(final Context context)
{
final int currentMover = context.state().mover();
final List<Move> movesHistory = context.trial().moves();
for (int i = movesHistory.size() - 1; i >= 0; --i)
{
final Move m = movesHistory.get(i);
if (m.mover() != currentMover) // Found move made by someone else
return m;
}
return null;
}
I just wrote that here and didn't test it, but pretty sure this should work correctly for now.