public BSInfo(Double ev, BlackJackMove blackJackMove) { this.ev = ev; this.blackJackMove = blackJackMove; }
public void playHand(BSDealer dealer, CardCounting cardCounter) { // We know the dealer doesn't have blackjack because this is tested before this portion of the game even occurs Stack <Card> splitCards = new Stack <Card>(); // Make a stack for holding the split cards int processesListCount = 0; // Keeps track of how many lists have been processed (Also reports the current lists index // While there are cards in the split pile, or their are unprocessed lists... while ((splitCards.Count > 0) | (processesListCount < this.cardList.Count)) { // If we have the same number of lists as we have processed, we must have to handle another split if (this.cardList.Count == processesListCount) { // Add the split card to the new list this.cardList.Add(new List <Card>()); // Add a new wager to the new hand this.currentBet.Add(this.initialBet); this.playerWin.Add(0); // Add the card to the new hand this.cardList[processesListCount].Add(splitCards.Pop()); } // Check if the hand has at least two cards, if it does'nt, then add one. This happens when we split if (this.cardList[processesListCount].Count == 1) { this.cardList[processesListCount].Add(dealer.takeHit()); } // Check if the higher, and lower values are both busted. If so then we've busted this hand so move to the next. if ((BlackJack.getHandValue_Lower(this.cardList[processesListCount]) > 21) & (BlackJack.getHandValue_Lower(this.cardList[processesListCount]) > 21)) { processesListCount += 1; } else { // Get the Basic Strategy move for the current card list BlackJackMove bjm = new BlackJackMove(); // If the player has doubles, but not enough money to split, then find an alternative move if (hasDoublesInHand(processesListCount) & hasQuit) { bjm = bsc.GetStrategyPairToNoPair(this.cardList[processesListCount], dealer.getUpCard()); } else { bjm = bsc.GetStrategy(this.cardList[processesListCount], dealer.getUpCard()); } switch (bjm) { case BlackJackMove.Stay: processesListCount += 1; break; case BlackJackMove.Hit: this.cardList[processesListCount].Add(dealer.takeHit()); // Add a card but don't finish processing this hand break; case BlackJackMove.Double: if (this.cardList[processesListCount].Count == 2) { // If we have enough money to double then do it, otherwise leave the table after the end of the round if ((BankRoll - currentBet[processesListCount]) > 0) { this.cardList[processesListCount].Add(dealer.takeHit()); this.BankRoll -= this.currentBet[processesListCount]; this.currentBet[processesListCount] = 2 * this.currentBet[processesListCount]; processesListCount += 1; break; } else { // Take a hit if we can't double due to money, and mark this as our last round to minimize losses hasQuit = true; this.cardList[processesListCount].Add(dealer.takeHit()); break; } } else { this.cardList[processesListCount].Add(dealer.takeHit()); // Add a card but don't finish processing this hand break; } case BlackJackMove.Double_Stay: // If we haven't hit this hand yet then double, otherwise stay if (this.cardList[processesListCount].Count == 2) { // If we have enough money to double then do it, otherwise leave the table. if ((BankRoll - currentBet[processesListCount]) > 0) { this.cardList[processesListCount].Add(dealer.takeHit()); this.BankRoll -= this.currentBet[processesListCount]; this.currentBet[processesListCount] = 2 * this.currentBet[processesListCount]; processesListCount += 1; break; } else { // Stay if we can't double due to money, and mark this as our last round to minimize losses hasQuit = true; processesListCount += 1; break; } } else { processesListCount += 1; break; } case BlackJackMove.Split: // Put the card from index 0 of the current hand into the stack. // Now, don't increment the processListCount, and reprocesses this hand. // It will only have one card so we will have to add that first. if (((BankRoll - this.initialBet) > 0) & (cardList.Count < 4)) { BankRoll -= this.initialBet; splitCards.Push(this.cardList[processesListCount][1]); this.cardList[processesListCount].RemoveAt(1); break; } else { // If we can't split due to money, then re-evaluate as a hard/soft hand and determine the new best move, mark // as the last turn to minimize losses hasQuit = true; break; } } } } // Even odds paid on split card blackjack }