/// <summary> /// Perform a raise, call or fold, based on non-user player's situation in game. /// </summary> /// <returns></returns> static private void makeMoveComputer(Player player) { // The player is going bankrupt. if (player.GetMoney() <= currentBid) { Console.WriteLine($"{player.Name} bets ${player.GetMoney()}."); moneyPool += player.PayEntryFee(player.GetMoney()); } // The player is making a normal move. else { int bidRaise = 0; if (new Random().NextDouble() <= foldProbability(player, currentBid)) { player.Fold(); } else if (new Random().NextDouble() < raiseProbability(player, currentBid)) { bidRaise = player.Raise(currentBid); } else { player.Call(currentBid); } currentBid += bidRaise; moneyPool += currentBid; } }
/// <summary> /// Choose to raise the bid, call or fold. /// </summary> static private void makeMoveUser(Player player) { // The player is going bankrupt. if (player.GetMoney() <= currentBid) { Console.WriteLine($"Bet ${player.GetMoney()}."); Console.ReadKey(true); ConsoleEditor.ClearLastLines(1); Console.WriteLine($"{player.Name} bets ${player.GetMoney()}."); moneyPool += player.PayEntryFee(player.GetMoney()); } // The player is making a normal move. else { int bidRaise = 0; bool repeat = true; // No one raised the bid. if (currentBid == 0) { while (repeat) { Console.WriteLine("[B] Bet\n[C] Check\n[F] Fold\n"); var key = Console.ReadKey(true).Key; ConsoleEditor.ClearLastLines(4); switch (key) { // A bet is a raise, when the bid is 0. case ConsoleKey.B: bidRaise = player.Raise(currentBid); currentBid += bidRaise; moneyPool += currentBid; repeat = false; break; // A check is a call, when the bid is 0. case ConsoleKey.C: player.Call(currentBid); repeat = false; break; case ConsoleKey.F: player.Fold(); repeat = false; break; } } } // The bid is already raised. else { while (repeat) { Console.WriteLine("[C] Call\n[R] Raise\n[F] Fold\n"); var key = Console.ReadKey(true).Key; ConsoleEditor.ClearLastLines(4); switch (key) { case ConsoleKey.C: player.Call(currentBid); moneyPool += currentBid; repeat = false; break; case ConsoleKey.R: bidRaise = player.Raise(currentBid); currentBid += bidRaise; moneyPool += currentBid; repeat = false; break; case ConsoleKey.F: player.Fold(); repeat = false; break; } } } } }