public func Activate(oCaller, oClonk) { if(!oClonk) oClonk = oCaller; // Effekt prüfen var iChkEff; if (iChkEff = CheckEffect("WarmPSpell", oExtiObj, 180)) return(iChkEff!=-1 && RemoveObject()); // Nächstes gerforenes Objekt finden var oExtiObj, iExtiCount, pObj; // Den Clonk selbst? if(Frozen(oClonk)) iExtiCount += DoUnfreeze(oClonk, oCaller); else if(oClonk->~MagicWarm(1800)) iExtiCount += DoUnfreeze(oClonk, oCaller); else if(pObj = Contents(0,oClonk)) if(GetID(pObj)==METL) if(GetDefHeight(ANML)) { RemoveObject(pObj); CreateContents(ANML, oClonk); return(RemoveObject()); } // Nächstliegende Objekte SetPosition(GetX(oCaller), GetY(oCaller)); // Suchradius ist abhängig von Höhe des Aufrufenden - ein Zauberturm hat einen größeren Radius var iSearchRadius = GetObjHeight(oCaller) * 3; while(oExtiObj = FindObject(0, 0, 0, -1, -1, 0, 0, 0, 0, oExtiObj)) if(ObjectDistance(oCaller, oExtiObj) > iSearchRadius) break; else if(Frozen(oExtiObj)) iExtiCount += DoUnfreeze(oExtiObj, oCaller); else if (oExtiObj->~MagicUnfreeze(oCaller)) iExtiCount += DoUnfreeze(oExtiObj, oCaller); // Irgendwas erwärmt? if (!iExtiCount) { Message("$NoUnfreeze$", oClonk); RemoveObject(); return 0; } // Einmaliger Effekt pro Zauber Sound("Inflame"); return(true); }
virtual const std::int64_t ElapsedAsMicroseconds(void) const final { if (Frozen()) return static_cast<std::int64_t>(std::chrono::duration_cast<std::chrono::microseconds>(m_TimeFreezePoint - m_TimeOrigin).count()); else return static_cast<std::int64_t>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now() - m_TimeOrigin ).count() ); }
/*! Return the elapsed time in seconds. Return duration between freeze point and last origin if frozen. */ virtual const double ElapsedAsSeconds(void) const final { if (Frozen()) return static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(m_TimeFreezePoint - m_TimeOrigin).count())/1000; else return static_cast<double> ( std::chrono::duration_cast<std::chrono::milliseconds> ( std::chrono::high_resolution_clock::now() - m_TimeOrigin ).count() )/1000; }
// Solve the diophantine system Ax = 0 and return a basis set for solutions // Reference: // Evelyne Contejean, Herve Devie. An Efficient Incremental Algorithm for // Solving // Systems of Linear Diophantine Equations. Information and computation, // 113(1):143-172, // August 1994. void homogeneous_lde(std::vector<DenseMatrix> &basis, const DenseMatrix &A) { unsigned p = A.nrows(); unsigned q = A.ncols(); unsigned n; SYMENGINE_ASSERT(p > 0 and q > 1); DenseMatrix row_zero(1, q); zeros(row_zero); DenseMatrix col_zero(p, 1); zeros(col_zero); std::vector<DenseMatrix> P; P.push_back(row_zero); std::vector<std::vector<bool>> Frozen(q, std::vector<bool>(q, true)); for (unsigned j = 0; j < q; j++) { Frozen[0][j] = false; } std::vector<bool> F(q, false); DenseMatrix t, transpose, product, T; RCP<const Integer> dot; product = DenseMatrix(p, 1); transpose = DenseMatrix(q, 1); while (P.size() > 0) { n = P.size() - 1; t = P[n]; P.pop_back(); t.transpose(transpose); A.mul_matrix(transpose, product); if (product.eq(col_zero) and not t.eq(row_zero)) { basis.push_back(t); } else { for (unsigned i = 0; i < q; i++) { F[i] = Frozen[n][i]; } T = t; for (unsigned i = 0; i < q; i++) { SYMENGINE_ASSERT(is_a<Integer>(*T.get(0, i))); T.set(0, i, rcp_static_cast<const Integer>(T.get(0, i)) ->addint(*one)); if (i > 0) { SYMENGINE_ASSERT(is_a<Integer>(*T.get(0, i - 1))); T.set(0, i - 1, rcp_static_cast<const Integer>(T.get(0, i - 1)) ->subint(*one)); } dot = zero; for (unsigned j = 0; j < p; j++) { SYMENGINE_ASSERT(is_a<Integer>(*product.get(j, 0))); RCP<const Integer> p_j0 = rcp_static_cast<const Integer>(product.get(j, 0)); SYMENGINE_ASSERT(is_a<Integer>(*A.get(j, i))); RCP<const Integer> A_ji = rcp_static_cast<const Integer>(A.get(j, i)); dot = dot->addint(*p_j0->mulint(*A_ji)); } if (F[i] == false and ((dot->is_negative() and is_minimum(T, basis, basis.size())) or t.eq(row_zero))) { P.push_back(T); n = n + 1; for (unsigned j = 0; j < q; j++) { Frozen[n - 1][j] = F[j]; } F[i] = true; } } } } }