本文整理汇总了C++中GetRand函数的典型用法代码示例。如果您正苦于以下问题:C++ GetRand函数的具体用法?C++ GetRand怎么用?C++ GetRand使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetRand函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0xfd;
pchMessageStart[1] = 0xa4;
pchMessageStart[2] = 0xdc;
pchMessageStart[3] = 0x6c;
vAlertPubKey = ParseHex("04d1832d7d0c59634d67d3023379403014c2878d0c2372d175219063a48fa06e6d429e09f36d3196ec544c2cfdd12d6fe510a399595f75ebb6da238eb5f70f2072");
nDefaultPort = 12340;
nRPCPort = 12341;
bnProofOfWorkLimit[ALGO_SHA256D] = CBigNum(~uint256(0) >> 20); // 1.00000000
bnProofOfWorkLimit[ALGO_SCRYPT] = CBigNum(~uint256(0) >> 20);
bnProofOfWorkLimit[ALGO_GROESTL] = CBigNum(~uint256(0) >> 20); // 0.00195311
bnProofOfWorkLimit[ALGO_SKEIN] = CBigNum(~uint256(0) >> 20); // 0.00195311
bnProofOfWorkLimit[ALGO_QUBIT] = CBigNum(~uint256(0) >> 20); // 0.00097655
// Build the genesis block.
const char* pszTimestamp = "Visir 10. oktober 2008 Gjaldeyrishoft sett a Islendinga";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 1 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04a5814813115273a109cff99907ba4a05d951873dae7acb6c973d0c9e7c88911a3dbc9aa600deac241b91707e7b4ffb30ad91c8e56e695a1ddf318592988afe0a") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1390598806;
genesis.nBits = Params().ProofOfWorkLimit(ALGO_SCRYPT).GetCompact();
//genesis.nBits = 0x1e0fffff;
genesis.nNonce = 538548;
hashGenesisBlock = genesis.GetHash();
assert(hashGenesisBlock == uint256("0x2a8e100939494904af825b488596ddd536b3a96226ad02e0f7ab7ae472b27a8e"));
assert(genesis.hashMerkleRoot == uint256("0x8957e5e8d2f0e90c42e739ec62fcc5dd21064852da64b6528ebd46567f222169"));
vSeeds.push_back(CDNSSeedData("luxembourgh", "s1.auroraseed.net"));
vSeeds.push_back(CDNSSeedData("united-states-west", "aurseed1.criptoe.com"));
vSeeds.push_back(CDNSSeedData("united-states-east", "s1.auroraseed.com"));
vSeeds.push_back(CDNSSeedData("iceland", "s1.auroraseed.org"));
vSeeds.push_back(CDNSSeedData("the-netherlands", "s1.auroraseed.eu"));
vSeeds.push_back(CDNSSeedData("electrum2", "electrum2.aurorcoin.is"));
vSeeds.push_back(CDNSSeedData("electrum3", "electrum3.auroracoin.is"));
vSeeds.push_back(CDNSSeedData("electrum4", "electrum4.auroracoin.is"));
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,23);
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,176);
base58Prefixes[SECRET_KEY_OLD] = std::vector<unsigned char>(1,151);
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
const int64_t nOneWeek = 7*24*60*60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nOneWeek) - nOneWeek;
vFixedSeeds.push_back(addr);
}
}
示例2: DamageCalc
static int DamageCalc( Character_t Attacker, Character_t Defender ){
// 通常攻撃の計算式の答えを返す
return (int)( Attacker.LEVEL*2*Attacker.Power /Defender.Defense +2 )*( 85+ GetRand(15) )/100;
}
示例3: EnemyBulletInit
//敵弾の初期設定
void EnemyBulletInit(){
for(int i=0; i<EnemyBulletNum; i++){
EnemyBullet[i].flag = false;
EnemyBullet[i].interval = GetRand(5)*60;
}
}
示例4: GetRand
/**
Set random shape
*/
void Tetromino::NewShape()
{
int rand = GetRand(0, 6);
mColor = GetRand(1, 7);
if(rand == 0) // O
{
mShape = 0;
mWidth = 2;
mHeight = 2;
int temp[2][2] = {{mColor, mColor}, {mColor, mColor}};
mShape = new int*[mHeight];
for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];
for(int row=0; row<mHeight; row++)
{
for(int col=0; col<mWidth; col++)
{
mShape[row][col] = temp[row][col];
}
}
}
else if(rand == 1) // I
{
mShape = 0;
mWidth = 1;
mHeight = 4;
mShape = new int*[mHeight];
for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];
int temp[4][1] = {{mColor}, {mColor}, {mColor}, {mColor}};
for(int row=0; row<mHeight; row++)
{
for(int col=0; col<mWidth; col++)
{
mShape[row][col] = temp[row][col];
}
}
}
else if(rand == 2) // L
{
mShape = 0;
mWidth = 2;
mHeight = 3;
mShape = new int*[mHeight];
for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];
int temp[3][2] = {{mColor, 0}, {mColor, 0}, {mColor, mColor}};
for(int row=0; row<mHeight; row++)
{
for(int col=0; col<mWidth; col++)
{
mShape[row][col] = temp[row][col];
}
}
}
else if(rand == 3) // J
{
mShape = 0;
mWidth = 2;
mHeight = 3;
mShape = new int*[mHeight];
for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];
int temp[3][2] = {{0, mColor}, {0, mColor}, {mColor, mColor}};
for(int row=0; row<mHeight; row++)
{
for(int col=0; col<mWidth; col++)
{
mShape[row][col] = temp[row][col];
}
}
}
else if(rand == 4) // S
{
mShape = 0;
mWidth = 3;
mHeight = 2;
mShape = new int*[mHeight];
for(int i=0; i<mHeight; i++) mShape[i] = new int[mWidth];
int temp[2][3] = {{0, mColor, mColor}, {mColor, mColor, 0}};
for(int row=0; row<mHeight; row++)
{
for(int col=0; col<mWidth; col++)
{
//.........这里部分代码省略.........
示例5: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
// The characters are rarely used upper ASCII, not valid as UTF-8, and produce
// a large 4-byte int at any alignment.
pchMessageStart[0] = 0xc7;
pchMessageStart[1] = 0xa1;
pchMessageStart[2] = 0xf6;
pchMessageStart[3] = 0xc9; //chimark
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
nDefaultPort = 58778;
nRPCPort = 58777;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 770000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
//
const char* pszTimestamp = "Dec 2013 light speed X-day";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 1 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1389429187;
genesis.nBits = 0x1e0fffff; //chimark
genesis.nNonce = 1030111;
hashGenesisBlock = genesis.GetHash();
//// debug print
//while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
// hashGenesisBlock = genesis.GetHash();
//}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("%x\n", bnProofOfWorkLimit.GetCompact());
genesis.print();
assert(hashGenesisBlock == uint256("0x00000a8f9572e068cffbdb30c23f698e659e1e2e13e51cfcb8114fa5df38ffee"));
assert(genesis.hashMerkleRoot == uint256("0x91c7edee50dd32d8544412f4cef06f8812723eefe8fec24fd3e66d92f83b1b9e"));
vSeeds.push_back(CDNSSeedData("chicoin.sipa.be", "seed.chicoin.sipa.be"));
vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me"));
vSeeds.push_back(CDNSSeedData("dashjr.org", "dnsseed.chicoin.dashjr.org"));
vSeeds.push_back(CDNSSeedData("xf2.org", "bitseed.xf2.org"));
base58Prefixes[PUBKEY_ADDRESS] = 27;
base58Prefixes[SCRIPT_ADDRESS] = 29;
base58Prefixes[SECRET_KEY] = 127;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}
示例6: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0xf8;
pchMessageStart[1] = 0xb5;
pchMessageStart[2] = 0x03;
pchMessageStart[3] = 0xdf;
vAlertPubKey = ParseHex("04f09702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
nDefaultPort = 12835;
nRPCPort = 12832;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 950000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
const char* pszTimestamp = "February 5, 2014: The Black Hills are not for sale - 1868 Is The LAW!";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 5000 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1390747675;
genesis.nBits = 0x1e0ffff0;
genesis.nNonce = 2091390249;
//// debug print
hashGenesisBlock = genesis.GetHash();
//while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
// hashGenesisBlock = genesis.GetHash();
//}
//printf("%s\n", hashGenesisBlock.ToString().c_str());
//printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
//printf("%x\n", bnProofOfWorkLimit.GetCompact());
//genesis.print();
assert(hashGenesisBlock == uint256("0x00000c7c73d8ce604178dae13f0fc6ec0be3275614366d44b1b4b5c6e238c60c"));
assert(genesis.hashMerkleRoot == uint256("0x62d496378e5834989dd9594cfc168dbb76f84a39bbda18286cddc7d1d1589f4f"));
vSeeds.push_back(CDNSSeedData("node.Maza.org", "node.Maza.org"));
vSeeds.push_back(CDNSSeedData("node.Maza.cf", "node.Maza.cf"));
vSeeds.push_back(CDNSSeedData("Maza.no-ip.org", "Maza.no-ip.org"));
base58Prefixes[PUBKEY_ADDRESS] = 50;
base58Prefixes[SCRIPT_ADDRESS] = 9;
base58Prefixes[SECRET_KEY] = 224;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}
示例7: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0x06;
pchMessageStart[1] = 0x03;
pchMessageStart[2] = 0x04;
pchMessageStart[3] = 0x01;
nDefaultPort = 2222; //Ring was forged in the second age
nRPCPort = 2223; //Ring was forged in the second age.
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 500000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
const char* pszTimestamp = "Sauron says hello.";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 1 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1386541846;
genesis.nBits = 0x1e0fffff;
genesis.nNonce = 0;
//// debug print
hashGenesisBlock = genesis.GetHash();
while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
if (++genesis.nNonce==0) break;
hashGenesisBlock = genesis.GetHash();
}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("%x\n", bnProofOfWorkLimit.GetCompact());
genesis.print();
assert(hashGenesisBlock == uint256("0x"));
assert(genesis.hashMerkleRoot == uint256("0x"));
vSeeds.push_back(CDNSSeedData("someaddress.com or IP addy", "someaddress.com"));
base58Prefixes[PUBKEY_ADDRESS] = 63;
base58Prefixes[SCRIPT_ADDRESS] = 30;
base58Prefixes[SECRET_KEY] = 224;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}
示例8: BasicTestingSetup
TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(chainName)
{
const CChainParams& chainparams = Params();
// Ideally we'd move all the RPC tests to the functional testing framework
// instead of unit tests, but for now we need these here.
RegisterAllCoreRPCCommands(tableRPC);
ClearDatadirCache();
pathTemp = GetTempPath() / strprintf("test_bitcoin_%lu_%i", (unsigned long)GetTime(), (int)(GetRand(100000)));
boost::filesystem::create_directories(pathTemp);
mapArgs["-datadir"] = pathTemp.string();
mempool.setSanityCheck(1.0);
pblocktree = new CBlockTreeDB(1 << 20, true);
pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
InitBlockIndex(chainparams);
{
CValidationState state;
bool ok = ActivateBestChain(state, chainparams);
BOOST_CHECK(ok);
}
nScriptCheckThreads = 3;
for (int i=0; i < nScriptCheckThreads-1; i++)
threadGroup.create_thread(&ThreadScriptCheck);
g_connman = std::unique_ptr<CConnman>(new CConnman(0x1337, 0x1337)); // Deterministic randomness for tests.
connman = g_connman.get();
RegisterNodeSignals(GetNodeSignals());
}
示例9: LOCK
void CTxMemPool::check(const CCoinsViewCache *pcoins) const
{
LOCK(cs);
if (nCheckFrequency == 0)
return;
if (GetRand(std::numeric_limits<uint32_t>::max()) >= nCheckFrequency)
return;
LogPrint(BCLog::MEMPOOL, "Checking mempool with %u transactions and %u inputs\n", (unsigned int)mapTx.size(), (unsigned int)mapNextTx.size());
uint64_t checkTotal = 0;
uint64_t innerUsage = 0;
CCoinsViewCache mempoolDuplicate(const_cast<CCoinsViewCache*>(pcoins));
const int64_t spendheight = GetSpendHeight(mempoolDuplicate);
std::list<const CTxMemPoolEntry*> waitingOnDependants;
for (indexed_transaction_set::const_iterator it = mapTx.begin(); it != mapTx.end(); it++) {
unsigned int i = 0;
checkTotal += it->GetTxSize();
innerUsage += it->DynamicMemoryUsage();
const CTransaction& tx = it->GetTx();
txlinksMap::const_iterator linksiter = mapLinks.find(it);
assert(linksiter != mapLinks.end());
const TxLinks &links = linksiter->second;
innerUsage += memusage::DynamicUsage(links.parents) + memusage::DynamicUsage(links.children);
bool fDependsWait = false;
setEntries setParentCheck;
int64_t parentSizes = 0;
int64_t parentSigOpCost = 0;
for (const CTxIn &txin : tx.vin) {
// Check that every mempool transaction's inputs refer to available coins, or other mempool tx's.
indexed_transaction_set::const_iterator it2 = mapTx.find(txin.prevout.hash);
if (it2 != mapTx.end()) {
const CTransaction& tx2 = it2->GetTx();
assert(tx2.vout.size() > txin.prevout.n && !tx2.vout[txin.prevout.n].IsNull());
fDependsWait = true;
if (setParentCheck.insert(it2).second) {
parentSizes += it2->GetTxSize();
parentSigOpCost += it2->GetSigOpCost();
}
} else {
assert(pcoins->HaveCoin(txin.prevout));
}
// Check whether its inputs are marked in mapNextTx.
auto it3 = mapNextTx.find(txin.prevout);
assert(it3 != mapNextTx.end());
assert(it3->first == &txin.prevout);
assert(it3->second == &tx);
i++;
}
assert(setParentCheck == GetMemPoolParents(it));
// Verify ancestor state is correct.
setEntries setAncestors;
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
std::string dummy;
CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, nNoLimit, dummy);
uint64_t nCountCheck = setAncestors.size() + 1;
uint64_t nSizeCheck = it->GetTxSize();
CAmount nFeesCheck = it->GetModifiedFee();
int64_t nSigOpCheck = it->GetSigOpCost();
for (txiter ancestorIt : setAncestors) {
nSizeCheck += ancestorIt->GetTxSize();
nFeesCheck += ancestorIt->GetModifiedFee();
nSigOpCheck += ancestorIt->GetSigOpCost();
}
assert(it->GetCountWithAncestors() == nCountCheck);
assert(it->GetSizeWithAncestors() == nSizeCheck);
assert(it->GetSigOpCostWithAncestors() == nSigOpCheck);
assert(it->GetModFeesWithAncestors() == nFeesCheck);
// Check children against mapNextTx
CTxMemPool::setEntries setChildrenCheck;
auto iter = mapNextTx.lower_bound(COutPoint(it->GetTx().GetHash(), 0));
int64_t childSizes = 0;
for (; iter != mapNextTx.end() && iter->first->hash == it->GetTx().GetHash(); ++iter) {
txiter childit = mapTx.find(iter->second->GetHash());
assert(childit != mapTx.end()); // mapNextTx points to in-mempool transactions
if (setChildrenCheck.insert(childit).second) {
childSizes += childit->GetTxSize();
}
}
assert(setChildrenCheck == GetMemPoolChildren(it));
// Also check to make sure size is greater than sum with immediate children.
// just a sanity check, not definitive that this calc is correct...
assert(it->GetSizeWithDescendants() >= childSizes + it->GetTxSize());
if (fDependsWait)
waitingOnDependants.push_back(&(*it));
else {
CheckInputsAndUpdateCoins(tx, mempoolDuplicate, spendheight);
}
}
unsigned int stepsSinceLastRemove = 0;
while (!waitingOnDependants.empty()) {
const CTxMemPoolEntry* entry = waitingOnDependants.front();
waitingOnDependants.pop_front();
//.........这里部分代码省略.........
示例10: DOLL_ID
void Scene_TestDangeon::Debug_ClearStage1(){
DWORD prevID = 0;
DOLL_ID dollID = DOLL_ID(0, 0);
dollID._aliceID = gr_others.GetAliceID();
// 人形を全て削除
r_aliceDoll.DeleteAllDolls();
g_dollList.RefreshAllDolls(&r_aliceDoll, &r_aliceInfo);
g_temp.isUnitedDoll = false;
// プリセットの人形を追加
for(int n=0; n<10; n++){
switch(n){
case 0:
g_temp.SetDroppedDoll(13, 100);
g_temp.SetDollName(_T("シアン"));
break;
case 1:
g_temp.SetDroppedDoll(14, 75);
g_temp.SetDollName(_T("マゼンタ"));
break;
case 2:
g_temp.SetDroppedDoll(15, 75);
g_temp.SetDollName(_T("イエロー"));
break;
case 7:
g_temp.SetDroppedDoll(7, 60);
g_temp.SetDollName(_T("サン"));
break;
case 8:
g_temp.SetDroppedDoll(8, 60);
g_temp.SetDollName(_T("ムーン"));
break;
case 9:
g_temp.SetDroppedDoll(9, 60);
g_temp.SetDollName(_T("スター"));
break;
default:
g_temp.SetDroppedDoll(60+GetRand(79), GetRand(40));
switch(n){
case 3:
g_temp.SetDollName(_T("イズ"));
break;
case 4:
g_temp.SetDollName(_T("ウェスタ"));
break;
case 5:
g_temp.SetDollName(_T("ノルス"));
break;
case 6:
g_temp.SetDollName(_T("サウジー"));
break;
}
break;
}
g_dollList.AddDoll(g_temp.dollData.GetDataPtr(), true, true, &r_aliceInfo);
prevID = gr_others.GetNextDollID() - 1;
dollID._id = prevID;
if(n < MAX_BATTLEDOLL){
r_aliceInfo.SetBattleDollID(n, dollID);
}
}
// チュートリアルのクリアボーナスの追加
// ExecuteMapClearBonus(NUM_TESTDANGEON_TUTORIAL);
// 終了
g_dollList.ReflectAllDollsToRecord();
// 時間経過
r_aliceInfo.ResetTime();
r_aliceInfo.AddTime(15);
}
示例11: mmrand
float mmrand(int min, int max, float divisor)
{
return ((float)GetRand(min, max)) / divisor;
};
示例12: aiSample
/**********************************************************
AIの行動を返す関数
**********************************************************/
Action aiSample(int view[2*VISIBLE+1][2*VISIBLE+1])
{
int r;
int danger=0;
double direct;
double PI=3.141592;
int tx,ty;
for(int i=0;i<2*VISIBLE+1;i++){
for(int j=0;j<2*VISIBLE+1;j++){
if(view[i][j]==3){
tx=i;
ty=j;
danger=1;
int dx=tx-CENTER;
int dy=ty-CENTER;
if(dx==0){
if(dy>=0){
direct=90;
}else{
direct=-90;
}
}else{
double t=dy/dx;
if(dx>0){
direct=atan(t)/PI*180;
}
else{
direct=atan(t)/PI*180+180;
}
}
}
}
}
if(danger==0){
int r=GetRand(4);
switch(r%4){
case 0:
if(view[CENTER][CENTER-1]!=1)
return N;
break;
case 1:
if(view[CENTER+1][CENTER]!=1)
return E;
break;
case 2:
if(view[CENTER][CENTER+1]!=1)
return S;
break;
case 3:
if(view[CENTER-1][CENTER]!=1)
return W;
break;
}
}else{
if(direct<-45 || direct>=225){
if(view[CENTER][CENTER+1]!=1)
return S;
else{
if(view[CENTER+1][CENTER]!=1){
return E;
}else if(view[CENTER-1][CENTER]!=1){
return W;
}else{
return N;
}
}
}
else if(direct<45){
if(view[CENTER-1][CENTER]!=1)
return W;
else{
if(view[CENTER][CENTER-1]!=1){
return N;
}else if(view[CENTER][CENTER+1]!=1){
return S;
}else{
return E;
}
}
}else if(direct<135){
if(view[CENTER][CENTER-1]!=1)
return N;
else{
if(view[CENTER-1][CENTER]!=1){
return W;
}else if(view[CENTER+1][CENTER]!=1){
return E;
}else{
return S;
}
}
}
else if(direct<225){
if(view[CENTER+1][CENTER]!=1)
return E;
else{
//.........这里部分代码省略.........
示例13: GetRandInt
int GetRandInt(int nMax)
{
return GetRand(nMax);
}
示例14: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0x55;
pchMessageStart[1] = 0x42;
pchMessageStart[2] = 0x4B;
pchMessageStart[3] = 0x45;
nDefaultPort = 11066;
nRPCPort = 11067;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 100000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
const char* pszTimestamp = "Viking Era";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 0.001 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1400630400; //nTime
genesis.nBits = 0x1e0fffff;
genesis.nNonce = 2016973;
hashGenesisBlock = genesis.GetHash();
// while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
// hashGenesisBlock = genesis.GetHash();
//}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("%x\n", bnProofOfWorkLimit.GetCompact());
genesis.print();
assert(hashGenesisBlock == uint256("0x00000c07c30a4f74683e64ed156668e3f8d2e71bb4efcdcc44c248708d1cabf2"));
assert(genesis.hashMerkleRoot == uint256("0xb8b26c88ea01ea6cbbd9fd39158f1e6cae130cc2cd5950b78727d83aa71c056d"));
vSeeds.push_back(CDNSSeedData("198.46.134.15", "192.3.10.93"));
vSeeds.push_back(CDNSSeedData("95.85.46.218", "81.11.246.44"));
vSeeds.push_back(CDNSSeedData("108.61.10.90", "192.241.199.243"));
base58Prefixes[PUBKEY_ADDRESS] = 70;
base58Prefixes[SCRIPT_ADDRESS] = 132;
base58Prefixes[SECRET_KEY] = 86;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}
示例15: CMainParams
CMainParams() {
// The message start string is designed to be unlikely to occur in normal data.
pchMessageStart[0] = 0x66;
pchMessageStart[1] = 0x66;
pchMessageStart[2] = 0x66;
pchMessageStart[3] = 0x66;
nDefaultPort = 24242;
nRPCPort = 24243;
bnProofOfWorkLimit = CBigNum(~uint256(0) >> 20);
nSubsidyHalvingInterval = 35040000;
// Build the genesis block. Note that the output of the genesis coinbase cannot
// be spent as it did not originally exist in the database.
const char* pszTimestamp = "Release the Kraken - www.krakencoin.com";
CTransaction txNew;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = 1 * COIN;
txNewvout1nValue = 5;
txNewvout2nValue = 450000 * COIN;
txNew.vout[0].scriptPubKey = CScript() << ParseHex("") << OP_CHECKSIG;
genesis.vtx.push_back(txNew);
genesis.hashPrevBlock = 0;
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
genesis.nVersion = 1;
genesis.nTime = 1394270601;
genesis.nBits = 0x1e0fffff;
genesis.nNonce = 943874;
//// debug print
hashGenesisBlock = genesis.GetHash();
//while (hashGenesisBlock > bnProofOfWorkLimit.getuint256()){
// if (++genesis.nNonce==0) break;
//hashGenesisBlock = genesis.GetHash();
//}
printf("%s\n", hashGenesisBlock.ToString().c_str());
printf("%s\n", genesis.hashMerkleRoot.ToString().c_str());
printf("%x\n", bnProofOfWorkLimit.GetCompact());
genesis.print();
assert(hashGenesisBlock == uint256("0x00000e9d058285796d9d49c3110a98c9367d25b7ab82cab06088f29ff4160b2a"));
assert(genesis.hashMerkleRoot == uint256("0x67cf79c130dc3b7f3a164ffde6d4ff3b30fb3847e649e5ab8c889cbcba8db40d"));
vSeeds.push_back(CDNSSeedData("162.243.90.199", "162.243.90.199"));
base58Prefixes[PUBKEY_ADDRESS] = 45;
base58Prefixes[SCRIPT_ADDRESS] = 30;
base58Prefixes[SECRET_KEY] = 224;
// Convert the pnSeeds array into usable address objects.
for (unsigned int i = 0; i < ARRAYLEN(pnSeed); i++)
{
// It'll only connect to one or two seed nodes because once it connects,
// it'll get a pile of addresses with newer timestamps.
// Seed nodes are given a random 'last seen time'
const int64 nTwoDays = 2 * 24 * 60 * 60;
struct in_addr ip;
memcpy(&ip, &pnSeed[i], sizeof(ip));
CAddress addr(CService(ip, GetDefaultPort()));
addr.nTime = GetTime() - GetRand(nTwoDays) - nTwoDays;
vFixedSeeds.push_back(addr);
}
}