bool RippleAddress::setSeedGeneric (const std::string& strText) { RippleAddress naTemp; bool bResult = true; uint256 uSeed; if (strText.empty () || naTemp.setAccountID (strText) || naTemp.setAccountPublic (strText) || naTemp.setAccountPrivate (strText) || naTemp.setNodePublic (strText) || naTemp.setNodePrivate (strText)) { bResult = false; } else if (strText.length () == 32 && uSeed.SetHex (strText, true)) { setSeed (uSeed); } else if (setSeed (strText)) { // Log::out() << "Recognized seed."; nothing (); } else { // Log::out() << "Creating seed from pass phrase."; setSeed (EdKeyPair::passPhraseToKey (strText)); } return bResult; }
int LinearGenerator::toGenerate() { setSeed(myRand()); while((getSeed() > getMaxValue()) || (getSeed() < getMinValue())) setSeed(myRand()); print(std::cout); return getSeed(); }
/** * Random returns a pseudo-random real number uniformly distributed * between 0.0 and 1.0. */ Rand::floatType Rand::random() { const intType Q = MODULUS / MULTIPLIER; const intType R = MODULUS % MULTIPLIER; intType t = MULTIPLIER * ( getSeed() % Q) - R * (getSeed() / Q); if (t > 0) setSeed(t); else setSeed(t + MODULUS); return ( static_cast<floatType>(getSeed()) / MODULUS); }
int DefaultGenerator::toGenerate() { srand(getSeed()); setSeed(getMinValue() + rand() % getMaxValue()); while((getSeed() > getMaxValue()) || (getSeed() < getMinValue())) setSeed(getMinValue() + rand() % getMaxValue()); print(cout); return getSeed(); }
Random::Random() { int left = 1; int initf = 0; //setSeed( GetTickCount() ); setSeed(0); }
bool Random::setSlotSeed(const Basic::Number* const seed) { bool ok = false; if (seed != 0) ok = setSeed(seed->getInt()); return ok; }
/* tuneControl: * Use user values to reset control * * Possible parameters: * ctrl->use_node_weights */ static void tuneControl (graph_t* g, spring_electrical_control ctrl) { long seed; int init; seed = ctrl->random_seed; init = setSeed (g, INIT_RANDOM, &seed); if (init != INIT_RANDOM) { agerr(AGWARN, "sfdp only supports start=random\n"); } ctrl->random_seed = seed; ctrl->K = late_double(g, agfindgraphattr(g, "K"), -1.0, 0.0); ctrl->p = -1.0*late_double(g, agfindgraphattr(g, "repulsiveforce"), -AUTOP, 0.0); ctrl->multilevels = late_int(g, agfindgraphattr(g, "levels"), INT_MAX, 0); ctrl->smoothing = late_smooth(g, agfindgraphattr(g, "smoothing"), SMOOTHING_NONE); ctrl->tscheme = late_quadtree_scheme(g, agfindgraphattr(g, "quadtree"), QUAD_TREE_NORMAL); /* ctrl->method = late_mode(g, agfindgraphattr(g, "mode"), METHOD_SPRING_ELECTRICAL); */ ctrl->method = METHOD_SPRING_ELECTRICAL; ctrl->beautify_leaves = mapBool (agget(g, "beautify"), FALSE); ctrl->rotation = late_double(g, agfindgraphattr(g, "rotation"), 0.0, -MAXDOUBLE); ctrl->edge_labeling_scheme = late_int(g, agfindgraphattr(g, "label_scheme"), 0, 0); if (ctrl->edge_labeling_scheme > 4) { agerr (AGWARN, "label_scheme = %d > 4 : ignoring\n", ctrl->edge_labeling_scheme); ctrl->edge_labeling_scheme = 0; } }
Enco3D::Core::Random::Random() { time_t t; time(&t); srand(t); setSeed(rand()); }
/** * Constructor taking a seed value and a range * @param seedValue :: The initial seed * @param start :: The minimum value a generated number should take * @param end :: The maximum value a generated number should take */ MersenneTwister::MersenneTwister(const size_t seedValue, const double start, const double end) : m_generator(), m_uniform_dist(), m_currentSeed(), m_savedStateGenerator(NULL) { setSeed(seedValue); setRange(start, end); }
static void generalWaveXpand(int x, int y) { //int totalcells = MAX_COL_INDEX*MAX_ROW_INDEX; int cellcount = 0; int i,j,changeflag = 1; setSeed(x,y); cellcount ++; // printf("cells on obstacles %i\n",cellcount); //while(cellcount<totalcells) while(changeflag) { changeflag = 0; for (i=0;i<MAX_COL_INDEX;i++) { for (j=0;j<MAX_ROW_INDEX;j++) { if (setNeighborsVal(i,j)) { cellcount++; changeflag = 1; } //printf("cell count %i\n",cellcount); } } } }
//! (ctor) Rand::Rand(intType initialSeed/*=0*/) { if (initialSeed<=0) generateSeed(); else setSeed(initialSeed); //ctor }
int main(){ setSeed(); //set random number seed beginGame(); //set chips=1000, print intro shuffle(); while (playing) { setup(); //shuffle deck, reset starting values makeBet(); //give initial bet amount dealBlackJack(); //deal player and dealer hands if (playerBlackjack()){ //check for player blackjack win(); input=0; } else play(); //player plays Hand if (input!=0){ //if player didnt bust or blackjack playDealer(); endRound(); } if (playing) { //continue to next round pad(15); printf("Next Round...\n\n"); } } }
EMOPSO::EMOPSO() { setPopSize(40); setBinarySize(0); setFloatSize(4); setGenerations(625); setNumberOfClusters(3); setSeed(1); for (int i = 0; i != getFloatSize() ; i++) { setFLLimit(-5,i); setFHLimit(5,i); } setMaxArchiveSize(100); setSocialAcc(2.0); setCognitiveAcc(2.0); setInertia(0.4); setFlyTime(5); nclusters= 3; gen=0; archive = new EFILE; }
void GillespieIntegrator::setSimulateOptions(const SimulateOptions* o) { if (o) { options = *o; if(options.hasKey("stoichScale")) { Log(Logger::LOG_NOTICE) << "getting stoichScale"; stoichScale = options.getItem("stoichScale").convert<double>(); Log(Logger::LOG_NOTICE) << "new stoichScale: " << stoichScale; } if(options.hasKey("timeScale")) { Log(Logger::LOG_NOTICE) << "getting timeScale"; timeScale = options.getItem("timeScale").convert<double>(); Log(Logger::LOG_NOTICE) << "new timeScale: " << timeScale; } if(options.hasKey("seed") && !options.getItem("seed").isEmpty()) { setSeed(options.getItem("seed")); } } }
RNG::RNG() { struct timeval tim; gettimeofday(&tim, NULL); int t=(int)tim.tv_usec; int r = rand(); setSeed(t+ r + time(NULL)); }
void test_random_rand(){ Random* r = new_random(); setSeed(r, 1); int i; for(i = 0; i < 5; ++i){ printf("nextRand = %d\n", nextRand(r)); } }
void TurbulenceModule::read (utils::InStream &s) { mPower = s.readDouble (); setRoughness (s.readInt()); setSeed (s.readInt()); setFrequency (s.readDouble()); setQuality (s.readInt()); }
void dataset::rand_split(UNSIGNED_4B_TYPE nFraction, UNSIGNED_1B_TYPE nActClasses, bool eqlSizeActBin, set *pExcl) {//random pick of nFraction; can keep activity distribution UNSIGNED_1B_TYPE nBins = max(nActClasses, 1); UNSIGNED_4B_TYPE Nmls = act.length(); if (Nmls < 2) return; set setSeed(0, Nmls); apvector<SIGNED_4B_TYPE> spnts(sact); UNSIGNED_4B_TYPE i, r, added, currNmls; apvector<UNSIGNED_4B_TYPE> actNmls(nBins, Nmls / nBins), testNmls(nBins, UNSIGNED_4B_TYPE(ceil(REALNUM_TYPE(nFraction) / nBins)) ); if (nBins > 1) { get_act_bins(actNmls, nBins, eqlSizeActBin); for (i = 0; i < nBins; i++) testNmls[i] = (actNmls[i] * nFraction) / Nmls; //check testNmls for (r = i = 0; i < nBins; i++) r += testNmls[i]; for (i = 0; i < nBins; i++) { if (r == nFraction) break; if (r < nFraction) { testNmls[i]++; r++; }; if (r > nFraction) { testNmls[i]--; r--; }; } } else setSeed.GetList(spnts); //no need to use ids sorted by activity, will be activity-independent. test.Dump(); for (currNmls = added = i = 0; i < nBins; i++) if (testNmls[i]) { Nmls = actNmls[i]; set tNmls; while ( (actNmls[i] < Nmls + testNmls[i]) && (added < nFraction) ) {//get randomly some portion r = currNmls + GetRandomNumber(Nmls); //check against the subset of points to be excluded if (pExcl) while (pExcl->IsInSet(spnts[r]) && (UNSIGNED_4B_TYPE(tNmls.Size()) < Nmls) ) { tNmls.PutInSet(spnts[r]); r = currNmls + GetRandomNumber(Nmls); } if (UNSIGNED_4B_TYPE(tNmls.Size()) == Nmls) break; //to prevent a case when a bin is totally covered by pExcl test.PutInSet(spnts[r]); added++; spnts[r] = spnts[--Nmls + currNmls]; } currNmls += actNmls[i]; if (added == nFraction) break; } train = setSeed - test; }
SamplingAlgorithmOptions_Impl::SamplingAlgorithmOptions_Impl() : DakotaAlgorithmOptions_Impl() { saveOption(Attribute("samples",5)); saveOption(Attribute("allVariables",false)); saveOption(Attribute("varianceBasedDecomp",false)); saveOption(Attribute("dropTolerance",false)); saveOption(Attribute("fixedSeed",false)); setSeed(std::max<int>(rand(),1)); }
SeedPrompt::SeedPrompt(QWidget* parent, const QString & seed, bool editable) : QDialog(parent) { setModal(true); setWindowFlags(Qt::Sheet); setWindowModality(Qt::WindowModal); setMinimumSize(360, 160); resize(360, 160); setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); // Layout QVBoxLayout * dialogLayout = new QVBoxLayout(this); // Label QLabel * label = new QLabel(tr("The map seed is the basis for all random values generated by the game.")); label->setWordWrap(true); dialogLayout->addWidget(label, 0); // Input box editBox = new QLineEdit(); editBox->setText(seed); editBox->setReadOnly(!editable); editBox->setStyleSheet("QLineEdit { padding: 3px; }"); dialogLayout->addWidget(editBox, 1); dialogLayout->addStretch(1); // Buttons QHBoxLayout * buttonLayout = new QHBoxLayout(); buttonLayout->addStretch(1); dialogLayout->addLayout(buttonLayout); if (editable) { QPushButton * btnCancel = new QPushButton(tr("Cancel")); QPushButton * btnOkay = new QPushButton(tr("Set seed")); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); connect(btnOkay, SIGNAL(clicked()), this, SLOT(accept())); #ifdef Q_OS_MAC buttonLayout->addWidget(btnCancel); buttonLayout->addWidget(btnOkay); #else buttonLayout->addWidget(btnOkay); buttonLayout->addWidget(btnCancel); #endif btnOkay->setDefault(true); } else { QPushButton * btnClose = new QPushButton(tr("Close")); connect(btnClose, SIGNAL(clicked()), this, SLOT(reject())); buttonLayout->addWidget(btnClose); btnClose->setDefault(true); } setStyleSheet("QPushButton { padding: 5px; }"); connect(this, SIGNAL(accepted()), this, SLOT(setSeed())); }
CClctrl::CClctrl(int arc, char** arv) : argc(arc), argv(arv) { argNo=1; fileFormat = 0; // svmlight format verbosity = 2; // second highest level (highest is 3) time_t seconds; time(&seconds); setSeed((unsigned long) seconds); }
void PertyOp::_configure() { ConfigOptions configOptions(_settings); setRandomError(configOptions.getPertyRandomErrorX(), configOptions.getPertyRandomErrorY()); setSystematicError( configOptions.getPertySystematicErrorX(), configOptions.getPertySystematicErrorY()); setGridSpacing(configOptions.getPertyGridSpacing()); setCsmParameters(configOptions.getPertyCsmBeta(), configOptions.getPertyCsmD()); setPermuteAlgorithm(configOptions.getPertyAlgorithm()); setSeed(configOptions.getPertySeed()); setNamedOps(configOptions.getPertyOps()); }
/** * Set up the noise/signal generator * * Description:\n * Set the parameters for the noise generator, including seed, average * noise power and bandwidth.\n\n * Notes:\n * This initializes the signal generator, resetting all counters and * summing registers. Any previously added signals are removed. */ void Gaussian::setup(int32_t seed_, float64_t bandwidthMHz_, float64_t avgPower_) { setSeed(seed_); setBandwidth(bandwidthMHz_); setNoisePower(avgPower_); sampleCnt = 0; power = ComplexFloat64(0, 0); sum = ComplexFloat64(0, 0); for (SigList::iterator s = signals.begin(); s != signals.end(); ++s) delete s->sig; signals.clear(); }
bool RippleAddress::setSeedGeneric(const std::string& strText) { RippleAddress naTemp; bool bResult = true; uint128 uSeed; if (strText.empty() || naTemp.setAccountID(strText) || naTemp.setAccountPublic(strText) || naTemp.setAccountPrivate(strText) || naTemp.setNodePublic(strText) || naTemp.setNodePrivate(strText)) { bResult = false; } else if (strText.length() == 32 && uSeed.SetHex(strText, true)) { setSeed(uSeed); } else if (setSeed(strText)) { // std::cerr << "Recognized seed." << std::endl; nothing(); } else if (1 == setSeed1751(strText)) { // std::cerr << "Recognized 1751 seed." << std::endl; nothing(); } else { // std::cerr << "Creating seed from pass phrase." << std::endl; setSeed(CKey::PassPhraseToKey(strText)); } return bResult; }
int RippleAddress::setSeed1751(const std::string& strHuman1751) { std::string strKey; int iResult = eng2key(strKey, strHuman1751); if (1 == iResult) { std::vector<unsigned char> vchLittle(strKey.rbegin(), strKey.rend()); uint128 uSeed(vchLittle); setSeed(uSeed); } return iResult; }
int RippleAddress::setSeed1751 (const std::string& strHuman1751) { std::string strKey; int iResult = RFC1751::getKeyFromEnglish (strKey, strHuman1751); if (1 == iResult) { Blob vchLittle (strKey.rbegin (), strKey.rend ()); uint128 uSeed (vchLittle); setSeed (uSeed); } return iResult; }
void TrainTrees( const TreeLearnerI* treeLearner, const BufferCollectionStack& data, int treeStartIndex, int treeStride, int numberOfTrees, Forest* forestOut ) { for(int i=treeStartIndex; i<numberOfTrees; i+=treeStride) { TimeLogger totalTree(forestOut->mTrees[i].GetExtraInfo(), "ParallelForestLearner"); unsigned long seedInt = i + static_cast<unsigned long>(std::time(NULL)) + reinterpret_cast<unsigned long>(treeLearner); setSeed(seedInt); //set bootstrap seed treeLearner->Learn(data, forestOut->mTrees[i], seedInt); } }
/* * Routine: initSparseKeys() * Purpose: set up the set of valid key values for a sparse table. * Algorithm: * Data Structures: * * Params: * Returns: * Called By: * Calls: * Assumptions: The total population will fit in 32b * Side Effects: * TODO: None */ int initSparseKeys(int nTable) { ds_key_t kRowcount, kOldSeed; int k; tdef *pTdef; kRowcount = get_rowcount(nTable); pTdef = getTdefsByNumber(nTable); pTdef->arSparseKeys = (ds_key_t *)malloc((long)kRowcount * sizeof(ds_key_t)); MALLOC_CHECK(pTdef->arSparseKeys); if (pTdef->arSparseKeys == NULL) ReportError(QERR_NO_MEMORY, "initSparseKeys()", 1); memset(pTdef->arSparseKeys, 0, (long)kRowcount * sizeof(ds_key_t)); kOldSeed = setSeed(0, nTable); for (k = 0; k < kRowcount; k++) genrand_key(&pTdef->arSparseKeys[k], DIST_UNIFORM, 1, pTdef->nParam, 0, 0); setSeed(0, (int)kOldSeed); return(0); }
int IsdnTest::NObjRndPatternGenSettings::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { typedef Domain::NamedObject QMocSuperClass; _id = QMocSuperClass::qt_metacall(_c, _id, _a); if (_id < 0) return _id; #ifndef QT_NO_PROPERTIES if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = getSeed(); break; case 1: *reinterpret_cast< int*>(_v) = getChangeBytesChancePercent(); break; case 2: *reinterpret_cast< int*>(_v) = getMaxChangeBits(); break; case 3: *reinterpret_cast< int*>(_v) = getCutBytesChancePercent(); break; case 4: *reinterpret_cast< int*>(_v) = getMaxCutBytes(); break; case 5: *reinterpret_cast< int*>(_v) = getAddBytesChancePercent(); break; case 6: *reinterpret_cast< int*>(_v) = getMaxAddBytes(); break; } _id -= 7; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setSeed(*reinterpret_cast< int*>(_v)); break; case 1: setChangeBytesChancePercent(*reinterpret_cast< int*>(_v)); break; case 2: setMaxChangeBits(*reinterpret_cast< int*>(_v)); break; case 3: setCutBytesChancePercent(*reinterpret_cast< int*>(_v)); break; case 4: setMaxCutBytes(*reinterpret_cast< int*>(_v)); break; case 5: setAddBytesChancePercent(*reinterpret_cast< int*>(_v)); break; case 6: setMaxAddBytes(*reinterpret_cast< int*>(_v)); break; } _id -= 7; } else if (_c == QMetaObject::ResetProperty) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 7; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 7; } #endif // QT_NO_PROPERTIES return _id; }
vertex_t* create_vertices(int nsym2, int nvertex, int maxsucc, int nactive, bool print_input){ vertex_t* vertices; nsym = nsym2; bitset_size = 50*(nsym / (sizeof(unsigned int) * 8)) + 1; Random* r = new_random(); setSeed(r, 1); void* tmp; posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) sizeof(vertex_t) * nvertex); vertices = tmp; for(int i = 0; i < nvertex; ++i){ vertices[i].index = i; vertices[i].listed = false; //posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) maxsucc); vertices[i].pred_list = NULL; vertices[i].pred_count = 0; //posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) maxsucc); vertices[i].succ_list = NULL; vertices[i].succ_count = 0; //vertices[i].pred_list = create_node(NULL); //First element = NULL //vertices[i].succ_list = create_node(NULL); //First element = NULL posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) bitset_size); vertices[i].in = tmp; posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) bitset_size); vertices[i].out = tmp; posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) bitset_size); vertices[i].use = tmp; posix_memalign(&tmp, (size_t) ALIGN_CONSTANT, (size_t) bitset_size); vertices[i].def = tmp; // Instead of using a homegrown calloc_align.. for(int j = 0; j < (int)(nsym / (sizeof(unsigned int) * 8)+1 ); ++j){ vertices[i].in[j] = 0; vertices[i].out[j] = 0; vertices[i].use[j] = 0; vertices[i].def[j] = 0; } } generateCFG(vertices, nvertex, maxsucc, r, print_input); generateUseDef(vertices, nvertex, nsym, nactive, r, print_input); return vertices; }