void Search() { int i1,i2,i3,i4,i5,i6,i7,i8,z1=0,z2=0,z3=0,z4=0,z5=0; for (i1=1;i1<10;++i1) for (i2=1;i2<10;++i2) { if (!Deal(g[1][1],i1,i2,g[1][5])) continue; g[1][3]=e;if (e<=0 || e>9) continue; for (i3=1;i3<10;i3+=2) for (i4=1;i4<10;i4+=2) { if (!Deal(g[1][5],i3,i4,g[5][5])) continue; g[3][5]=e;if (e<=0 || e>9) continue; for (i5=1;i5<10;i5+=2) for (i6=1;i6<10;i6+=2) { if (!Deal(g[5][1],i6,i5,g[5][5])) continue; g[5][3]=e;if (e<=0 || e>9) continue; if (!Deal(i1,g[2][2],g[4][2],i6)) continue; g[3][2]=e;if (e<0 || e>9) continue; if (!Deal(i2,g[2][4],g[4][4],i5)) continue; g[3][4]=e;if (e<0 || e>9) continue; for (i7=1;i7<10;++i7) for (i8=1;i8<10;++i8) { if (!Deal(g[1][1],i8,i7,g[5][1])) continue; g[3][1]=e;if (e<=0 || e>9) continue; if (!Deal(i8,g[2][2],g[2][4],i3)) continue; g[2][3]=e;if (e<0 || e>9) continue; if (!Deal(i7,g[4][2],g[4][4],i4)) continue; g[4][3]=e;if (e<0 || e>9) continue; if (!Deal(g[3][1],g[3][2],g[3][4],g[3][5])) continue; if (e!=g[3][3]) continue; if (!Deal(g[1][3],g[2][3],g[4][3],g[5][3])) continue; if (e!=g[3][3]) continue; g[1][2]=i1; g[1][4]=i2; g[2][5]=i3; g[4][5]=i4; g[5][2]=i6; g[5][4]=i5; g[2][1]=i8; g[4][1]=i7; print(); } } } } }
TEST_F(ComputerFixture, yourTurnToSelectKitty) { Deal(); EXPECT_EQ(lua_gettop(L), 0); debug; ASSERT_NO_THROW(yourTurnToSelectKitty(m_kitty)); EXPECT_EQ(lua_gettop(L), 0); }
void Game::DoMove(wxDC& dc, Pile* src, Pile* dest) { if (m_moveIndex < MaxMoves) { if (src == dest) { wxMessageBox(wxT("Game::DoMove() src == dest"), wxT("Debug message"), wxOK | wxICON_EXCLAMATION); } m_moves[m_moveIndex].src = src; m_moves[m_moveIndex].dest = dest; m_moveIndex++; // when we do a move any moves in redo buffer are discarded m_redoIndex = m_moveIndex; } else { wxMessageBox(wxT("Game::DoMove() Undo buffer full"), wxT("Debug message"), wxOK | wxICON_EXCLAMATION); } if (!m_inPlay) { m_inPlay = true; m_numGames++; } DisplayScore(dc); if (HaveYouWon()) { wxWindow *frame = wxTheApp->GetTopWindow(); wxWindow *canvas = (wxWindow *) NULL; if (frame) { wxWindowList::compatibility_iterator node = frame->GetChildren().GetFirst(); if (node) canvas = (wxWindow*)node->GetData(); } // This game is over m_inPlay = false; // Redraw the score box to update games won DisplayScore(dc); if (wxMessageBox(wxT("Do you wish to play again?"), wxT("Well Done, You have won!"), wxYES_NO | wxICON_QUESTION) == wxYES) { Deal(); canvas->Refresh(); } else { // user cancelled the dialog - exit the app ((wxFrame*)canvas->GetParent())->Close(true); } } }
bool hhPoker::HandleSingleGuiCommand(idEntity *entityGui, idLexer *src) { idToken token; if (!src->ReadToken(&token)) { return false; } if (token == ";") { return false; } if (token.Icmp("deal") == 0) { Deal(); } else if (token.Icmp("draw") == 0) { Draw(); } else if (token.Icmp("mark1") == 0) { Mark(0); } else if (token.Icmp("mark2") == 0) { Mark(1); } else if (token.Icmp("mark3") == 0) { Mark(2); } else if (token.Icmp("mark4") == 0) { Mark(3); } else if (token.Icmp("mark5") == 0) { Mark(4); } else if (token.Icmp("incbet") == 0) { IncBet(); } else if (token.Icmp("decbet") == 0) { DecBet(); } else if (token.Icmp("reset") == 0) { Reset(); } else if (token.Icmp("restart") == 0) { bCanDeal = bCanIncBet = bCanDecBet = true; bCanDraw = bCanMark1 = bCanMark2 = bCanMark3 = bCanMark4 = bCanMark5 = false; PlayerCredits = spawnArgs.GetInt("credits"); bGameOver = false; Bet = PlayerBet = 1; UpdateView(); } else { src->UnreadToken(&token); return false; } return true; }
TEST_F(ComputerFixture, bidWon) { Deal(); Bidding bidding; ASSERT_NO_THROW(bidding.bid(this, Bid(Suit::CLUBS, 10))); EXPECT_EQ(lua_gettop(L), 0); ASSERT_NO_THROW(bidWon(&bidding, this)); EXPECT_EQ(lua_gettop(L), 0); }
TEST_F(ComputerFixture, yourTurnToBid) { Deal(); Bidding bidding; EXPECT_EQ(bidding.count(), 0); EXPECT_EQ(lua_gettop(L), 0); Bid b; ASSERT_NO_THROW(b = yourTurnToBid(&bidding)); EXPECT_EQ(lua_gettop(L), 0); debug << b; }
TEST_F(ComputerFixture, yourTurnToPlay) { Deal(); EXPECT_EQ(lua_gettop(L), 0); debug; Trick t; EXPECT_EQ(t.size(), 0); Card* c; ASSERT_NO_THROW(c = yourTurnToPlay(&t)); EXPECT_EQ(lua_gettop(L), 0); debug << *c; }
void Deck::AdditionalCards(GenericPlayer& aGenericPlayer) { Deal(aGenericPlayer); // std::cout << " after additional deal total points for now: " << aGenericPlayer.GetTotal() << std::endl; // we need to print out the hand ? std::cout << aGenericPlayer << "\n"; if(aGenericPlayer.IsBusted() ) { aGenericPlayer.Bust(); } }
TEST_F(ComputerFixture, trickWon) { Deal(); EXPECT_EQ(lua_gettop(L), 0); debug; Trick t; ASSERT_NO_THROW(t.playCard(this, hand.at(0))); ASSERT_NO_THROW(t.playCard(this, hand.at(1))); ASSERT_NO_THROW(t.playCard(this, hand.at(2))); ASSERT_NO_THROW(t.playCard(this, hand.at(3))); EXPECT_EQ(t.size(), 4); ASSERT_NO_THROW(trickWon(t, t.winner(Suit::DIAMONDS))); EXPECT_EQ(lua_gettop(L), 0); }
Game::Game(FortyFrame* frame, int wins, int games, int score) : m_inPlay(false), m_moveIndex(0), m_redoIndex(0), m_bmap(0), m_bmapCard(0) { symbol = new wxBitmap(symbols_xpm); if (!symbol->IsOk()) { ::wxMessageBox(wxT("Failed to load bitmap CardSymbols"), wxT("Error")); } picture = new wxBitmap(Pictures); if (!picture->IsOk()) { ::wxMessageBox(wxT("Failed to load bitmap CardPictures"), wxT("Error")); } int i; m_pack = new Pack(frame, this, 2, 2 + 4 * (CardHeight + 2)); srand(time(0)); for (i = 0; i < 5; i++) m_pack->Shuffle(); m_discard = new Discard(frame, 2, 2 + 5 * (CardHeight + 2)); for (i = 0; i < 8; i++) { m_foundations[i] = new Foundation(frame, 2 + (i / 4) * (CardWidth + 2), 2 + (i % 4) * (CardHeight + 2)); } for (i = 0; i < 10; i++) { m_bases[i] = new Base(frame, 8 + (i + 2) * (CardWidth + 2), 2); } Deal(); m_srcPile = 0; m_liftedCard = 0; // copy the input parameters for future reference m_numWins = wins; m_numGames = games; m_totalScore = score; m_currentScore = 0; }
bool hhBlackJack::HandleSingleGuiCommand(idEntity *entityGui, idLexer *src) { idToken token; if (!src->ReadToken(&token)) { return false; } if (token == ";") { return false; } if (token.Icmp("deal") == 0) { Deal(); } else if (token.Icmp("hit") == 0) { Hit(); } else if (token.Icmp("stay") == 0) { Stay(); } else if (token.Icmp("double") == 0) { Double(); } else if (token.Icmp("incbet") == 0) { IncBet(); } else if (token.Icmp("decbet") == 0) { DecBet(); } else if (token.Icmp("reset") == 0) { Reset(); } else if (token.Icmp("restart") == 0) { PlayerCredits = spawnArgs.GetInt("credits"); Bet = PlayerBet = 1; EndGame(); UpdateView(); } else { src->UnreadToken(&token); return false; } return true; }
int main() { int i,j,flag=0; char tar[11]; FILE *fin = fopen ("ttwo.in", "r"); FILE *fout = fopen ("ttwo.out", "w"); for(i=1;i<=10;i++) { fscanf(fin,"%s",tar); for(j=0;j<10;j++) { if(tar[j]=='.') map[i][j+1]=0; else if(tar[j]=='*') map[i][j+1]=1; else if(tar[j]=='F') { fr=i; fc=j+1; } else if(tar[j]=='C') { cr=i; cc=j+1; } } } while(Deal()) { tot++; if(fr==cr&&fc==cc) { fprintf(fout,"%d\n",tot); flag=1; break; } } if(flag!=1) fprintf(fout,"0\n"); return 0; }
void CDealFrameAddGift::Deal(CRCClient* poClinet,UINT32 dwSerialNumber,UINT32 dwAreaID,UINT32 dwPlayerID,map<string,string> &mapField) { if(NULL == poClinet) { return; } if (mapField[PLAYER_ID].empty() || mapField[GET_RES_INFO_VALUE_PARAM].empty() || mapField[ADD_GIFT_NAME_AND_DESC].empty() || mapField[ADD_GIFT_OUT_TIME].empty()) { string strErrorMsg = GetRsponeResult(ERR_GM_PARM_INFO::ID_PARAM_ERR); poClinet->Rspone(strErrorMsg.c_str()); } UINT32 unPlayerId = SDAtou(mapField[PLAYER_ID].c_str()); string strAddRes = mapField[GET_RES_INFO_VALUE_PARAM]; string strGiftName = mapField[ADD_GIFT_NAME_AND_DESC]; Deal(poClinet, dwSerialNumber, 0, dwAreaID, dwPlayerID, 0, 0, 0, (TCHAR*)strAddRes.c_str(), (TCHAR*)strGiftName.c_str(), NULL); }
Game::Game(int wins, int games, int score) : m_inPlay(false), m_moveIndex(0), m_redoIndex(0), m_bmap(0), m_bmapCard(0) { int i; m_pack = new Pack(2, 2 + 4 * (CardHeight + 2)); srand(time(0)); for (i = 0; i < 5; i++) m_pack->Shuffle(); m_discard = new Discard(2, 2 + 5 * (CardHeight + 2)); for (i = 0; i < 8; i++) { m_foundations[i] = new Foundation(2 + (i / 4) * (CardWidth + 2), 2 + (i % 4) * (CardHeight + 2)); } for (i = 0; i < 10; i++) { m_bases[i] = new Base(8 + (i + 2) * (CardWidth + 2), 2); } Deal(); m_srcPile = 0; m_liftedCard = 0; // copy the input parameters for future reference m_numWins = wins; m_numGames = games; m_totalScore = score; m_currentScore = 0; }
void hhBlackJack::Event_Deal() { Deal(); }
int main(void) { int n, i, j, k, temp, temp1; int m[M], l[M], num[M]; char p[1000][90], q[1000][90]; scanf("%d", &n); for(i = 0; i < n; i++){ scanf("%s", p[i]); Deal(p[i], q[i]); } for(i = 0; i < M; i++){ m[i] = 1; } for(i = 0; i < n; i++){ for(j = i+1; j < n; j++){ if(strcmp(q[i], q[j]) == 0){ q[j][0] = '\0'; m[i]++; m[j]--; } } } k = 0; for(i = 0; i < n; i++){ if(q[i][0] != '\0' && m[i] > 1){ for(j = 0; j < 7; j++){ num[k] *= 10; temp = q[i][j] - '0'; num[k] += temp; } l[k] = m[i]; k++; } } for(i = 0; i < k; i++){ for(j = i+1; j < k; j++){ if(num[i] > num[j]){ temp = num[i]; num[i] = num[j]; num[j] = temp; temp1 = l[i]; l[i] = l[j]; l[j] = temp1; } } } for(i = 0; i < k; i++){ temp = num[i]; for(j = 7; j >= 0; j--){ if(j == 3){ q[i][j] = '-'; } else{ q[i][j] = '0' + temp%10; temp /= 10; } } q[i][8] = '\0'; } if(k == 0){ printf("No duplicates.\n"); } for(i = 0; i < k; i++){ printf("%s %d\n", q[i], l[i]); } }
int main () { int c; srand (0); InitDeck (&Deck); Shuffle (&Deck); /* Shuffle Deck. */ #if 1 printf ("STRAIGHT_FLUSH_SCORE\t%08x\n",STRAIGHT_FLUSH_SCORE); printf ("FOUR_KIND_SCORE\t\t%08x\n",FOUR_KIND_SCORE); printf ("FULL_HOUSE_SCORE\t%08x\n",FULL_HOUSE_SCORE); printf ("FLUSH_SCORE\t\t%08x\n",FLUSH_SCORE); printf ("STRAIGHT_SCORE\t\t%08x\n",STRAIGHT_SCORE); printf ("THREE_KIND_SCORE\t%08x\n",THREE_KIND_SCORE); printf ("TWO_PAIR_SCORE\t\t%08x\n",TWO_PAIR_SCORE); printf ("TWO_KIND_SCORE\t\t%08x\n",TWO_KIND_SCORE); printf ("\n"); for (c=0; c < 8; c++) { Deal (&Hand, &Deck, 5); DisplayHand5 (&Hand); Deal (&Deck, &Hand, 5); Shuffle (&Deck); } for (c=0; c < 8; c++) { Deal (&Hand, &Deck, 7); DisplayHand7 (&Hand); Deal (&Deck, &Hand, 7); Shuffle (&Deck); } printf("\nRigged hands\n\n"); Hand.len = 5; Hand.entry[0] = 12; Hand.entry[1] = 12+13; Hand.entry[2] = 12+26; Hand.entry[3] = 12+39; Hand.entry[4] = 11; DisplayHand5 (&Hand); Hand.entry[0] = 12; Hand.entry[1] = 12+13; Hand.entry[2] = 12+26; Hand.entry[3] = 11+39; Hand.entry[4] = 11; DisplayHand5 (&Hand); Hand.entry[0] = 12; Hand.entry[1] = 0+13; Hand.entry[2] = 1+26; Hand.entry[3] = 2+39; Hand.entry[4] = 3; DisplayHand5 (&Hand); printf ("\n"); #endif #ifndef DETERMINISTIC srand ((unsigned int) time ((void *) 0)); #endif Shuffle (&Deck); /* Shuffle Deck. */ Hand.len = 0; c = 0; printf ("7 Card Draw test\n\n"); for (;;) { Deal (&Hand, &Deck, 7); if (SevenCardDrawScore (&Hand.entry[0]) != SevenCardDrawScoreSlow (&Hand.entry[0])) break; Deal (&Deck, &Hand, 7); /* Add hand back into Deck. */ Shuffle (&Deck); /* Reshuffle Deck. */ c++; if ((c & 0xFFFFF) == 0) { #ifndef DETERMINISTIC srand ((unsigned int) time ((void *) 0)); #endif printf ("%d \t(no errors)\n", c); } } /* There must be an error ! */ DisplayHand7 (&Hand); return 0; }
void hhPoker::Event_Deal() { Deal(); }
Game::Game(int wins, int games, int score) : m_inPlay(false), m_moveIndex(0), m_redoIndex(0), m_bmap(0), m_bmapCard(0) { int i; m_pack = new Pack(2, 2 + 4 * (CardHeight + 2)); srand(time(0)); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0; i < 5; i++) m_pack->Shuffle(); m_discard = new Discard(2, 2 + 5 * (CardHeight + 2)); #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0; i < 8; i++) { m_foundations[i] = new Foundation(2 + (i / 4) * (CardWidth + 2), 2 + (i % 4) * (CardHeight + 2)); } #if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */ # pragma ivdep # pragma swp # pragma unroll # pragma prefetch # if 0 # pragma simd noassert # endif #endif /* VDM auto patch */ for (i = 0; i < 10; i++) { m_bases[i] = new Base(8 + (i + 2) * (CardWidth + 2), 2); } Deal(); m_srcPile = 0; m_liftedCard = 0; // copy the input parameters for future reference m_numWins = wins; m_numGames = games; m_totalScore = score; m_currentScore = 0; }