// Enum state #endregion #region Containers & UI private void Start() { // Set the containers from the UI. SetContainers(); // Get components from the player. generator = GetComponentInChildren <HandGenerator>(); collector = GetComponentInChildren <HandCollector>(); audioS = GetComponent <AudioSource>(); mixer = new ContanterMixer(); }
public void Play(int currentPos0Player, ref int p0Bank, ref int p1Bank) { if (_detailedHist && ShowLegend) { Console.WriteLine("LEGEND:"); Console.WriteLine("START Player1Hand Player2Hand WinningPlayer"); Console.WriteLine("CurrentPlayerHand CurrentPlayer HisPosition PreviousPosition NextAction CurrentAction"); } string currentAction = "R1,R1"; int pos = 1; HandGenerator handGenerator = new HandGenerator(16, true); HandInfo handInfo = handGenerator.GenerateRandomHand(); int winningPlayer = handInfo.WinningPlayer; int[] hands = handInfo.Hands; if (_detailedHist) { Console.WriteLine($"START\t{hands[0]:X}\t{hands[1]:X}\t{winningPlayer}"); } using (DbReader dbReader1 = new DbReader(_player1DbName), dbReader2 = new DbReader(_player2DbName)) { int round = 0; int? pay = null; int prevpos = -1; int tries = 0; DbReader[] dbReaders = { dbReader1, dbReader2 }; while (pay == null) { int currentPlayer = (1 - pos) ^ currentPos0Player; if (prevpos == pos) { currentPlayer = pos ^ currentPos0Player; } int? nextPos; string actions; string prob; if (!dbReaders[currentPlayer].GetPossibleActions(pos, hands[currentPlayer], currentAction, out nextPos, out actions, out round, out prob, out pay)) { pos = 1 - pos; tries++; if (tries > 2) { if (_detailedHist) { Console.WriteLine("No action detected!"); } return; } continue; } tries = 0; if (nextPos != null) { if (pos == nextPos.Value && prevpos != pos) { prevpos = pos; continue; } if (pos == nextPos.Value) { prevpos = -1; } else { prevpos = pos; } pos = nextPos.Value; string nextAction = RandomAction(actions, prob); if (_detailedHist) { Console.WriteLine($"{hands[currentPlayer]:X}\t{currentPlayer}\t{pos}\t{prevpos}\t{nextAction}\t{currentAction}"); } currentAction += "," + nextAction; } } if (round == (int)Round.Fold) { int k = pos ^ currentPos0Player; if (k == 0) { p0Bank -= pay.Value; p1Bank += pay.Value; } else { p0Bank += pay.Value; p1Bank -= pay.Value; } } if (round == (int)Round.Showdown) { int k = winningPlayer; if (k == 1) { p0Bank -= pay.Value; p1Bank += pay.Value; } else if (k == 0) { p0Bank += pay.Value; p1Bank -= pay.Value; } } } }
public void GeneratePokerHands() { var hands = HandGenerator.GenerateHands(); Assert.AreEqual(expected: 2, actual: hands.ToList().Count); }
public static void Main(string[] args) { Console.WriteLine(HandEvaluator.Evalutate(HandGenerator.GenerateHands())); Console.ReadLine(); }