public virtual Card draw() { Card c = DeckList[0]; DeckList.RemoveAt(0); this.DeckList_Backup.Add(c); cardCounter.countCard(c); return(c); }
// Simulates gameplay for a specific amount of time, or until money runs out, returns the ammount of money left private Double PlayTimedGame() { // Function Variables int gameCount = 0; // Shuffle the deck deck.shuffle(); cardCounter.reset(); // Reinitialize the players foreach (BSPlayer bsp in players) { bsp.setBankRoll(blackJackGameParams.bankroll); // Set how much money each player starts with bsp.clearCurrentBets(); bsp.hasQuit = false; } // Clear the whole list this.bankRoll_vs_GamesPlayed = new List <double>(); // While we haven't finished playing... //REAL CODE: while ((gameCount < (blackJackGameParams.hoursOfPlay * BlackJack.getHandsPerHour(blackJackGameParams.numPlayers))) & (!players[blackJackGameParams.tablePosition].hasQuit)) { // Have the player in question place a bet players[blackJackGameParams.tablePosition].PlaceInitialBet(blackJackGameParams, cardCounter); // Give players their cards dealer.dealCards(players); // Check for dealer and player blackjacks // If the dealer has blackjack, loop through the players and determine wages. Don't worry about insurance/even mmoney as // basic strategy says never take insurrance or even money if (!dealer.hasBlackJack()) { // Let each player take their turn for (int i = 0; i < players.Count; i++) { if (!players[i].hasQuit) { players[i].playHand(dealer, cardCounter); } } // Let the dealer draw until he gets H17 or S17 (Depending on parameters) dealer.drawTo17(blackJackGameParams.H17); } // Add the dealers hidden card so card counters can see cardCounter.countCard(dealer.getHiddenCard()); // Process player winnings but only for the player in question processPlayerWinnings(players[blackJackGameParams.tablePosition], dealer); // Show debugging info //showGameEnd(players, dealer); // Add the specified players bankroll to the plot variable this.bankRoll_vs_GamesPlayed.Add(players[blackJackGameParams.tablePosition].getBankroll()); // Clear the players dealer.clearTable(players); // Check if the cut card was hit (Penetration Percent) Double currentPenetrationPercent = deck.penetrationPercent(); if (currentPenetrationPercent >= blackJackGameParams.deckPenetration) { // Shuffle the deck deck.shuffle(); // Print status message // System.Diagnostics.Debug.AutoFlush = true; // System.Diagnostics.Debug.WriteLine((Double)gameCount / ((Double)BlackJack.getHandsPerHour(blackJackGameParams.numPlayers) * blackJackGameParams.hoursOfPlay) + "% Complete"); // Reset the Count cardCounter.reset(); } gameCount += 1; } // End While Loop return(players[blackJackGameParams.tablePosition].getBankroll()); }