Example #1
0
 public Question(string q, List <string> a, Table.status t, string e)
 {
     question      = q;
     answers       = a;
     question_type = t;
     explanation   = e;
 }
        private void addQuestion(Table.status questionType)
        {
            if (questionType == Table.status.Flop || questionType == Table.status.Turn)
            {
                int n = table.getHands()[0].compareHand(table.getHands()[1]);
                int outs;
                if (n == 1)
                {
                    // Player winning
                    outs = countOuts(table, table.getHands()[1]);
                }
                else
                {
                    // Opponent winning
                    outs = countOuts(table, table.getHands()[0]);
                }
                Random        rnd     = new Random();
                List <string> answers = new List <string>();
                answers.Add(outs.ToString());
                answers.Add((outs + rnd.Next(1, 4)).ToString());
                int secondAnswer = outs - rnd.Next(1, 4);
                answers.Add(((secondAnswer) < 0?rnd.Next(1, 5):secondAnswer).ToString());
                string explanation = "There are no outs in this case (Meaning that no card will improve the hand).";
                if (outs > 0)
                {
                    explanation = "\nOut cards: \n";
                    for (int i = 0; i < outs_list.Count; i++)
                    {
                        explanation += outs_list[i].ToString() + " (" + outs_strength_list[i].ToString() + ")\n";
                    }
                }
                if (n == 1)
                {
                    // Player winning
                    if (outs > 0)
                    {
                        explanation = "Vilain has " + outs + " outs." + explanation;
                    }
                    questions.Add(new Question("How many outs does the villain have?", answers, questionType, explanation));
                }
                else
                {
                    // Opponent winning
                    if (outs > 0)
                    {
                        explanation = "Player has " + outs + " outs." + explanation;
                    }
                    questions.Add(new Question("How many outs do you have?", answers, questionType, explanation));
                }

                if (questionType == Table.status.Turn)
                {
                    // pot odds bit
                    Random random = new Random();
                    answers = new List <string>();

                    int    pot          = random.Next(1, 9) * 10;         // Generate pot
                    int    bet          = random.Next(pot / 25, pot / 5); // Generatae bet
                    float  winning_odds = outs * 2;
                    float  pot_odds     = 100 / (((float)pot + (float)bet) / (float)bet);
                    string last_line;
                    if (winning_odds > pot_odds)
                    {
                        // Profitable
                        answers.Add("Yes");
                        answers.Add("No");
                        last_line = "Statistically speaking this call is profitable. Because " + winning_odds + "% > " + pot_odds + "%, and as long as chances of winning are higher than the pot odds, it is a profitable call.";
                    }
                    else
                    {
                        // Not profitable
                        answers.Add("No");
                        answers.Add("Yes");
                        last_line = "Statistically speaking this call is not profitable. Because " + winning_odds + "% < " + pot_odds + "%, and since the chances of winning are less than the pot odds, it is not a profitable call.";
                    }
                    string question;
                    if (n == 1)
                    {
                        // Player is winning
                        question = "As Opponent";
                    }
                    else
                    {
                        // Tie or opponent is winning
                        question = "As a Player";
                    }
                    question   += " would you call " + bet + "£ in a " + pot + "£ pot.";
                    explanation = "To answer this question correctly you need to calculate two things: Chances of winning, and pot odds.\nThe easiest way to calculate chances of winning is using the rule of '2', which says that your chances of winnings are outs * 2. In this case chance of winning is:" + outs + " * 2 =" + winning_odds + "%.\nTo calculate pot odds we need to know ratio of pot/bet sizes. In the given situation pot odds are " + (float)pot / (float)bet + " to 1. Converted to percentages it is " + pot_odds + "% .\n" + last_line;
                    // explanation = "Using the rule of '2' the chances of winning are " + winning_odds + "%.\nPot odds are " + pot_odds + "%.\n"+last_line;

                    questions.Add(new Question(question, answers, questionType, explanation));
                }
            }
        }