Esempio n. 1
0
void CEntityPropertyHandler::SetProperty(IEntity *pIEntity, int index, const char *value)
{
	EntityId id = pIEntity->GetId();

	CMonoEntityExtension *pEntity = nullptr;
	if (IGameObject *pGameObject = static_cast<CScriptSystem *>(GetMonoScriptSystem())->GetIGameFramework()->GetGameObject(id))
		pEntity = static_cast<CMonoEntityExtension *>(pGameObject->QueryExtension(pIEntity->GetClass()->GetName()));

	// Only true after game has started, limiting this to changes made in Editor.
	if(pEntity && pEntity->IsInitialized())
		pEntity->SetPropertyValue(m_pProperties[index].info, value);
	else
	{
		bool exists = false;
		for(auto it = m_queuedProperties.begin(); it != m_queuedProperties.end(); ++it)
		{
			if((*it).first == id)
			{
				(*it).second.push_back(SQueuedProperty(m_pProperties[index].info, value));

				exists = true;
				break;
			}
		}
		if(!exists)
		{
			DynArray<SQueuedProperty> queuedPropertiesForEntity;
			queuedPropertiesForEntity.push_back(SQueuedProperty(m_pProperties[index].info, value));

			m_queuedProperties.insert(TQueuedPropertyMap::value_type(id, queuedPropertiesForEntity));
		}
	}
}
Esempio n. 2
0
int main (int argl, char ** argc) {
	
	DynArray <char *> files;
	
	for (int i=1; i<argl; ++i) {
		if (argc [i][0] == '-') {
			if (string (argc [i]) == "--help") {
				printHelp (argc [0]);
				return 0;
			}
		} else {
			files.push_back (argc [i]);
		}
	}
	
	if (files.empty ()) {
		
		string line, prog;
		while (std::getline (std::cin, line)) {
			if (not line.empty ()) {
				prog += line + "\n";
			} else if (not prog.empty ()) {
				auto n = parse (prog);
				print (n);
				delete n;
				std::cout << std::endl;
				prog = line;
			}
		}
		if (not prog.empty()) {
			auto n = parse (prog);
			print (n);
			delete n;
		}
		
	} else {
		for (char * f : files) {
			std::ifstream fin (f);
			string buff, prog;
			while (std::getline (fin, buff)) prog += buff + "\n";
			std::cout << "########" << f << "########" << std::endl;
			auto n = parse (prog);
			print (n);
			delete n;
			std::cout << "########" << f << "########" << std::endl;
		}
	}
	
	return 0;
	
}
Esempio n. 3
0
void CFlowGraphDebugger::FillDynArray(DynArray<SBreakPoint>& breakpointsDynArray, TFlowPortIDS portIDS, IFlowGraphPtr pFlowgraph, TFlowNodeId nodeID, bool bIsOutput)
{
	TFlowPortIDS::const_iterator iterPorts = portIDS.begin();
	for (iterPorts; iterPorts != portIDS.end(); ++iterPorts)
	{
		TFlowPortId port = (*iterPorts).portID;
		SBreakPoint breakpoint;
		breakpoint.flowGraph = pFlowgraph;
		breakpoint.addr.node = nodeID;
		breakpoint.addr.port = port;
		breakpoint.addr.isOutput = bIsOutput;

		breakpointsDynArray.push_back(breakpoint);
	}
}
Esempio n. 4
0
float64_t CBaggingMachine::get_oob_error(CEvaluation* eval) const
{
	REQUIRE(m_combination_rule != NULL, "Combination rule is not set!");
	REQUIRE(m_bags->get_num_elements() > 0, "BaggingMachine is not trained!");

	SGMatrix<float64_t> output(m_features->get_num_vectors(), m_bags->get_num_elements());
	if (m_labels->get_label_type() == LT_REGRESSION)
		output.zero();
	else
		output.set_const(NAN);

	/* TODO: add parallel support of applying the OOBs
	  only possible when add_subset is thread-safe
	#pragma omp parallel for num_threads(parallel->get_num_threads())
	*/
	for (index_t i = 0; i < m_bags->get_num_elements(); i++)
	{
		CMachine* m = dynamic_cast<CMachine*>(m_bags->get_element(i));
		CDynamicArray<index_t>* current_oob 
			= dynamic_cast<CDynamicArray<index_t>*>(m_oob_indices->get_element(i));

		SGVector<index_t> oob(current_oob->get_array(), current_oob->get_num_elements(), false);
		oob.display_vector();
		m_features->add_subset(oob);

		CLabels* l = m->apply(m_features);
		SGVector<float64_t> lv = l->get_values();

		// assign the values in the matrix (NAN) that are in-bag!
		for (index_t j = 0; j < oob.vlen; j++)
			output(oob[j], i) = lv[j];

		m_features->remove_subset();
		SG_UNREF(current_oob);
		SG_UNREF(m);
		SG_UNREF(l);
	}
	output.display_matrix();

	DynArray<index_t> idx;
	for (index_t i = 0; i < m_features->get_num_vectors(); i++)
	{
		if (m_all_oob_idx[i])
			idx.push_back(i);
	}

	SGVector<float64_t> combined = m_combination_rule->combine(output);
	CLabels* predicted = NULL;
	switch (m_labels->get_label_type())
	{
		case LT_BINARY:
			predicted = new CBinaryLabels(combined);
			break;

		case LT_MULTICLASS:
			predicted = new CMulticlassLabels(combined);
			break;

		case LT_REGRESSION:
			predicted = new CRegressionLabels(combined);
			break;

		default:
			SG_ERROR("Unsupported label type\n");
	}
	
	m_labels->add_subset(SGVector<index_t>(idx.get_array(), idx.get_num_elements(), false));
	float64_t res = eval->evaluate(predicted, m_labels);
	m_labels->remove_subset();

	return res;
}