std::vector<std::string> CRumbleGenerator::GetMotors(const std::string& controllerId) { using namespace GAME; std::vector<std::string> motors; CControllerManager& controllerManager = CServiceBroker::GetGameControllerManager(); ControllerPtr controller = controllerManager.GetController(controllerId); if (controller) controller->GetFeatures(motors, FEATURE_TYPE::MOTOR); return motors; }
void CGUIControllerList::RegisterController(const std::string& addonId, const ADDON::VECADDONS& addonCache) { auto it = std::find_if(addonCache.begin(), addonCache.end(), [addonId](const AddonPtr& addon) { return addon->ID() == addonId; }); if (it != addonCache.end()) { ControllerPtr newController = std::dynamic_pointer_cast<CController>(*it); if (newController && newController->LoadLayout()) m_controllers.push_back(newController); } }
CButtonMapping::CButtonMapping(IButtonMapper* buttonMapper, IButtonMap* buttonMap, IKeymap* keymap) : m_buttonMapper(buttonMapper), m_buttonMap(buttonMap), m_keymap(keymap), m_lastAction(0), m_frameCount(0) { assert(m_buttonMapper != nullptr); assert(m_buttonMap != nullptr); // Make sure axes mapped to Select are centered before they can be mapped. // This ensures that they are not immediately mapped to the first button. if (m_keymap) { using namespace GAME; CControllerManager& controllerManager = CServiceBroker::GetGameControllerManager(); ControllerPtr controller = controllerManager.GetController(m_keymap->ControllerID()); const auto& features = controller->Features(); for (const auto& feature : features) { bool bIsSelectAction = false; const auto &actions = m_keymap->GetActions(CJoystickUtils::MakeKeyName(feature.Name())).actions; if (!actions.empty() && actions.begin()->actionId == ACTION_SELECT_ITEM) bIsSelectAction = true; if (!bIsSelectAction) continue; CDriverPrimitive primitive; if (!m_buttonMap->GetScalar(feature.Name(), primitive)) continue; if (primitive.Type() != PRIMITIVE_TYPE::SEMIAXIS) continue; // Set initial config, as detection will fail because axis is already activated AxisConfiguration axisConfig; axisConfig.bKnown = true; axisConfig.center = primitive.Center(); axisConfig.range = primitive.Range(); GetAxis(primitive.Index(), static_cast<float>(primitive.Center()), axisConfig).SetEmitted(primitive); } } }
bool CGameClientInput::OpenMouse(const ControllerPtr &controller) { using namespace JOYSTICK; if (!controller) { CLog::Log(LOGERROR, "Failed to open mouse, no controller given"); return false; } //! @todo Move to player manager PERIPHERALS::PeripheralVector mice; CServiceBroker::GetPeripherals().GetPeripheralsWithFeature(mice, PERIPHERALS::FEATURE_MOUSE); if (mice.empty()) return false; std::string controllerId = controller->ID(); game_controller controllerStruct{}; controllerStruct.controller_id = controllerId.c_str(); controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL); controllerStruct.analog_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG); controllerStruct.analog_stick_count = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK); controllerStruct.accelerometer_count = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER); controllerStruct.key_count = controller->FeatureCount(FEATURE_TYPE::KEY); controllerStruct.rel_pointer_count = controller->FeatureCount(FEATURE_TYPE::RELPOINTER); controllerStruct.abs_pointer_count = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER); controllerStruct.motor_count = controller->FeatureCount(FEATURE_TYPE::MOTOR); bool bSuccess = false; { CSingleLock lock(m_clientAccess); if (m_gameClient.Initialized()) { try { bSuccess = m_struct.toAddon.EnableMouse(true, &controllerStruct); } catch (...) { m_gameClient.LogException("EnableMouse()"); } } } if (bSuccess) { m_mouse.reset(new CGameClientMouse(m_gameClient, controllerId, m_struct.toAddon, mice.at(0).get())); return true; } return false; }
unsigned int CAddonCallbacksPeripheral::FeatureCount(void* addonData, const char* controllerId, JOYSTICK_FEATURE_TYPE type) { using namespace ADDON; using namespace GAME; unsigned int count = 0; AddonPtr addon; if (CAddonMgr::GetInstance().GetAddon(controllerId, addon, ADDON_GAME_CONTROLLER)) { ControllerPtr controller = std::static_pointer_cast<CController>(addon); if (controller->LoadLayout()) count = controller->Layout().FeatureCount(CPeripheralAddonTranslator::TranslateFeatureType(type)); } return count; }
void run(ControllerPtr &controller) try { // Prepare Analysis // FilterAnalyzerPtr analyzer(new FilterAnalyzer()); // Process inputs // controller->use(analyzer); controller->start(); cout << *analyzer << endl; } catch(...) { }
/// Provides new values that the body should use to control it's actuators. void Else::AcrobotArticulatedBody ::setActuators( const ControllerPtr argController ) { // 1 actuator double torque = 0.85 * scaleTorque( argController->getOutput(1, 0) ); dJointAddHingeTorque( myJoints[0], torque ); }
void CGameClient::UpdatePort(unsigned int port, const ControllerPtr& controller) { using namespace JOYSTICK; CSingleLock lock(m_critSection); if (Initialized()) { if (controller != CController::EmptyPtr) { std::string strId = controller->ID(); game_controller controllerStruct; controllerStruct.controller_id = strId.c_str(); controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL); controllerStruct.analog_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG); controllerStruct.analog_stick_count = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK); controllerStruct.accelerometer_count = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER); controllerStruct.key_count = 0; //! @todo controllerStruct.rel_pointer_count = controller->FeatureCount(FEATURE_TYPE::RELPOINTER); controllerStruct.abs_pointer_count = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER); controllerStruct.motor_count = controller->FeatureCount(FEATURE_TYPE::MOTOR); try { m_struct.toAddon.UpdatePort(port, true, &controllerStruct); } catch (...) { LogException("UpdatePort()"); } } else { try { m_struct.toAddon.UpdatePort(port, false, nullptr); } catch (...) { LogException("UpdatePort()"); } } } }
void XboxdrvDaemon::on_connect(ControllerSlotPtr slot) { ControllerPtr controller = slot->get_controller(); assert(controller); if (!m_opts.on_connect.empty()) { log_info("launching connect script: " << m_opts.on_connect); std::vector<std::string> args; args.push_back(m_opts.on_connect); args.push_back(controller->get_usbpath()); args.push_back(controller->get_usbid()); args.push_back(controller->get_name()); spawn_exe(args); } }
CButtonMapping::CButtonMapping(IButtonMapper* buttonMapper, IButtonMap* buttonMap, IActionMap* actionMap) : m_buttonMapper(buttonMapper), m_buttonMap(buttonMap), m_actionMap(actionMap), m_lastAction(0), m_frameCount(0) { assert(m_buttonMapper != nullptr); assert(m_buttonMap != nullptr); // Make sure axes mapped to Select are centered before they can be mapped. // This ensures that they are not immediately mapped to the first button. if (m_actionMap && m_actionMap->ControllerID() == m_buttonMap->ControllerID()) { using namespace GAME; CGameServices& gameServices = CServiceBroker::GetGameServices(); ControllerPtr controller = gameServices.GetController(m_actionMap->ControllerID()); const auto& features = controller->Layout().Features(); for (const auto& feature : features) { if (m_actionMap->GetActionID(feature.Name()) != ACTION_SELECT_ITEM) continue; CDriverPrimitive primitive; if (!m_buttonMap->GetScalar(feature.Name(), primitive)) continue; if (primitive.Type() != PRIMITIVE_TYPE::SEMIAXIS) continue; // Set initial config, as detection will fail because axis is already activated AxisConfiguration axisConfig; axisConfig.bKnown = true; axisConfig.center = primitive.Center(); axisConfig.range = primitive.Range(); GetAxis(primitive.Index(), primitive.Center(), axisConfig).SetEmitted(primitive); } } }
static void ButtonCallback(GLFWwindow *window, int b, int action, int mods) { double x, y; glfwGetCursorPos(window, &x, &y); gOldMouseX = x; gOldMouseY = y; bool quit = gSceneController->Button(b, action, mods, x, y); if(quit) glfwSetWindowShouldClose(window, GL_TRUE); }
void XboxdrvMain::init_controller(const ControllerPtr& controller) { m_jsdev_number = UInput::find_jsdev_number(); m_evdev_number = UInput::find_evdev_number(); if (m_opts.get_controller_slot().get_led_status() == -1) { controller->set_led(static_cast<uint8_t>(2 + m_jsdev_number % 4)); } else { controller->set_led(static_cast<uint8_t>(m_opts.get_controller_slot().get_led_status())); } if (m_opts.rumble_l != -1 && m_opts.rumble_r != -1) { // Only set rumble when explicitly requested controller->set_rumble(static_cast<uint8_t>(m_opts.rumble_l), static_cast<uint8_t>(m_opts.rumble_r)); } }
void XboxdrvDaemon::connect(ControllerSlotPtr slot, ControllerPtr controller) { log_info("connecting slot to thread"); try { // set the LED status if (slot->get_led_status() == -1) { controller->set_led(static_cast<uint8_t>(2 + (slot->get_id() % 4))); } else { controller->set_led(static_cast<uint8_t>(slot->get_led_status())); } } catch(const std::exception& err) { log_error("failed to set led: " << err.what()); } slot->connect(controller); on_connect(slot); log_info("controller connected: " << controller->get_usbpath() << " " << controller->get_usbid() << " " << "'" << controller->get_name() << "'"); log_info("launched Controller for " << controller->get_usbpath() << " in slot " << slot->get_id() << ", free slots: " << get_free_slot_count() << "/" << m_controller_slots.size()); }
void CGUIFeatureList::Load(const ControllerPtr& controller) { if (m_controller && m_controller->ID() == controller->ID()) return; // Already loaded CleanupButtons(); m_controller = controller; const std::vector<CControllerFeature>& features = controller->Layout().Features(); for (unsigned int buttonIndex = 0; buttonIndex < features.size(); buttonIndex++) { const CControllerFeature& feature = features[buttonIndex]; CGUIButtonControl* pButton = nullptr; switch (feature.Type()) { case JOYSTICK::FEATURE_TYPE::SCALAR: { pButton = new CGUIScalarFeatureButton(*m_guiButtonTemplate, m_wizard, feature, buttonIndex); break; } case JOYSTICK::FEATURE_TYPE::ANALOG_STICK: { pButton = new CGUIAnalogStickButton(*m_guiButtonTemplate, m_wizard, feature, buttonIndex); break; } default: break; } if (pButton) m_guiList->AddControl(pButton); // Just in case if (buttonIndex >= MAX_FEATURE_COUNT) break; } }
void read(NIFStream *nif) { next.read(nif); flags = nif->getUShort(); frequency = nif->getFloat(); phase = nif->getFloat(); timeStart = nif->getFloat(); timeStop = nif->getFloat(); target.read(nif); }
MultiKultiControllerPtr MultiKultiInstance::getBestMigrant(int nodeId){ vector<NewsItem*> * island = allItems[nodeId]; //int i = Rand::randint(0,island->size()); double bestFitness = island->at(0)->getContent()->GetOriginalFitness(); //cout<<"Island size"<<island->size()<<endl; int best = 0; //cout<<"0:"<<bestFitness<<endl; for(unsigned int i =1;i<island->size();i++){ double actualFitness = island->at(i)->getContent()->GetOriginalFitness(); //cout<<i<<":"<<actualFitness<<endl; if(actualFitness > bestFitness){ best = i; bestFitness = actualFitness; //cout<<"yay"<<endl; } } //cout<<"Received "<<best<<"from node "<<nodeId<<endl; ControllerPtr migrant = island->at(best)->getContent(); return boost::dynamic_pointer_cast<MultiKultiController>(migrant->Clone()); }
static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods) { if(action == GLFW_PRESS) { switch(key) { case 'W': gDrawWireframe = !gDrawWireframe; break; default: bool quit = gSceneController->Key(key, scancode, action, mods); if(quit) glfwSetWindowShouldClose(window, GL_TRUE); break; } } }
static void DrawFrame(GLFWwindow *window) { CheckOpenGL(__FILE__, __LINE__); chrono::time_point<chrono::system_clock> now = chrono::system_clock::now(); chrono::duration<float> elapsed_seconds = now - gSceneStartTime; float elapsed = elapsed_seconds.count(); gSceneController->Update(elapsed); gScenePreviousTime = now; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); CheckOpenGL(__FILE__, __LINE__); DrawScene(elapsed); CheckOpenGL(__FILE__, __LINE__); }
static void MotionCallback(GLFWwindow *window, double x, double y) { // glfw/glfw#103 // If no motion has been reported yet, we catch the first motion // reported and store the current location if(!gMotionReported) { gMotionReported = true; gOldMouseX = x; gOldMouseY = y; } double dx, dy; dx = x - gOldMouseX; dy = y - gOldMouseY; gOldMouseX = x; gOldMouseY = y; bool quit = gSceneController->Motion(dx, dy); if(quit) glfwSetWindowShouldClose(window, GL_TRUE); }
ControllerPtr PopulationControlArchitecture::selectParentByBinaryTournament(ControllerPtr exclude) { NewsItem *selectedSolutionA = population->randomNews(exclude); ControllerPtr parentA; if (selectedSolutionA != NULL) { if (debug) { cout << population->getId() << " - ParentA: " << selectedSolutionA->getAgentId() << " (" << selectedSolutionA->getTimestamp() << ")" << endl; } parentA = selectedSolutionA->getContent(); } if (parentA == NULL) { // the population gave us a NULL parent; generate a random one //cout << population->getId() << " - ParentA: NULL" << endl; if (debug) { cout << "Got NULL parent A, generating random parent A." << endl; } parentA = this->createRandomGenome(); } // select a second parent, excluding the first from the selection NewsItem *selectedSolutionB = population->randomNews(parentA, exclude); ControllerPtr parentB; if (selectedSolutionB != NULL) { if (debug) { cout << population->getId() << " - ParentB: " << selectedSolutionB->getAgentId() << " (" << selectedSolutionB->getTimestamp() << ")" << endl; } parentB = selectedSolutionB->getContent(); } if (parentB == NULL) { // the population gave us a NULL parent; generate a random one //cout << population->getId() << " - ParentB: NULL" << endl; if (debug) { cout << "Got NULL parent B, generating random parent B." << endl; } parentB = this->createRandomGenome(); } if (debug) { cout << "ParentA: " << parentA->GetOriginalFitness() << " vs ParentB: " << parentB->GetOriginalFitness() << endl; } if (parentA->GetOriginalFitness() > parentB->GetOriginalFitness()) { return parentA; } else { return parentB; } }
void post(NIFFile *nif) { Extra::post(nif); controller.post(nif); }
void read(NIFStream *nif) { Extra::read(nif); controller.read(nif); }
static void ScrollCallback(GLFWwindow *window, double dx, double dy) { bool quit = gSceneController->Scroll(dx, dy); if(quit) glfwSetWindowShouldClose(window, GL_TRUE); }
ControllerPtr PopulationControlArchitecture::getNextCandidate() { currentTime++; ControllerPtr candidate; // if there is no full list of active solutions yet, generate a new candidate randomly if (activeSolutions.size() < mu) { candidate = this->createRandomGenome(); if (debug) { cout << "Generated " << candidate->ToString() << endl; } } // get news from the population, spreading the active solution population->update(currentTime); // if there is a full list of active solutions, mutate an existing solution or re-evaluate an active to create a new candidate if (activeSolutions.size() == mu) { // decide whether to re-evaluate or mutate a controller if (Rand::randouble() < reEvaluationRate) { // re-evaluate // pick one of the active solutions for re-evaluation candidate = activeSolutions[Rand::randint(0, activeSolutions.size())]; if (debug) { cout << "Selected re-evaluation of " << candidate->ToShortString() << endl; } } else { // mutate existing // parent selection: random from the population ControllerPtr parentA = selectParentByBinaryTournament(ControllerPtr()); if (debug) { cout << "Selected first parent: " << parentA->ToShortString() << endl; } // crossover or clone; crossover only if there is a second active solution in the hivemind if (population->getActiveCount() > 1 && Rand::randouble() < crossoverRate) { if (debug) { cout << "Selecting second parent, from a choice of " << population->getActiveCount() << endl; } // crossover // select a second parent, excluding the first from the selection vector<ControllerPtr> *parents = new vector<ControllerPtr>(); parents->push_back(parentA); while (parents->size()<(unsigned) numberOfParents) { if (debug) { cout << parents->size() << endl; } ControllerPtr tmpC = selectParentsByBinaryTournament(parents); parents->push_back(tmpC); } // create a candidate from crossover between the parents candidate = parentA->crossOverWithMP(parents); if (debug) { cout << " Created " << candidate->ToShortString() << " from crossover between " << parents->at(0)->ToShortString(); for (uint i = 1; i < parents->size(); i++) cout << " and " << parents->at(i)->ToShortString(); cout << endl; } parents->clear(); delete parents; } else { // clone candidate = parentA->Clone(); if (debug) { cout << "Spawned " << candidate->ToShortString() << " from " << parentA->ToShortString() << endl; } } // mutation if (Rand::randouble() < mutationRate) { //cout << "Before mutation: " << candidate->ToString() << endl; candidate->mutate(); //cout << "After mutation: " << candidate->ToString() << endl; if (debug) { cout << "Mutated " << candidate->ToShortString() << endl; } } } } return candidate; }
void post(NIFFile *nif) { Record::post(nif); next.post(nif); target.post(nif); }
int main(int argc, char **argv) { const char *progname = argv[0]; if(argc < 2) { fprintf(stderr, "usage: %s filename # e.g. \"%s 64gon.builtin\"\n", progname, progname); exit(EXIT_FAILURE); } const char *scene_filename = argv[1]; GLFWwindow* window; glfwSetErrorCallback(ErrorCallback); if(!glfwInit()) exit(EXIT_FAILURE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_SAMPLES, 4); window = glfwCreateWindow(gWindowWidth = 512, gWindowHeight = 512, "Spin", NULL, NULL); if (!window) { glfwTerminate(); fprintf(stdout, "Couldn't open main window\n"); exit(EXIT_FAILURE); } glfwMakeContextCurrent(window); InitializeGL(); bool success; tie(success, gSceneRoot, gSceneController) = LoadScene(scene_filename); if(!success) { fprintf(stderr, "couldn't load scene from %s\n", scene_filename); exit(EXIT_FAILURE); } InitializeScene(gSceneRoot); if(gVerbose) { printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); printf("GL_VERSION: %s\n", glGetString(GL_VERSION)); } gSceneController->Resize(gWindowWidth, gWindowHeight); glfwSetKeyCallback(window, KeyCallback); glfwSetMouseButtonCallback(window, ButtonCallback); glfwSetCursorPosCallback(window, MotionCallback); glfwSetScrollCallback(window, ScrollCallback); glfwSetFramebufferSizeCallback(window, ResizeCallback); glfwSetWindowRefreshCallback(window, DrawFrame); gSceneStartTime = gScenePreviousTime = chrono::system_clock::now(); while (!glfwWindowShouldClose(window)) { DrawFrame(window); glfwSwapBuffers(window); if(gStreamFrames) glfwPollEvents(); else glfwWaitEvents(); } glfwTerminate(); }
static void ResizeCallback(GLFWwindow *window, int x, int y) { glfwGetFramebufferSize(window, &gWindowWidth, &gWindowHeight); glViewport(0, 0, gWindowWidth, gWindowHeight); gSceneController->Resize(gWindowWidth, gWindowHeight); }
bool CGameClientInput::OpenJoystick(const std::string &portAddress, const ControllerPtr &controller) { using namespace JOYSTICK; if (!controller) { CLog::Log(LOGERROR, "Failed to open port \"%s\", no controller given", portAddress.c_str()); return false; } const CControllerPortNode &port = m_controllers.GetPort(portAddress); if (!port.IsControllerAccepted(portAddress, controller->ID())) { CLog::Log(LOGERROR, "Failed to open port: Invalid controller \"%s\" on port \"%s\"", controller->ID().c_str(), portAddress.c_str()); return false; } std::string strId = controller->ID(); game_controller controllerStruct{}; controllerStruct.controller_id = strId.c_str(); controllerStruct.provides_input = controller->Topology().ProvidesInput(); controllerStruct.digital_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::DIGITAL); controllerStruct.analog_button_count = controller->FeatureCount(FEATURE_TYPE::SCALAR, INPUT_TYPE::ANALOG); controllerStruct.analog_stick_count = controller->FeatureCount(FEATURE_TYPE::ANALOG_STICK); controllerStruct.accelerometer_count = controller->FeatureCount(FEATURE_TYPE::ACCELEROMETER); controllerStruct.key_count = controller->FeatureCount(FEATURE_TYPE::KEY); controllerStruct.rel_pointer_count = controller->FeatureCount(FEATURE_TYPE::RELPOINTER); controllerStruct.abs_pointer_count = controller->FeatureCount(FEATURE_TYPE::ABSPOINTER); controllerStruct.motor_count = controller->FeatureCount(FEATURE_TYPE::MOTOR); bool bSuccess = false; { CSingleLock lock(m_clientAccess); if (m_gameClient.Initialized()) { try { bSuccess = m_struct.toAddon.ConnectController(true, portAddress.c_str(), &controllerStruct); } catch (...) { m_gameClient.LogException("ConnectController()"); } } } if (bSuccess) { m_joysticks[portAddress].reset(new CGameClientJoystick(m_gameClient, portAddress, controller, m_struct.toAddon)); ProcessJoysticks(); return true; } return false; }
void read(NIFFile *nif) { Extra::read(nif); controller.read(nif); }
void PopulationControlArchitecture::setCandidateFitness(ControllerPtr candidate, double scoredFitness) { // running evaluation has completed. Decide if the candidate will become the active solution. if (candidate->GetFitness() > -1) { // this is a re-evaluation, average out the previous and the new score if (debug) { cout << "This was a re-evaluation, not adding a new candidate" << endl; } candidate->SetFitness((candidate->GetFitness() + scoredFitness) / 2); if (debug || verbose) { cout << "Finished re-evaluating " << candidate->ToShortString() << " - fitness: " << scoredFitness << ", avg: " << candidate->GetFitness() << endl; } } else { candidate->SetFitness(scoredFitness); // this is a first evaluation and will need to be considered for placement as an active solution if (activeSolutions.size() < mu) { // there is no full set of active solutions yet, just add this solution activeSolutions.push_back(candidate); // send out a news item about the new active solution population->setNews(candidate->Clone(), activeSolutions.size() - 1, currentTime); } else { // there is a full list of active solutions, compete with the active solutions int worstIndex = -1; ControllerPtr worst = candidate; // find the worst controller in the (unsorted) list for (unsigned int i = 0; i < activeSolutions.size(); i++) { if (worst->GetFitness() > activeSolutions[i]->GetFitness()) { worst = activeSolutions[i]; worstIndex = i; } } // if the candidate is better than the worst controller in the list, have it take that controller's place if (scoredFitness > worst->GetFitness()) { if (debug) { cout << "This was first evaluation, candidate became active solution" << endl; } activeSolutions[worstIndex] = candidate; // send out a news item about the new active solution population->setNews(candidate->Clone(), worstIndex, currentTime); } else { if (debug) { cout << "This was first evaluation, candidate failed" << endl; } // the candidate has lost the competition; have it deleted // done automatically by smart pointer } } // Don't print if candidate was deleted if (candidate && (debug || verbose)) { cout << "Finished evaluating " << candidate->ToShortString() << " - fitness: " << scoredFitness << endl; } } if (!debug && !verbose) { // there has been no output on the fitness yet, do that now cout << scoredFitness << endl; } }