edaxGetBookMoveWithPositionByMoves method

MoveListWithPosition edaxGetBookMoveWithPositionByMoves(
  1. String moves
)

Get book move list with position by specified moves.

Implementation

MoveListWithPosition edaxGetBookMoveWithPositionByMoves(final String moves) {
  final dstM = calloc<bindings.MoveList>();
  final dstP = calloc<bindings.Position>();
  final movesPointer = moves.toCharPointer();
  final symetry = _bindings.edax_get_bookmove_with_position_by_moves(
    movesPointer,
    dstM,
    dstP,
  );
  calloc.free(movesPointer);

  final moveList = dstM.ref;
  final resultMoveList = <Move>[];
  for (var k = 0; k < moveList.n_moves; k++) {
    final m = moveList.move[k + 1];
    resultMoveList.add(Move.fromCStruct(m));
  }
  calloc.free(dstM);

  final position = Position.fromCStruct(dstP.ref);
  calloc.free(dstP);

  return MoveListWithPosition(resultMoveList, position, symetry);
}