Beispiel #1
0
int main(int argc, char **argv)
{
    char *handranksfile = DEFAULT_HANDRANKS_FILE;
    char *hand[NUM_HAND];
    char *community[NUM_COMMUNITY];
    char *last_arg;
    int num_community = argc - 3;
    int num_playing = DEFAULT_NUM_PLAYING;
    int simulated;
    double winprob;
    PokerAI *AI;

    InitEvaluator(handranksfile);

    if (argc < 3)
    {
        fprintf(stderr, "Usage: ./winprob hand1 hand2 [comm1, .. , comm5] [-nx]\n");
        fprintf(stderr, "\tWhere x is the number of opponents (3 by default)\n");
        exit(1);
    }

    for (int i = 0; i < NUM_HAND; i++)
    {
        hand[i] = argv[i + 1];
    }

    for (int i = 0; i < num_community - 1; i++)
    {
        community[i] = argv[NUM_HAND + i + 1];
    }

    //Check if the last card is a community card
    //or a specifier of the number of players
    last_arg = argv[NUM_HAND + num_community];
    if (!strncmp(last_arg, "-n", strlen("-n")))
    {
        num_playing = atoi(last_arg + strlen("-n"));
        num_community--;
    }
    else
    {
        community[num_community - 1] = last_arg;
    }

    AI = CreatePokerAI(TIMEOUT);
    SetHand(AI, hand, NUM_HAND);
    SetCommunity(AI, community, num_community);
    UpdateGameDeck(&AI->game);
    AI->game.num_playing = num_playing;
    winprob = GetWinProbability(AI);
    simulated = AI->games_simulated;

    printf("Win probability: %.2lf%%\n", winprob * 100);
    printf("Games simulated: %dk\n", simulated / 1000);

    //Clean up resources
    DestroyPokerAI(AI);
    return 0;
}
Beispiel #2
0
//------------------------------------------------------------------------
void CItem::SetViewMode(int mode)
{
	m_stats.viewmode = mode;

	if(mode & eIVM_FirstPerson)
	{
		SetHand(m_stats.hand);

		if(!m_parentId)
		{
			uint32 flags = GetEntity()->GetFlags();

			if(!m_stats.mounted)
				flags &= ~ENTITY_FLAG_CASTSHADOW;
			else
				flags |= ENTITY_FLAG_CASTSHADOW;

			//GetEntity()->SetFlags(flags|ENTITY_FLAG_RECVSHADOW);
			DrawSlot(eIGS_FirstPerson, true, !m_stats.mounted);
		}
		else
			DrawSlot(eIGS_FirstPerson, false, false);
	}
	else
	{
		SetGeometry(eIGS_FirstPerson, 0);
	}

	if(mode & eIVM_ThirdPerson)
	{
		DrawSlot(eIGS_ThirdPerson, true);

		if(!m_stats.mounted)
			CopyRenderFlags(GetOwner());
	}
	else
		DrawSlot(eIGS_ThirdPerson, false);

	for(TAccessoryMap::iterator it = m_accessories.begin(); it != m_accessories.end(); it++)
	{
		IItem *pItem = m_pGameFramework->GetIItemSystem()->GetItem(it->second);

		if(pItem)
		{
			CItem *pCItem = static_cast<CItem *>(pItem);

			if(pCItem)
				pCItem->SetViewMode(mode);
		}
	}
}
Beispiel #3
0
void Dealer::Init(Room* room)
{
	m_pRoom = room;
	m_deck.Init();

	bool flag = true;
	for (int handCnt = 0; handCnt < 2; ++handCnt)
	{
		for (int i = 0; i < 5; ++i)
		{
			User* user = m_pRoom->GetUserInfo(i);
			if (user == nullptr) continue;

			user->SetHand(0, m_deck.Draw());

			if (flag)
			{
				// 카지노 보니까 딜러는 한 장만 들고있음..
				flag = false;
				SetHand(m_deck.Draw());
			}
		}
	}

	// 블랙젝인지 체크하고, 블랙젝이면 핸드 상태를 바꿔줌
	for (int i = 0; i < MAX_USERCOUNT_PER_ROOM; ++i)
	{
		User* user = m_pRoom->GetUserInfo(i);
		if (user == nullptr) continue;

		if (std::get<1>(user->GetCardSum(0)) == 21)
		{
			user->SetHandState(0, COMMON::HandInfo::HandState::BLACKJACK);
		}
	}
}