MCPcopy Create free account
hub / github.com/dds-bridge/dds / register_solve_bindings

Function register_solve_bindings

python/src/bindings.cpp:52–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52auto register_solve_bindings(py::module_& module) -> void
53{
54 // Overload 1: solve_board with optional context
55 module.def(
56 "solve_board",
57 [](const py::dict& deal,
58 const int target,
59 const int solutions,
60 const int mode,
61 const int thread_index,
62 py::object context_obj) {
63 FutureTricks future_tricks{};
64 const Deal native_deal = dds3_python::dict_to_deal(deal);
65 SolverContext* context_ptr = nullptr;
66 if (!context_obj.is_none()) {
67 context_ptr = py::cast<SolverContext*>(context_obj);
68 }
69 int code = RETURN_NO_FAULT;
70 {
71 py::gil_scoped_release release;
72
73 if (context_ptr == nullptr) {
74 // Create temporary context (old behavior)
75 code = SolveBoard(
76 native_deal,
77 target,
78 solutions,
79 mode,
80 &future_tricks,
81 thread_index);
82 } else {
83 // Use provided context
84 code = solve_board(
85 *context_ptr,
86 native_deal,
87 target,
88 solutions,
89 mode,
90 &future_tricks);
91 }
92 }
93 throw_on_dds_error(code);
94 return dds3_python::future_tricks_to_dict(future_tricks);
95 },
96 py::arg("deal"),
97 py::arg("target") = -1,
98 py::arg("solutions") = 3,
99 py::arg("mode") = 0,
100 py::arg("thread_index") = 0,
101 py::arg("context") = py::none(),
102 "Solve a single bridge deal from binary format.\n\n"
103 "Args:\n"
104 " deal (dict): Deal dict with keys 'trump', 'first', 'remain_cards', 'current_trick_suit', "
105 "'current_trick_rank'.\n"
106 " target (int, optional): Target number of tricks for optimization (-1 = no target). Default: -1\n"
107 " solutions (int, optional): Depth of search (1-3, higher = more branches). Default: 3\n"
108 " mode (int, optional): 0 = auto, 1 = thread depth 6, 2 = node depth 12. Default: 0\n"
109 " thread_index (int, optional): Thread ID for transposition table access. Default: 0\n"

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 8

dict_to_dealFunction · 0.85
solve_boardFunction · 0.85
throw_on_dds_errorFunction · 0.85
future_tricks_to_dictFunction · 0.85
pbn_to_dealFunction · 0.85
SolveBoardPBNFunction · 0.85
convert_from_pbnFunction · 0.85
SolveBoardFunction · 0.50

Tested by

no test coverage detected