예제 #1
0
파일: pokerai.c 프로젝트: gorel/C-Poker-AI
/*
 * Manually set the AI's community cards
 * ai: the pokerAI to update
 * community: the cards to give the AI
 * communitysize: the number of community cards in play
 */
void SetCommunity(PokerAI *ai, char **community, int communitysize)
{
    ai->game.communitysize = communitysize;
    for (int i = 0; i < communitysize; i++)
    {
        ai->game.community[i] = StringToCard(community[i]);
    }
}
예제 #2
0
CardsSet* MakeCardsSet(bp::object& o) {
	CardsSet* result = new CardsSet();
    bp::stl_input_iterator<string> begin(o), end;
    for (auto it = begin; it != end; it++) {
    	result->Add(StringToCard(*it));
    }
    return result;
}
예제 #3
0
파일: pokerai.c 프로젝트: gorel/C-Poker-AI
/*
 * Manually set the AI's hand cards
 * ai: the pokerAI to update
 * hand: the cards to give the AI
 * handsize: the number of cards in the AI's hand
 */
void SetHand(PokerAI *ai, char **hand, int handsize)
{
    ai->game.handsize = handsize;
    for (int i = 0; i < handsize; i++)
    {
        ai->game.hand[i] = StringToCard(hand[i]);
    }
}
예제 #4
0
/*
 * Set the card array to the given JSON array
 * cards: the int array of where to place the results
 * json: a JSON array of card strings
 * return: the number of cards in the array
 */
int GetCardArray(int *cards, cJSON *json)
{
    int i;

    for (i = 0; i < cJSON_GetArraySize(json); i++)
    {
        cards[i] = StringToCard(
                JSON_ARRAY_ELEM(json, i)->valuestring);
    }

    return cJSON_GetArraySize(json);
}
예제 #5
0
void CommandLoop(int self_id)
{
	Command cmd = GetCommand();

	/* No switch for strings :( */
	switch (cmd.type) {
		case CommandType_Reveal:
			assert(cmd.params.size() == 2);
			break;
		case CommandType_Out:
			assert(cmd.params.size() >= 1 && cmd.params.size() <= 3);
			if (std::stoi(cmd.params[0]) == self_id) {
				Debug() << "Oh noes, we lost!";
				exit(0);
			}
			for (uint i = 1; i < cmd.params.size(); i++) {
				RemoveCardAllPlayers(StringToCard(cmd.params[i]));
			}
			break;
		case CommandType_Player:
			assert(cmd.params.size() == 1);
			if (std::stoi(cmd.params[0]) != self_id) break;

			MakeMove(self_id);
			break;
		case CommandType_Played:
			assert(cmd.params.size() >= 1 && cmd.params.size() <= 4);
			// Remove played card (cmd.params[1]) from possibilities
			break;
		case CommandType_Protected:
			assert(cmd.params.size() == 1);
			Debug() << "Dammit, didn't realise player " << cmd.params[0] << " was protected";
			break;
		case CommandType_Swap:
			assert(cmd.params.size() == 1);
			break;
		case CommandType_Discard:
			assert(cmd.params.size() == 2);
			break;
		/* These commands shouldn't happen here. */
		case CommandType_Ident:
		case CommandType_Players:
		case CommandType_Start:
		case CommandType_Draw:
		default:
			Debug() << "D: Unrecognised command! \"" << cmd.type << "\"";
			exit(1);
	}
}
예제 #6
0
void
SetGameStateRiver(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 1) {
		printf("ERROR wrong row number in flop msg! \n");
	}
	
	game->communitysize = 5;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("river");

	game->call_no = 0;
	game->raise_no = 0;
			
	stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[0]);
	char card[3] = {'\0'};		
	HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
	game->community[5-1] = StringToCard(card);
}
예제 #7
0
// set game->hand[0] game->hand[1]
void
SetGameStateHold(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 2) {
		printf("ERROR wrong row number in hold msg! \n");
	}
	
	game->handsize = 2;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("deal");
	
	game->call_no = 0;
	game->raise_no = 0;
	
	for (int i = 0; i < 2; ++i) {
		stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[i]);
		char card[3] = {'\0'};		
		HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
		game->hand[i] = StringToCard(card);
	}
}
예제 #8
0
void
SetGameStateFlop(GameState *game, stMsg_t stOneMsg)
{
	if (stOneMsg.m_nRowNo < 3) {
		printf("ERROR wrong row number in flop msg! \n");
	}	
	
	game->communitysize = 3;
	game->your_turn = 0;
	game->phase_last = game->phase;
	game->phase = GetPhase("flop");

	game->call_no = 0;
	game->raise_no = 0;
		
	for (int i = 0; i < 3; ++i) {
		stMsgRow_t stMsgRow = *(stOneMsg.m_pstMsgRow[i]);
		char card[3] = {'\0'};		
		HoldCardMsgRowToChar3(card, stMsgRow.m_szWordRest[0], stMsgRow.m_szWordRest[1]);
		game->community[i] = StringToCard(card);
	}
}
예제 #9
0
uint32_t GetCardBitWrap(const std::string& card) {
	return GetCardBit(StringToCard(card));
}
예제 #10
0
	Card DoMove(float* /*moveValue*/) override {
		bp::object res = this->get_override("do_move")();
		return StringToCard(bp::extract<string>(res));
	}