edaxGetBookMoveWithPosition method

MoveListWithPosition edaxGetBookMoveWithPosition()

Get book move list with position.

Implementation

MoveListWithPosition edaxGetBookMoveWithPosition() {
  final dstM = calloc<bindings.MoveList>();
  final dstP = calloc<bindings.Position>();
  final symetry = _bindings.edax_get_bookmove_with_position(dstM, dstP);

  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);
}