Exemple #1
0
void person()
{
    torso();
    glPushMatrix();
        head();
    glPopMatrix();
    glPushMatrix();
        upper_right_arm();
        lower_arm();
        hand();
    glPopMatrix();
    glPushMatrix();
        upper_left_arm();
        lower_arm();
        hand();
    glPopMatrix();
    glPushMatrix();
        upper_right_leg();
        lower_leg();
    glPopMatrix();
    glPushMatrix();
        upper_left_leg();
        lower_leg();
    glPopMatrix();
}
Exemple #2
0
void ArmModule::draw(Box2f viewport, Box2f screen_viewport, float scale, unsigned int recurse) {

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glBoxToBox(viewport, screen_viewport);

	glBegin(GL_QUADS);
	glColor3f(0.0f, 0.0f, 0.0f);
	glVertex2f(-1.0f, -0.5f);
	glVertex2f( 1.0f, -0.5f);
	glVertex2f( 1.0f,  0.5f);
	glVertex2f(-1.0f,  0.5f);
	glEnd();

	{ //draw arm.
		glMatrixMode(GL_MODELVIEW);

		glColor3f(0.5f, 0.5f, 0.5f);
		glPushMatrix();
		glTranslatef(base().x, base().y, 0.0f);
		glRotatef(base().z / M_PI * 180.0f,   0.0f, 0.0f, 1.0f);
		capsule(BaseLen, 0.9f);
		glPopMatrix();

		glPushMatrix();
		glTranslatef(hand().x, hand().y, 0.0f);
		glRotatef(hand().z / M_PI * 180.0f,   0.0f, 0.0f, 1.0f);
		glBegin(GL_QUADS);
		glVertex2f(0.0f, 0.0f);
		glVertex2f(1.5f * Rad, 1.5f * Rad);
		glVertex2f(3.0f * Rad, 0.0f);
		glVertex2f(1.5f * Rad,-1.5f * Rad);
		glEnd();
		glPopMatrix();

		glColor3f(0.7f, 0.7f, 0.7f);
		glPushMatrix();
		glTranslatef(seg().x, seg().y, 0.0f);
		glRotatef(seg().z / M_PI * 180.0f,   0.0f, 0.0f, 1.0f);
		capsule(SegLen);
		glPopMatrix();


		glMatrixMode(GL_PROJECTION);
	}

	glBegin(GL_LINE_LOOP);
	glVertex2f(-1.0f, -0.5f);
	glVertex2f( 1.0f, -0.5f);
	glVertex2f( 1.0f,  0.5f);
	glVertex2f(-1.0f,  0.5f);
	glEnd();

	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	Graphics::gl_errors("Arm::draw");

}
/// Finds the best combination of 5 cards out of 7 cards.
hand_t find_best_hand(const card_t cards[7], HandStrength *strength_output)
{
#if 1
    // New method: try it out!
    Hand hand(cards, 7);
    HandStrength strength = EvaluateHand(hand);
    *strength_output = strength;
#endif

	card_t choice[5];
	hand_t best;

	// Exclude each pair of cards (i, j), and evaluate the rest.
	for (int i = 0; i < 7; i++)
	{
		for (int j = i + 1; j < 7; j++)
		{
			int ii = 0;
			for (int k = 0; k < 7; k++)
				if (k != i && k != j)
					choice[ii++] = cards[k];

			hand_t h = make_hand(choice);
			if (j == 1 || h > best)
				best = h;
		}
	}
	return best;
}
Exemple #4
0
/**
 * Updates our command to @a new_command.
 */
void wml_menu_item::update_command(const config & new_command)
{
	// If there is an old command, remove it from the event handlers.
	if ( !command_.empty() ) {
		for ( manager::iteration hand(event_name_); hand.valid(); ++hand ) {
			if ( hand->is_menu_item() ) {
				LOG_NG << "Removing command for " << event_name_ << ".\n";
				remove_event_handler(command_["id"].str());
			}
		}
	}

	// Update our stored command.
	if ( new_command.empty() )
		command_.clear();
	else {
		command_ = new_command;

		// Set some fields required by event processing.
		config::attribute_value & event_id = command_["id"];
		if ( event_id.empty() && !item_id_.empty() ) {
			event_id = item_id_;
		}
		command_["name"] = event_name_;
		command_["first_time_only"] = false;

		// Register the event.
		LOG_NG << "Setting command for " << event_name_ << " to:\n" << command_;
		add_event_handler(command_, true);
	}
}
Exemple #5
0
std::vector<Card> Deck::giveHandtoPlayer(const unsigned int &size)
{
    std::vector<Card> hand(size);
    std::copy(mDeck.end() - size, mDeck.end(), hand.begin());
    mDeck.erase(mDeck.end() - size, mDeck.end());
    return hand;
}
Exemple #6
0
void MainInterface::PlayerStartPlayingHand()
{
    /*从选中的牌图片中得到要打出去的牌组*/
    if(m_Selected.isEmpty()) return;
    QList<card> cards;
    QSet<CardPicture*>::iterator it = m_Selected.begin();
    for(;it!=m_Selected.end();it++)
        cards.append((*it)->getCard());

    /****************判断是否能打出*********************/
    Hand hand(cards);
    //未知牌型不能出
    if( hand.getHandType() == Hand_Unknown )
    {
        qDebug()<<"Unkown HandType";
        return;
    }

    //打不过不能出
    Hand handToHit(m_gameprocess->getHitCards());
    Player* hitPlayer=m_gameprocess->getHitPlayer();
    if(hitPlayer!=m_gameprocess->getDownPlayer()&&hitPlayer!=NULL)
        if(!hand.Defeat(handToHit))
        {
            qDebug()<<"Cannot Defeat";
            return;
        }


    /****************************************/
    m_Selected.clear();
    m_gameprocess->getDownPlayer()->playHand(cards);

}
Exemple #7
0
/* if this method throw an exception then the object is invalid */
bool JsonShredder::Shred(uint64_t docseq,
                         const std::string& json,
                         std::string* idout,
                         std::string* errout) {
    YajlHandle hand(&ctx_);
    yajl_status stat;
    bool success = true;
    ctx_.docseq = docseq;
    stat = yajl_parse(hand, (unsigned char*)json.c_str(), json.length());

    if (stat == yajl_status_ok)
        stat = yajl_complete_parse(hand);

    if (stat == yajl_status_client_canceled) {
        if (ctx_.exception_ptr) {
            // some sorta exception occurred. rethrow.
            std::rethrow_exception(ctx_.exception_ptr);
        } else {
            // error message must be in tempbuff
            *errout = ctx_.tempbuff;
            success = false;
        }
    } else if (stat != yajl_status_ok) {
        hand.GetError(json, errout);
        success = false;
    }
    if (ctx_.docid.length() == 0) {
        *errout = "missing _id field";
        success = false;
    }
    *idout = ctx_.docid;

    return success;
}
Exemple #8
0
bool loadXLIFF(Translator &translator, QIODevice &dev, ConversionData &cd)
{
    QXmlInputSource in(&dev);
    QXmlSimpleReader reader;
    XLIFFHandler hand(translator, cd);
    reader.setContentHandler(&hand);
    reader.setErrorHandler(&hand);
    return reader.parse(in);
}
Exemple #9
0
void video(int x,int y,int p)
{ setcolor(WHITE);
/*  ellipse(x,y,140,40,25,25);
  rectangle(x-20,y-20,x+20,y-16);
  line(x-20,y-20,x-25,y-35);
  line(x+20,y-20,x+25,y-35);
  line(x-25,y-35,x-10,y-25);
  line(x+25,y-35,x+10,y-25);
  line(x-10,y-25,x,y-35);
  line(x+10,y-25,x,y-35);
  circle(x-8,y-7,3);
  circle(x+8,y-7,3);
  line(x,y-6,x-3,y+3);
  line(x-3,y+3,x+1,y+3);
  ellipse(x,y+5,180,360,10,10);

  line(x-50,y+25,x+50,y+25);
  line(x-50,y+25,x-75,y+65);
  line(x-40,y+50,x-75,y+100);
  line(x-40,y+50,x-35,y+125);

  line(x+50,y+25,x+75,y+75);
  line(x+40,y+50,x+55,y+75);
  line(x+55,y+75,x+36,y+110);
  line(x+75,y+75,x+36,y+130);

  line(x+40,y+50,x+35,y+125);
  line(x-35,y+125,x+35,y+125);
  line(x-35,y+125,x-40,y+225);
  line(x+35,y+125,x+40,y+225);
  line(x-40,y+225,x+40,y+225);

  ellipse(x-250,y-25,316,346,300,200);
  ellipse(x-275,y-25,323,346,300,200);*/
  x=x-75; y=y+65;
  line(x,y,x,y+35);
  line(x,y,x,y+35);
  x=x+75; y=y-65;
/*  setfillstyle(SOLID_FILL,RED);
  floodfill(x,y-30,WHITE);
  setfillstyle(SOLID_FILL,12);
  floodfill(x,y,WHITE);
  setfillstyle(SOLID_FILL,BLUE);
  floodfill(x,y+45,WHITE);
  setfillstyle(SOLID_FILL,GREEN);
  floodfill(x,y+65,WHITE);
  setfillstyle(SOLID_FILL,BLUE);
  floodfill(x,y+100,WHITE);
  setfillstyle(SOLID_FILL,BROWN);
  floodfill(x,y+150,WHITE);*/
  x=x-75; y=y+65;
  if(p==0)
  { hand3(x,y,92,30);
    hand(x,y,92,30); }
  else
   hand2(x,y,92,30);
}
Exemple #10
0
void renderScene()
{
    // Clear framebuffer & depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    //Enable lighting
    glEnable(GL_LIGHTING);
    //Set the material properties
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, emerald_ambient);
    glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, emerald_diffuse);
    glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, emerald_specular);
    glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, emerald_shininess);

    // Reset Modelview matrix
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    // Set view position & direction
    // (Camera at (0,0,5) looking down the negative Z-axis)
    gluLookAt(0, 0, 5, 0, 0, -1, 0, 1, 0);

    torso();
    glPushMatrix();
        head();
    glPopMatrix();
    glPushMatrix();
        upper_right_arm();
        lower_arm();
        hand();
    glPopMatrix();
    glPushMatrix();
        upper_left_arm();
        lower_arm();
        hand();
    glPopMatrix();
    glPushMatrix();
        upper_right_leg();
        lower_leg();
    glPopMatrix();
    glPushMatrix();
        upper_left_leg();
        lower_leg();
    glPopMatrix();

    glutSwapBuffers();
}
Exemple #11
0
void main()
{
 int gdriver = DETECT, gmode;
 initgraph(&gdriver, &gmode, "\\tc\\bgi");
 cleardevice();

 hand();

 getch();
 closegraph();
}
TEST (HandSuitsPoints_Test, WeakTwo_hand) {

    HandSuitsPoints hand(5,5,1,2,8);

    EXPECT_EQ(5, hand.getSuitCount(CLUB));
    EXPECT_EQ(5, hand.getSuitCount(DIAMOND));
    EXPECT_EQ(1, hand.getSuitCount(HEART));
    EXPECT_EQ(2, hand.getSuitCount(SPADE));

    EXPECT_EQ(8, hand.getPoints());
}
TEST (HandSuitsPoints_Test, NT_hand) {

    HandSuitsPoints hand(4,3,3,3,16);

    EXPECT_EQ(4, hand.getSuitCount(CLUB));
    EXPECT_EQ(3, hand.getSuitCount(DIAMOND));
    EXPECT_EQ(3, hand.getSuitCount(HEART));
    EXPECT_EQ(3, hand.getSuitCount(SPADE));

    EXPECT_EQ(16, hand.getPoints());
}
TEST (HandSuitsPoints_Test, Basic) {

    HandSuitsPoints hand(4,4,4,1,12);

    EXPECT_EQ(4, hand.getSuitCount(CLUB));
    EXPECT_EQ(4, hand.getSuitCount(DIAMOND));
    EXPECT_EQ(4, hand.getSuitCount(HEART));
    EXPECT_EQ(1, hand.getSuitCount(SPADE));

    EXPECT_EQ(12, hand.getPoints());
}
TEST (HandSuitsPoints_Test, OneSuit_hand) {

    HandSuitsPoints hand(2,5,3,3,13);

    EXPECT_EQ(2, hand.getSuitCount(CLUB));
    EXPECT_EQ(5, hand.getSuitCount(DIAMOND));
    EXPECT_EQ(3, hand.getSuitCount(HEART));
    EXPECT_EQ(3, hand.getSuitCount(SPADE));

    EXPECT_EQ(13, hand.getPoints());
}
Exemple #16
0
void DoRcv(void)
{

  unsigned char i,j;

  if(GsmRcvCnt!=0)
  {
      //收到了完整的AT指令,完整的AT指令是以0x0a 0x0d结尾的。故作此判断,在接收的过程中是否收到0x0a 0x0d
      if (GsmRcvCnt >= 2)
      {
         if( (GsmRcv[GsmRcvCnt-2] == 0x0d) && (GsmRcv[GsmRcvCnt-1] == 0x0a) )
         {
        
            if((hand("CLOSED")) || (hand("ERROR")))
            {
              ConnectFlag=0;
              LogFlag=0;
              clr_Buf();
            }
         }
      }
    for (i=0;i<(GsmRcvCnt-Num_Of_Package+1);i++)  //在收到的所有数据中,提取服务器指令,最多提取CMD_num条
    {
       if ((GsmRcv[i] == 0x60)&& (GsmRcv[i+Num_Of_Package-1] == 0xff))
       {
         for(j=0;j<Num_Of_Package;j++)
         {
           CMD[CMD_num][j]=GsmRcv[j+i];
         }
         CMD_num++;
       }
    }
    clr_Buf();
  }

  if(CMD_num!=0)
  {
    DoCommand();
    CMD_num--;
  }
}
Exemple #17
0
void IKModule::update(float elapsed_time) {
	Vector2f target = hand().xy;
	if (length(target - BasePos) > BaseLen + SegLen) {
		target = BasePos + normalize(target - BasePos) * (BaseLen + SegLen);
	}
	{
		float a = BaseLen;
		float b = SegLen;
		float c = length(target - BasePos);
		float val = (c * c - a * a - b * b) / (-2.0f * a * b);
		if (val < -1.0f) val = -1.0f;
		if (val > 1.0f) val = 1.0f;
		seg_ang() = float(M_PI) + acosf(val);
	}
	{
		Vector2f tip = BasePos + make_vector(BaseLen, 0.0f) + SegLen * make_vector(cosf(seg_ang()), sinf(seg_ang()));
		base_ang() = -atan2(tip.y - BasePos.y, tip.x - BasePos.x);
	}
	base_ang() += atan2(target.y - BasePos.y, target.x - BasePos.x);
	hand_ang() = hand().z - base_ang() - seg_ang();
}
void GLElbowFlexWidget::drawMovingArm() {

    upperArm();

    elbow();

    rotateForeArm();

    foreArm();

    hand();
}
Exemple #19
0
void fist(float wristangle){
	matrixPush(ModelView);
	matrixRotate(ModelView, wristangle, 0, 0, 1);

	matrixPush(ModelView);
	matrixScale(ModelView, .5, .5, 1);
	joint();
	matrixPop(ModelView);
	
	hand();

	matrixPop(ModelView);
}
Exemple #20
0
	IKModule() {
		in_ports.push_back(&hand);
		hand() = make_vector(BaseLen+SegLen+BasePos.x, BasePos.y, 0.0f);
		hand.position = make_vector(-0.25f, 0.0f);

		out_ports.push_back(&base_ang);
		out_ports.push_back(&seg_ang);
		out_ports.push_back(&hand_ang);
		base_ang() = seg_ang() = hand_ang() = 0.0f;
		base_ang.position = make_vector(0.25f, 1.0f / 6.0f - 0.5f);
		seg_ang.position  = make_vector(0.25f, 3.0f / 6.0f - 0.5f);
		hand_ang.position = make_vector(0.25f, 5.0f / 6.0f - 0.5f);
	}
/*!
  Draw a clock hand

  \param painter Painter
  \param hd Specify the type of hand
  \param center Center of the clock
  \param radius Maximum length for the hands
  \param direction Direction of the hand in degrees, counter clockwise
  \param cg ColorGroup
*/
void QwtAnalogClock::drawHand( QPainter *painter, Hand hd,
                               const QPointF &center, double radius, double direction,
                               QPalette::ColorGroup cg ) const
{
    const QwtDialNeedle *needle = hand( hd );
    if ( needle )
    {
        if ( hd == HourHand )
            radius = qRound( 0.8 * radius );

        needle->draw( painter, center, radius, direction, cg );
    }
}
Exemple #22
0
std::vector<Card> Deck::deal(unsigned numCards)
{
    assert(numCards > 0);
    assert(cards_.size() >= numCards);

    std::vector<Card> hand(numCards);
    for (unsigned i = 0; i < numCards; i++)
    {
        hand[i] = cards_.back();
        cards_.pop_back();
    }

    return hand;
}
Exemple #23
0
void CCardGame::play( void ) {
	while( mPlayer1Cards.isDeckEmpty() == false && mPlayer2Cards.isDeckEmpty() == false ){
		// cout<<"BEFORE "<<"("<<mPlayer1Cards.getDeckSize()<<","<<mPlayer2Cards.getDeckSize()<<") "<<endl<<*this;
		hand();
		gameLogFile<<"AFTER "<<"("<<mPlayer1Cards.getDeckSize()<<","<<mPlayer2Cards.getDeckSize()<<") "<<endl<<*this;
	}
	if( mPlayer1Cards.isDeckEmpty() == true ) {
		gameLogFile<<endl<<"Player 2 is the winner!"<<endl;
	} else if( mPlayer2Cards.isDeckEmpty() == true ) {
		gameLogFile<<endl<<"Player 1 is the winner!"<<endl;
	}
	gameLogFile<<"Total hands: "<<mHands<<endl;
	gameLogFile<<"Total wars: "<<mWars<<endl;
}
// update the error for a particle based on the stored data
HRESULT ParticleSwarmOptimizer::update_particle_error( Particle& p ) {
  HRESULT hr = S_OK;

  HandModel hand( p.curr_sln );
  // render the model stored by the particle.
  hr = renderer.render( hand );
  if ( FAILED(hr) ) {
    return hr;
  }

  generate_matched_depths();

  p.curr_error = calculate_error_term(); 

  return hr;
}
Exemple #25
0
Fichier : wrap.c Projet : kahrs/cda
void
wrap(Signal *s)
{
	if(s->alg == 0)
		s->alg = defroute;
	switch(s->alg)
	{
	case RTSP:	tsp(s); s->prfn = prseq; break;
	case RTSPE:	tspe(s); s->prfn = prseq; break;
	case RHAND:	hand(s); s->prfn = prseq; break;
	case RMST:	mst(s); s->prfn = prmst; break;
	case RMST3:	mst3(s); s->prfn = prmst; break;
	default:
		f_major("Unknown routing algorithm %d", s->alg);
		abort();
		return;
	}
	calclen(s);
}
TEST(Libev, Webscoket) {
  ServerWebHandler hand(kHinf);
  common::libev::tcp::TcpServer* serv = new common::libev::tcp::TcpServer(g_hs, false, &hand);
  common::ErrnoError err = serv->Bind(true);
  ASSERT_FALSE(err);

  err = serv->Listen(5);
  ASSERT_FALSE(err);

  auto tp = THREAD_MANAGER()->CreateThread(&ExitWebServer, serv);
  GTEST_ASSERT_EQ(tp->GetHandle(), common::threads::invalid_thread_handle());
  bool res_start = tp->Start();
  ASSERT_TRUE(res_start);

  int res_exec = serv->Exec();
  ASSERT_TRUE(res_exec == EXIT_SUCCESS);
  tp->Join();
  delete serv;
}
Exemple #27
0
Grasp GraspSet::createHypothesis(const Eigen::Vector3d& sample, const PointList& point_list,
  const std::vector<int>& indices_learning, const Eigen::Matrix3d& hand_frame, const FingerHand& finger_hand) const
{
  // extract data for classification
  PointList point_list_learning = point_list.slice(indices_learning);

//  std::cout << point_list_learning.getPoints().block(0,0,3,5) << "\n";
//  std::cout << "---------------\n";
//  std::cout << point_list_learning.getNormals().block(0,0,3,5) << "\n";

  // calculate grasp width (hand opening width)
  double width = point_list_learning.getPoints().row(0).maxCoeff() - point_list_learning.getPoints().row(0).minCoeff();

  Grasp hand(sample, hand_frame, finger_hand, width);

  // evaluate if the grasp is antipodal
  labelHypothesis(point_list_learning, finger_hand, hand);

  return hand;
}
Exemple #28
0
void * simulator(void * v) {
  uint32_t ngames = ((uint32_t *)v)[0];
  uint32_t * ohs = (uint32_t *)malloc(2*(np-1)*sizeof(uint32_t));
  uint32_t cs[7], myas[7], cs0, cs1, result, result1, i, j, k;
  uint32_t mycounters[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  // int mywins = 0, mydraws = 0;
  deck * d = newdeck();
  for (i=0; i<kc; i++) {
    pick(d, as[i]);
    myas[i] = as[i];
  }
  for (i=0; i<ngames; i++) {
    int64_t score;
    initdeck(d, 52-kc);
    for (j=0; j<2*(np-1); j++) ohs[j] = draw(d);
    for (j=kc; j<7; j++) myas[j] = draw(d);
    for (j=0; j<7; j++) cs[j] = myas[j];
    sort(cs);
    score = eval7(cs);
    result = WIN;
    for (j=0; j<np-1; j++) {
      cs[0] = ohs[2*j];
      cs[1] = ohs[2*j+1];
      for (k=2; k<7; k++) cs[k] = myas[k];
      sort(cs);
      result1 = comp7(cs, score);
      if (result1 < result) result = result1;
      if (result == LOSS) break;
    }
    mycounters[result]++;
    mycounters[hand(score)]++;
  }
  pthread_mutex_lock(&tlock);
  for (i=0; i<12; i++) {
    counters[i] += mycounters[i];
  }
  pthread_mutex_unlock(&tlock);
  free(ohs);
  free(d);
  return NULL;
}
Exemple #29
0
Documentation  Josh Johnson 10/11/2015

Documentation on smithy
Smithy is a card that when played has the player draw 3 cards into their hand.  The smithycard is then discarded.

Documentation on Adventurer Card
The Adventurer card draws cards until two treasure cards are drawn.  The two
treasure cards stay in the player's hand. The other cards are discarded along
with the Adventurer card

discardCard()
discardCard function has several properties, namely, as the funtion is so aptly named, to discard a card.  Normally this would be to the player's discard pile (or 'played pile' as the comments state).  However, discardCard() will 'trash' a card when the trashFlag is set.

To discard the card, the card is first copied to the top of the discard pile (assuming it's not trashed).  It is then removed from the hand, either by subtracting the hand count by one if it's at the end, or by doing a swap with the last card in the hand and then subtracting from the hand (since the hand is an array)

updateCoins()
For the player's turn, counts the number of coins in the player's hand.

To accomplish this, it resents the coin count to 0, then iteratively looks at each card in the player's hand for copper, silver, and gold.  When it comes across these cards, the appropriate value is added to the player's coin count.  Then any extra bonus amounts (from an action card for example) which was passed in to the function is added in to the total.
Exemple #30
0
	int runTest()
	{
		Hand hand(Hand::STRAIGHTFLUSH);
		assert(hand.print()=="StFlush");
		return 0;
	}