Beispiel #1
0
        public TestPokerAI()
        {
            list       = new List <Card>();
            pokerCombo = new PokerAI(TypePlayerPoker.NORMAL);
            pokerCombo.CardsOnBoard = list;
            pokerTest = new PrivateObject(pokerCombo, new PrivateType(typeof(PokerAI)));

            cardRank   = Card.CardRank.Two;
            cardSuit   = Card.CardSuit.Clubs;
            imageBidon = Properties.Resources._2C;
        }
 public PokerAction(GameObject actor, string chairName, bool withMoney)
     : base(actor, chairName, withMoney)
 {
     //Debug.Log("Drunkness: " + state.GetDrunkness());
     pokerAI = new PokerAI(this, Mathf.Max(0, 1 - (int)state.GetDrunkness() / DRUNKNESS_LIMIT), Mathf.Max(50, 100-4*(int)state.GetDrunkness()));
     cardHooks = new Transform[2];
     cardHooks[0] = CharacterAnimator.FindChild(actor, "card_hook_1");
     cardHooks[1] = CharacterAnimator.FindChild(actor, "card_hook_2");
     cardItems = new CardItem[cardHooks.Length];
     busy = true;
     currentHandStrength = 0.0;
 }
        public void TestSelectSuperABCDE()
        {
            _currentHost = PokerNumType.PA;

            _value   = new PatternValue(GetCurrentHost);
            _matcher = new PatternMatcher(_value);
            _pokerAI = new PokerAI(_matcher, _value);

            _pokerAI.SetMyPokers(PokerUtil.ParsePokerList("SQ, SQ, CQ, D2, HA"));

            var lastChuPai = _matcher.Match(PokerUtil.ParsePokerList("D7, HA, D9, D0, DJ"));
            var selected   = _pokerAI.SelectBiggerXXXXOrSuperABCDE(lastChuPai, 0, true);

            Assert.AreEqual(PokerPattern.NULL, selected);
        }
Beispiel #4
0
        public GameForm(Settings settings)   // Think about making Settings in settingsForm and has it as a parameter.
        {
            InitializeComponent();
            _settings = settings;
            // Initialization of List for more readable and homogeneous code
            CreateButtonList();
            CreatePictureBoxList();

            // Creates the game with user settings
            _game = new PokerGame(_settings);
            _game.Players[0].Name = _settings.PlayerName;
            _game.Players[1].Name = "Deep Peer";

            labelPlayerStack.Text = Convert.ToString(_game.Players[0].Stack); // Why only index 0?
            labelTablePot.Text    = Convert.ToString("Pot:   $" + 0);
            labelPlayerName.Text  = _settings.PlayerName;
            UpdatePlayerBlindLabels(_game.Players[0]);

            //AI
            _ai = new PokerAI(_game);

            MainUpdate();
        }
Beispiel #5
0
    /// <summary>
    /// AI出牌
    /// </summary>
    /// <returns></returns>
    public bool AIPlayCards()
    {
        BasePlayer c = players[playerIndex % 3];
        //获取当前手牌的大小
        List <int> myList = new List <int>();

        for (int i = 0; i < c.myCardInfo.Count; i++)
        {
            myList.Add(c.myCardInfo[i].cardIndex);
        }

        //获取上个玩家手牌的大小
        List <int> last = new List <int>();

        if (lastCards.Count != 0)
        {
            for (int i = 0; i < lastCards.Count; i++)
            {
                last.Add(lastCards[i].cardIndex);
            }
        }

        //要排序
        myList.Sort();
        last.Sort();

        //所有符合该牌型的组合,存到字典中
        Dictionary <int, List <int> > result = PokerAI.FindPromptCards(myList, last, lastType);

        //是否能出牌
        if (result == null || result.Count == 0)
        {
            //Debug.Log("字典为空");
            //没有比上家大的牌,不出
            NotPlayCards();
            return(false);
        }

        //所有的key
        List <int> keys = new List <int>();
        //某一个key的值
        List <int> value = new List <int>();

        //循环取到所有的key
        foreach (var item in result.Keys)
        {
            keys.Add(item);
        }

        //随机选择众多结果中的一个结果出 = =
        int vauleCount = MyUtil.GetRange(0, keys.Count);

        value = result[keys[vauleCount]];

        //如上家出333, 那么value为444,有三个4,所以在当前手牌中需要取3个4
        for (int i = 0; i < value.Count; i++)
        {
            for (int j = 0; j < c.myCardInfo.Count; j++)
            {
                if (value[i] == c.myCardInfo[j].cardIndex && c.myCardInfo[j].isSelected == false)
                {
                    c.myCardInfo[j].isSelected = true;
                    break;
                }
            }
        }

        //能出牌,获取出牌牌型
        PokerRules.PopEnable(value, out c.myType);
        lastType = c.myType;

        return(true);
    }