ABSymCurve::ABSymCurve(string name, int card, string input, string time, int mCache, double kDist) : ABSymContinuous(name, card), order(C_ORDER), kDist(kDist), maxCache(mCache), cullCount(0) { vector<string> inputs; inputs.push_back(input); inputs.push_back(time); setInputs(inputs); tCache = getCard(); if (maxCache < C_ORDER*2) maxCache = C_ORDER*2; for (int i = 0; i < getCard()+1; i++) { GCacheQueue q(maxCache, 0.0); caches.push_back(q); } lastCurve = new int[getCard()]; for (int i = 0; i < getCard(); i++) { curves.push_back(vector< Piece<C_ORDER> >()); lastCurve[i] = -1; } }
JQuadPtr WSrcCards::getImage(int offset) { if (!WResourceManager::Instance()->IsThreaded()) { if (mDelay && mLastInput < mDelay) { return WResourceManager::Instance()->RetrieveCard(getCard(offset), RETRIEVE_EXISTING); } } return WResourceManager::Instance()->RetrieveCard(getCard(offset)); }
void ABSymSmooth::recalculate() { double vals[getCard()], nvals[getCard()]; inputSyms[0]->getValues(vals); for (int i = 0; i < getCard(); i++) { GCacheQueue &q = qvect[i]; q.shift(vals[i]); nvals[i] = q.getSum() / q.getSize(); } setValues(nvals); }
bool ABSymCurve::ABSymCurve::ABSymCurve::pullCurrent() { if (!inputSyms[1] || !*inputSyms) return false; caches[tCache].shift(inputSyms[1]->getValue(0)); double buf[getCard()]; (*inputSyms)->getValues(buf); setValues(buf); for (int i = 0; i < getCard(); i++) caches[i].shift(buf[i]); return true; }
void ABSymMax::recalculate() { if (prime < 1) { double nvals[getCard()]; inputSyms[0]->getValues(nvals); double vals[getCard()]; getValues(vals); for (int i = 0; i < getCard(); i++) vals[i] = min(max(vals[i], vals[i]), clamp); setValues(vals); } else prime--; }
void CardLayout::updateLayout(const MFUnrecChildComponentPtr* Components, const Component* ParentComponent) const { if(getCard() >= Components->size()) { SWARNING << "CardLayout::updateLayout: The Index set for Card is: "<< getCard() << ", but there are only " << Components->size() << " components in the container this layout is attached to" << std::endl; return; } /*! Draw the current "card" component centered in the parent component and set to the size of the parent component, or to its max size */ Pnt2f borderTopLeft, borderBottomRight; dynamic_cast<const ComponentContainer*>(ParentComponent)->getInsideInsetsBounds(borderTopLeft, borderBottomRight); Vec2f borderSize(borderBottomRight-borderTopLeft); Vec2f size(borderSize),offset; ComponentRefPtr curCard((*Components)[getCard()]); for(UInt32 i(0) ; i<Components->size() ; ++i) { if((*Components)[i] != curCard && (*Components)[i]->getSize() != Vec2f(0.0f,0.0f)) { (*Components)[i]->setSize(Vec2f(0.0f,0.0f)); } } // check each dimension against the max size of the component; if (size[0] > curCard->getMaxSize()[0]) size[0] = curCard->getMaxSize()[0]; if (size[1] > curCard->getMaxSize()[1]) size[1] = curCard->getMaxSize()[1]; // set the component to its parent component's size, or its max size if(curCard->getSize() != size) { curCard->setSize(size); } offset[0] = (borderSize.x()-size.x())/2; offset[1] = (borderSize.y()-size.y())/2; Pnt2f Pos(borderTopLeft + Vec2f(offset)); if(curCard->getPosition() != Pos) { curCard->setPosition(Pos); } }
void HelloWorld::createCard(PosIndex posIndex) { // 新しいカードを作成 auto card = CardSprite::create(); card->setCard(getCard()); card->setPosIndex(posIndex); addChild(card, ZORDER_SHOW_CARD); }
struct hand *initCard() { struct hand *obj = malloc(sizeof(struct hand)); getCard(obj->card); obj->next = NULL; return obj; }
/* 查询卡信息 在结构体数组aCard中,查找卡号与pName相同的卡信息 结果通过返回值返回(NULL) */ Card* queryCard(const char* pName) { //定义指针P,指向cardList的第一个节点 IpCardNode cur = NULL; Card* pCard = NULL; int nIndex = 0; if (FALSE == getCard()) { return FALSE; } //首先分配一个Card大小的内存空间 pCard = (Card*)malloc(sizeof(Card));//保存查询到的符合条件的卡信息 //遍历链表 if (cardList != NULL) { cur = cardList; //遍历链表,结点为空表示链表尾部 while (cur != NULL) { //判断当前节点中的卡号是否和输入的卡号相同 if (strstr(cur->data.aName, pName) != NULL) { //如果有,则保存节点中的数据 pCard[nIndex] = cur->data; nIndex++; //重新为指针分配内存 pCard = (Card*)realloc(pCard, (nIndex + 1)*sizeof(Card)); } //移到链表下一结点 cur = cur->next; } } return pCard; }
/* 函数名:queryCards 功能:查询用户账户核心函数 参数:const char* pName, 要查询的用户账户名;int* pIndex,指向顺序数的指针,用于遍历链表及文件用 返回值:int;0-FALSE,失败;1-TRUE,成功 */ Card* queryCards(const char* pName, int* pIndex) { IpCardNode node = NULL; Card* pCard = NULL; if (FALSE == getCard()) { return FALSE; } //首先分配一个Card大小的内存空间 pCard = (Card*)malloc(sizeof(Card));//保存查询到的符合条件的卡信息 if (cardList != NULL) { //从头节点指向的下一个节点开始遍历 node = cardList; //遍历链表,结点为空表示链表尾部 while (node != NULL) { //判断在该遍历到的节点的信息中,查找是否包含pName字符串 if (strstr(node->data.aName, pName) != NULL) { //如果有,则保存节点中的数据 pCard[*pIndex] = node->data; (*pIndex)++; //重新为指针分配内存 pCard = (Card*)realloc(pCard, ((*pIndex) + 1)*sizeof(Card)); } //移到链表下一结点 node = node->next; } } return pCard; }
bool ABSymCurve::getVelocity(double *buff, double time) { for (int i = 0; i < getCard(); i++) { buff[i] = getValueAt(i, time, 1); } return true; }
Card *cardFromName (const char *str) { int face = -1, suit = -1; if (!str) return 0; while (*str && (unsigned char)(*str) <= ' ') str++; switch (*str++) { case '7': face = 7; break; case '8': face = 8; break; case '9': face = 9; break; case '1': if (*str++ != '0') return 0; face = 10; break; case 'J': case 'j': face = 11; break; case 'Q': case 'q': face = 12; break; case 'K': case 'k': face = 13; break; case 'A': case 'a': face = 14; break; default: return 0; } while (*str && (unsigned char)(*str) <= ' ') str++; switch (*str++) { case 'S': case 's': suit = 1; break; case 'C': case 'c': suit = 2; break; case 'D': case 'd': suit = 3; break; case 'H': case 'h': suit = 4; break; default: return 0; } return getCard(face, suit); }
queries::records::AnswerConfiguration queries::records::AnswerConfigurationPacked::convert() const{ return AnswerConfiguration( getQid(), getScopeid(), getCard() ); }
/* * What is the mean of your score if N=SOMETHING * What is the standard deviation of your score if N=SOMETHING */ void play(int nTrial){ const int nT = nTrial; T totalScore =0; data.clear(); for(; nTrial > 0 ; nTrial--){ T trialScore =0; T point=0; T numC = 0; for(; point < N ; numC++){ uint c = getCard(); point += c; } trialScore = (point-N); data.push_back(trialScore); totalScore+=trialScore; } this->mean = (double)totalScore/(double)nT; std::vector<double> diff(data.size()); std::transform(data.begin(), data.end(), diff.begin(), std::bind2nd(std::minus<double>(), mean)); double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0); double variance = sq_sum / nT; double standardDeviation = std::sqrt(variance); stdev = standardDeviation; printf("\tN=%i , mean = %.10f variance %.10f, stdev = %.10f\n",N,mean,variance,stdev); }
/* 功能:根据卡号和密码,在链表中查询卡信息 参数:参数:pName上机卡号;pPwd上机卡密码;pIndex上机卡在链表中的索引的指针 返回值:符合条件的卡信息结构体指针 */ Card* checkCard(const char* pName, const char* pPwd,int *pIndex) { Card* pCard = NULL; IpCardNode node = NULL; int nIndex = 0; if (FALSE == getCard()) { return FALSE; } //首先分配一个Card大小的内存空间 pCard = (Card*)malloc(sizeof(Card));//保存查询到的符合条件的卡信息 if (cardList != NULL) { //从头节点指向的下一个节点开始遍历 node = cardList; //遍历链表,结点为空表示链表尾部 while (node != NULL) { //判断在该遍历到的节点的信息中,查找是否包含pName字符串 if (strcmp(node->data.aName, pName)==0 && strcmp(node->data.aPwd, pPwd)==0) { pCard = &node->data; (*pIndex) = nIndex; } //移到链表下一结点 node = node->next; nIndex++; } } return pCard; }
bool ABSymCurve::getAcceleration(double *buff, double time) { for (int i = 0; i < getCard(); i++) { buff[i] = getValueAt(i, time, 2); } return true; }
int WSrcCards::addToDeck(MTGDeck * i, int num) { int oldpos = getOffset(); int added = 0; int cycles = 0; if (!i) { if (num < 0) return 0; return num; } setOffset(0); if (num < 0) { //Add it all; MTGCard * c; for (;;) { c = getCard(); if (!c || !next()) break; i->add(c); } } else while (added < num) { MTGCard * c = getCard(); if (!next() || !c) { if (++cycles == WSrcCards::MAX_CYCLES) { //Abort the search, too many cycles. setOffset(oldpos); return num - added; } setOffset(0); continue; } else { i->add(c); added++; } } setOffset(oldpos); return 0; }
void CardDatabase::cacheCardPixmaps(const QStringList &cardNames) { QPixmap tmp; // never cache more than 300 cards at once for a single deck int max = qMin(cardNames.size(), 300); for (int i = 0; i < max; ++i) getCard(cardNames[i])->loadPixmap(tmp); }
void queries::records::AnswerConfigurationPacked::toString (std::ostream& out) const { out << "("; out << "qid:" << getQid(); out << ","; out << "scopeid:" << getScopeid(); out << ","; out << "card:" << getCard(); out << ")"; }
void MainWindow::swap_card(int card) { if (m_gamestate == Pick) { int temp=hand[card]; hand[card]=used[card]; used[card]=temp; getButton(card)->setIcon(getCard(hand[card])); } }
void ABSymCurve::clear() { for (int i = 0; i < getCard(); i++) { lastCurve[i] = -1; caches[i].setSize(0); curves[i].clear(); } caches[tCache].setSize(0); }
void ABSymCurve::ABSymCurve::updateCurves() { GCacheQueue &tc = caches[tCache]; for (int i = 0; i < getCard(); i++) { GCacheQueue &c = caches[i]; if (c.getSize() == 0) continue; // Initialize if no curves if (curves[i].size() < 1) { Piece<C_ORDER> curve = ABSymCurve::getCurve(c, tc); curves[i].push_back(curve); } // Run the full calculation else if (c.getSize() < c.getCard()) { Piece<C_ORDER> curve = ABSymCurve::getCurve(c, tc); Piece<C_ORDER> last = curves[i].back(); // If curve is still good, modify current top if (curve.r <= kDist * distModify(c.getSize(), c.getCard())) { curves[i].back() = curve; } // Curve is not good, so start a new one! else { // printf("Fit Final %d:\n", (int)curves[i].size()-1); // printf("\ttmin: %f, tmax: %f\n\t", curves[i].back().tmin, curves[i].back().tmax); // for (int c = 0; c <= C_ORDER; c++) // printf(" %f", curves[i].back().coef[c]); // printf("\n"); c.setSize(2); curve = ABSymCurve::getCurve(c, tc); curves[i].push_back(curve); } } // Otherwise, start a new top else { // printf("Num Final %d:\n", (int)curves[i].size()-1); // printf("\ttmin: %f, tmax: %f\n\t", curves[i].back().tmin, curves[i].back().tmax); // for (int c = 0; c <= C_ORDER; c++) // printf(" %f", curves[i].back().coef[c]); // printf("\n"); c.setSize(2); Piece<C_ORDER> curve = ABSymCurve::getCurve(c, tc); curves[i].push_back(curve); } } }
void ABSymMean::recalculate() { double sums[getCard()]; for (int i = 0; i < getCard(); i++) sums[i] = 0.0; for (unsigned int i = 0; i < getCard(); i++) { if (!inputSyms[i] || inputSyms[i]->getCard() == 0) continue; double buff[inputSyms[i]->getCard()];// = new double[inputSyms[i]->getCard()]; inputSyms[i]->getValues(buff); sums[i] = 0.0; for (unsigned int j = 0; j < inputSyms[i]->getCard(); j++) sums[i] += buff[j]; sums[i] /= inputSyms[i]->getCard(); } setValues(sums); //dataState = DIRTY; }
ABSymDifferentiate::ABSymDifferentiate(string name, int card, string input, string timeNode) : ABSymbol(name, card) { // Verify that "time" is in inputs (otherwise it won't link correctly) vector<string> names; names.push_back(input); names.push_back(timeNode); setInputs(names); timeIdx = 1; lastVals = new double[getCard()]; for (int i = 0; i < getCard(); i++) lastVals[i] = 0.0; setValues(lastVals); lastTime = 0; }
void HelloWorld::createCard(PosIndex posIndex){ //新しいカードを作成する auto card = CardSprite::create(); card->setCard(getCard()); card->setPosIndex(posIndex); addChild(card, ZORDER_SHOW_CARD); //auto card = Sprite::create("card_spades.png"); //card->setPosition(CARD_1_POS_X + CARD_DISTANCE_X * posIndex.x, // CARD_1_POS_Y + CARD_DISTANCE_Y * posIndex.y); //addChild(card, ZORDER_SHOW_CARD); }
int main(){ int handA; int handB; int k[10] = {adventurer, embargo, great_hall, village, minion, mine, cutpurse, sea_hag, tribute, smithy}; int i; int j; struct gameState g; printf("Testing Adventurer...\n"); initializeGame(2, k, 5, &g); printf("Start Amount of Cards: %d\n", g.handCount[0]); handA = g.handCount[0]; printf("Starting Cards: \n"); for(i = 0; i < 5; i++) { printf("%s ", getCard(&k[i])); } cardEffect(adventurer, 0, 0, 0, &g, 0, 0); printf("\n\nEnd Amount of Cards: %d\n", g.handCount[0]); handB = g.handCount[0]; printf("Ending Cards: \n"); for(j = 0; j < 10; j++) { printf("%s ", getCard(&k[i])); } if(handB > 7){ printf("\n TEST FAILED. The end amount is more than expected. \n"); } else{ printf("\n TEST Adventurer SUCCEED. \n"); } printf("Test Ending...\n"); return 0; }
bool Hand::play(unsigned int slot) { if (field_.isActive(slot)) { return false; } field_.setCard(getCard(slot), slot); drawCard(slot); return true; }
bool RoomState::setCard(int cardId, Card *newCard) { Card* oldCard = getCard(cardId); if (oldCard == newCard) return true; m_cards[cardId] = newCard; newCard->setId(cardId); // newCard->setModified(true); if (oldCard != NULL) { delete oldCard; } return true; }
void ABSymDifferentiate::recalculate() { double t = inputSyms[timeIdx]->getValue(0); // If t is too close, peace out static double EPS = 1e-6; if (fabs(t - lastTime) < EPS) return; // Calculate inverse double idt = 1.0/(t - lastTime); lastTime = t; // Grab current values double x[getCard()]; inputSyms[0]->getValues(x); // Grab differences double dx[getCard()]; for (int i = 0; i < getCard(); i++) dx[i] = (x[i] - lastVals[i])*idt; memcpy(lastVals, x, sizeof(double)*getCard()); setValues(dx); }
void WSrcCards::bakeFilters() { vector<MTGCard*> temp; setOffset(0); for (int t = 0; t < Size(); t++) { temp.push_back(getCard(t)); } setOffset(0); cards.clear(); cards.swap(temp); clearFilters(); return; }