private Card[,] GetPossipleCards(Card[] Field, Card[] PlayerCards) { Card[] PosCards = new Card[45]; int index = 0; for (int i = 0; i < 52; i++) { if ((Deck[i] != PlayerCards[0]) && (Deck[i] != PlayerCards[1]) && (Deck[i] != Field[0]) && (Deck[i] != Field[1]) && (Deck[i] != Field[2]) && (Deck[i] != Field[3]) && (Deck[i] != Field[4])) { PosCards[index] = Deck[i]; index++; } } Card[,] PosHandsAll = new Card[990, 7]; index = 0; for (int i = 0; i < 44; i++) { for (int j = i; j < 44; j++) { Card[] PosHands = new Card[7]; Card[] tempHand = new Card[5]; Comb[] TempComb = new Comb[21]; PosHands[0] = Field[0]; PosHands[1] = Field[1]; PosHands[2] = Field[2]; PosHands[3] = Field[3]; PosHands[4] = Field[4]; PosHands[5] = PosCards[i]; PosHands[6] = PosCards[j]; PosHandsAll[index, 0] = PosHands[0]; PosHandsAll[index, 1] = PosHands[1]; PosHandsAll[index, 2] = PosHands[2]; PosHandsAll[index, 3] = PosHands[3]; PosHandsAll[index, 4] = PosHands[4]; PosHandsAll[index, 5] = PosHands[5]; PosHandsAll[index, 6] = PosHands[6]; index++; } } return(PosHandsAll); }
public Comb[] GetCombs(Card[] Cards) { Comb[] TempComb = new Comb[21]; int[,] CombinationIndex = new int[, ] { { 1, 2, 3, 4, 5 }, { 1, 2, 3, 4, 6 }, { 1, 2, 3, 4, 7 }, { 1, 2, 3, 5, 6 }, { 1, 2, 3, 5, 7 }, { 1, 2, 3, 6, 7 }, { 1, 2, 4, 5, 6 }, { 1, 2, 4, 5, 7 }, { 1, 2, 4, 6, 7 }, { 1, 2, 5, 6, 7 }, { 1, 3, 4, 5, 6 }, { 1, 3, 4, 5, 7 }, { 1, 3, 4, 6, 7 }, { 1, 3, 5, 6, 7 }, { 1, 4, 5, 6, 7 }, { 2, 3, 4, 5, 6 }, { 2, 3, 4, 5, 7 }, { 2, 3, 4, 6, 7 }, { 2, 3, 5, 6, 7 }, { 2, 4, 5, 6, 7 }, { 3, 4, 5, 6, 7 } }; Card[] Temp = new Card[5]; for (int i = 0; i < 21; i++) { for (int j = 0; j < 5; j++) { Temp[j] = Cards[CombinationIndex[i, j] - 1]; } Comb Te = new Comb(Temp); TempComb[i] = Te; } return(TempComb); }
public void Odds() { var what = GetPossipleCards(Field, PlayerHand); int wins = 0; int draws = 0; int loses = 0; Card[] Intro = new Card[7]; Intro[0] = Field[0]; Intro[1] = Field[1]; Intro[2] = Field[2]; Intro[3] = Field[3]; Intro[4] = Field[4]; Intro[5] = PlayerHand[0]; Intro[6] = PlayerHand[1]; Comb[] PlayerCombs = new Comb[21]; PlayerCombs = GetCombs(Intro); Comb PlayerComb = new Comb(); PlayerComb = PlayerCombs[0]; for (int i = 0; i < 21; i++) { if (PlayerComb < PlayerCombs[i]) { PlayerComb = PlayerCombs[i]; } } for (int i = 0; i < 990; i++) { Card[] cards = new Card[7]; cards[0] = what[i, 0]; cards[1] = what[i, 1]; cards[2] = what[i, 2]; cards[3] = what[i, 3]; cards[4] = what[i, 4]; cards[5] = what[i, 5]; cards[6] = what[i, 6]; Comb tempCom = new Comb(cards); if (tempCom < PlayerComb) { wins++; } else if (tempCom > PlayerComb) { loses++; } else if (tempCom == PlayerComb) { draws++; } } double temp = 100 * wins / (wins + loses + draws); HumanWinningOdds = temp; temp = 100 * loses / (wins + loses + draws); HumanLosingOdds = temp; ComputerWinningOdds = temp; temp = 100 * draws / (wins + loses + draws); HumanDrawingOdds = temp; }
private void ShowComputerCardsAndCompare() { Card[] Intro = new Card[7]; Intro[0] = HoldemGame.Field[0]; Intro[1] = HoldemGame.Field[1]; Intro[2] = HoldemGame.Field[2]; Intro[3] = HoldemGame.Field[3]; Intro[4] = HoldemGame.Field[4]; Intro[5] = HoldemGame.PlayerHand[0]; Intro[6] = HoldemGame.PlayerHand[1]; Comb[] PlayerCombs = new Comb[21]; PlayerCombs = HoldemGame.GetCombs(Intro); Comb PlayerComb = new Comb(); PlayerComb = PlayerCombs[0]; for (int i = 0; i < 21; i++) { if (PlayerComb < PlayerCombs[i]) { PlayerComb = PlayerCombs[i]; } } Intro[5] = HoldemGame.ComputerHand[0]; Intro[6] = HoldemGame.ComputerHand[1]; Comb[] ComputerCombs = new Comb[21]; ComputerCombs = HoldemGame.GetCombs(Intro); Comb ComputerComb = new Comb(); ComputerComb = ComputerCombs[0]; for (int i = 0; i < 21; i++) { if (ComputerComb < ComputerCombs[i]) { ComputerComb = ComputerCombs[i]; } } if (PlayerComb > ComputerComb) { PlayerWins(); } else if (PlayerComb == ComputerComb) { PlayerDraws(); } else { PlayerLoses(); MessageBox.Show("WH"); } HoldemGame.ShuffleDeck(); HoldemGame.Odds(); ShowHumanPlayerCards(); ShowFieldCards(); ShowComputerPlayerCards(); txtbxPlayerOddsOfWinning.Text = HoldemGame.HumanWinningOdds.ToString(); txtbxPlayerOddsOfLosing.Text = HoldemGame.HumanLosingOdds.ToString(); txtbxPlayerOddsDraw.Text = HoldemGame.HumanDrawingOdds.ToString(); }