9 #define EXPOSE_AGENT_CONTAINER(...) \ 
   10 namespace pybind11 { namespace detail { \ 
   11     template<> class type_caster<vector<shared_ptr<__VA_ARGS__>>> : public type_caster_base<vector<shared_ptr<__VA_ARGS__>>> { }; \ 
   13 #define EXPOSE_PATCH_CONTAINER(...) \ 
   14 namespace pybind11 { namespace detail { \ 
   15     template<> class type_caster<map<unsigned,shared_ptr<__VA_ARGS__>>> : public type_caster_base<map<unsigned,shared_ptr<__VA_ARGS__>>> { }; \ 
   22     template<
class ENV, 
class AGENT, 
class PATCH> 
 
   60     template<
class ENV, 
class AGENT, 
class PATCH> 
 
   71         void inherit(shared_ptr<AGENT> father)
 override{
 
   81     template<
class ENV, 
class AGENT, 
class PATCH> 
 
   94     template<
class ENV,
class AGENT,
class PATCH,
class tram
class>
 
   96         auto class_binds_obj = 
 
   97         py::class_<ENV,tramclass,std::shared_ptr<ENV>> (
m,class_name_string.c_str(),py::dynamic_attr())
 
   99             .
def(
"place_agent", py::overload_cast<shared_ptr<PATCH>,shared_ptr<AGENT>>(&ENV::place_agent), 
"Places the agent on the given patch")
 
  100             .
def(
"place_agent", py::overload_cast<
unsigned,shared_ptr<AGENT>>(&ENV::place_agent), 
"Places the agent on the given patch index")
 
  101             .
def(
"place_agent_randomly",&ENV::place_agent_randomly)
 
  102             .def(
"setup_domain",&ENV::setup_domain)
 
  103             .def(
"step_agents",&ENV::step_agents)
 
  104             .def(
"step_patches",&ENV::step_patches)
 
  105             .def(
"update",&ENV::update)
 
  106             .def(
"step",&ENV::step)
 
  107             .def(
"setup_agents",&ENV::setup_agents)
 
  108             .def(
"count_agents",&ENV::count_agents)
 
  109             .def(
"memory_usage",&ENV::memory_usage)
 
  110             .def_readwrite(
"patches",&ENV::patches)
 
  111             .def_readwrite(
"agents",&ENV::agents);
 
  112         return class_binds_obj;
 
  115     template<
class ENV,
class AGENT,
class PATCH>
 
  117         auto class_binds_obj = 
 
  118         py::class_<ENV,std::shared_ptr<ENV>> (
m,class_name_string.c_str(),py::dynamic_attr())
 
  120             .
def(
"memory_usage",&ENV::memory_usage)
 
  121             .def(
"place_agent_randomly",&ENV::place_agent_randomly)
 
  122             .def(
"setup_domain",&ENV::setup_domain)
 
  123             .def(
"step_agents",&ENV::step_agents)
 
  124             .def(
"step_patches",&ENV::step_patches)
 
  125             .def(
"place_agent",&ENV::place_agent)
 
  126             .def(
"update",&ENV::update)
 
  127             .def(
"step",&ENV::step)
 
  128             .def(
"setup_agents",&ENV::setup_agents)
 
  129             .def(
"count_agents",&ENV::count_agents)
 
  130             .def(
"connect_patch_agent", &ENV::connect_patch_agent)
 
  131             .def_readwrite(
"patches",&ENV::patches)
 
  132             .def_readwrite(
"agents",&ENV::agents);
 
  133         return class_binds_obj;
 
  136     template<
class ENV,
class AGENT,
class PATCH,
class tram
class>
 
  138         auto class_binds_obj = py::class_<AGENT, tramclass,std::shared_ptr<AGENT>>(
m,class_name_str.c_str(),py::dynamic_attr())
 
  139             .
def(
py::init<shared_ptr<ENV>,
string>(),
"Initialize",py::arg(
"env"),py::arg(
"class_name"))
 
  140             .
def(
"move",&
AGENT::move,
"Move the agent to a new patch",py::arg(
"patch")=
nullptr,py::arg(
"quiet")=
false)
 
  141             .
def(
"order_hatch",&AGENT::order_hatch,
"Hatch request",
 
  142                 py::arg(
"patch")=
nullptr, py::arg(
"inherit")=
false,
 
  143                 py::arg(
"quiet")=
false, py::arg(
"reset")=
false)
 
  144             .
def(
"order_move",&AGENT::order_move,
"Move request",
 
  145                 py::arg(
"patch")=
nullptr, 
 
  146                 py::arg(
"quiet")=
false, py::arg(
"reset")=
false)
 
  147             .
def(
"order_switch",&AGENT::order_switch,
"Switch request",
 
  149             .def_readwrite(
"disappear",&AGENT::disappear)
 
  150             .def_readwrite(
"env",&AGENT::env)
 
  151             .def_readwrite(
"patch",&AGENT::patch)
 
  152             .def_readwrite(
"disappear",&AGENT::disappear)
 
  153             .def_readwrite(
"class_name",&AGENT::class_name);
 
  154         return class_binds_obj;
 
  157     template<
class ENV,
class AGENT,
class PATCH>
 
  159         auto class_binds_obj = py::class_<AGENT, std::shared_ptr<AGENT>>(
m,class_name_str.c_str(),py::dynamic_attr())
 
  160             .
def(
py::init<shared_ptr<ENV>,
string>(),
"Initialize",py::arg(
"env"),py::arg(
"class_name"))
 
  161             .
def(
"move",&
AGENT::move,
"Move the agent to a new patch",py::arg(
"patch")=
nullptr,py::arg(
"quiet")=
false)
 
  162             .
def(
"order_hatch",&AGENT::order_hatch,
"Hatch request",
 
  163                 py::arg(
"patch")=
nullptr, py::arg(
"inherit")=
false,
 
  164                 py::arg(
"quiet")=
false, py::arg(
"reset")=
false)
 
  165             .
def(
"order_move",&AGENT::order_move,
"Move request",
 
  166                 py::arg(
"patch")=
nullptr, 
 
  167                 py::arg(
"quiet")=
false, py::arg(
"reset")=
false)
 
  168             .
def(
"order_switch",&AGENT::order_switch,
"Switch request",
 
  170             .def_readwrite(
"disappear",&AGENT::disappear)
 
  171             .def_readwrite(
"env",&AGENT::env)
 
  172             .def_readwrite(
"patch",&AGENT::patch)
 
  173             .def_readwrite(
"disappear",&AGENT::disappear)
 
  174             .def_readwrite(
"class_name",&AGENT::class_name);
 
  175         return class_binds_obj;
 
  179     template<
class ENV,
class AGENT,
class PATCH,
class tram
class>
 
  181         auto class_binds_obj =  py::class_<PATCH,tramclass,std::shared_ptr<PATCH>>(
m,class_name_ptr.c_str(),py::dynamic_attr())
 
  183             .
def(
"empty_neighbor", &PATCH::empty_neighbor,
"Return an empty patch around the patch",
 
  184                 py::arg(
"quiet")=
false)
 
  185             .
def(
"find_neighbor_agents",&PATCH::find_neighbor_agents,
"Returns a vector of agents in one patch neighborhood",
 
  186                 py::arg(
"include_self")=
true)
 
  187             .def_readwrite(
"index",&PATCH::index)
 
  188             .def_readwrite(
"coords",&PATCH::coords)
 
  189             .def(
"get_agent",&PATCH::get_agent)
 
  190             .def(
"empty",&PATCH::empty)
 
  191             .def_readwrite(
"on_border",&PATCH::on_border)
 
  192             .def_readwrite(
"neighbors",&PATCH::neighbors);
 
  193         return class_binds_obj;
 
  197     template<
class ENV,
class AGENT,
class PATCH>
 
  199         auto class_binds_obj =  py::class_<PATCH,std::shared_ptr<PATCH>>(
m,class_name_ptr.c_str(),py::dynamic_attr())
 
  201             .
def(
"empty_neighbor", &PATCH::empty_neighbor,
"Return an empty patch around the patch",
 
  202                 py::arg(
"quiet")=
false)
 
  203             .
def(
"find_neighbor_agents",&PATCH::find_neighbor_agents,
"Returns a vector of agents in one patch neighborhood",
 
  204                 py::arg(
"include_self")=
true)
 
  205             .def_readwrite(
"coords",&PATCH::coords)
 
  206             .def(
"get_agent",&PATCH::get_agent)
 
  207             .def(
"empty",&PATCH::empty)
 
  208             .def_readwrite(
"on_border",&PATCH::on_border)
 
  209             .def_readwrite(
"neighbors",&PATCH::neighbors);
 
  210         return class_binds_obj;
 
  215          py::register_exception<patch_availibility>(
m, 
"patch_availibility");
 
  216          py::register_exception<undefined_member>(
m, 
"undefined_member");
 
  221         py::class_<MESH_ITEM>(
m,
"MESH_ITEM")
 
  223         auto space_sub = 
m.def_submodule(
"space");
 
  224         space_sub.def(
"grid2",&
space::grid2,
"Creates 3D grid mesh", py::arg(
"length"), py::arg(
"width"), py::arg(
"mesh_length"),py::arg(
"share") = 
false);
 
  225         space_sub.def(
"grid3",&
space::grid3,
"Creates 3D grid mesh", py::arg(
"length"), py::arg(
"width"),py::arg(
"height"), py::arg(
"mesh_length"),py::arg(
"share") = 
false);
 
  229     template<
class ENV,
class AGENT,
class PATCH>
 
  231         using AgentsBank = vector<shared_ptr<AGENT>>;
 
  232         using PatchesBank = map<unsigned,shared_ptr<PATCH>>;
 
  233         py::bind_vector<AgentsBank>(
m,
"AgentsBank")
 
  234         .def(
"append",[](AgentsBank& container,shared_ptr<AGENT> agent){
 
  235             container.push_back(agent);
 
  237         py::bind_map<PatchesBank>(
m,
"PatchesBank")
 
  238         .def(
"clear",[](PatchesBank& container){
 
  241         .
def(
"keys",[](PatchesBank& container){
 
  242               std::vector<unsigned> keys;
 
  243               for (
auto const& element : container) {
 
  244                 keys.push_back(element.first);
 
  248         .
def(
"append",[](PatchesBank& container,shared_ptr<PATCH> patch){
 
  249             container.insert(std::pair<
unsigned,shared_ptr<PATCH>>(patch->index,patch));
 
  253     template<
class ENV,
class AGENT, 
class PATCH>
 
  255         expose_containers<ENV,AGENT,PATCH>(
m);
 
  260     template<
class env,
class agent,
class patch,
class tramenv,
class tramagent,
class trampatch>
 
  262         using py_env =  py::class_<env,tramenv,std::shared_ptr<env>>;
 
  263         using py_agent = py::class_<agent,tramagent,std::shared_ptr<agent>>;
 
  264         using py_patch = py::class_<patch,trampatch,std::shared_ptr<patch>>;
 
  271             bind_tools::expose_defaults<env,agent,patch>(
m);