c++ implement of collective intelligence