Exemplo n.º 1
0
    private void Start()
    {
        tableCards = GetComponentInChildren <PokerTableCards>();
        players    = GetComponentsInChildren <PokerPlayer>();

        foreach (PokerPlayer p in players)
        {
            p.resetCurrency();
            p.UpdateCurrencyText();
        }

        totalPot          = 0;
        totalPotText.text = totalPot.ToString();

        roundCount     = 1;
        RoundText.text = roundCount.ToString();

        currenBet           = 1;
        currentBetText.text = currenBet.ToString();

        ShuffleDeck();

        cardsDelt = 0;

        StartCoroutine(DealPocketCards() as IEnumerator);
    }
Exemplo n.º 2
0
    public IEnumerator CalculateBet(float currenBet, int cardsDelt, float topCurrency, PokerTableCards table, int deckSize, int turn)
    {
        //use neural network here
        betting = true;

        if (isAi)
        {
            //inputs = { totalCount, heartsCount, dimondCount, spadeCount, clubsCount, hand1, hand2, table1, table2, table3, table4, table5, turn, cash }

            float[] inputs =
            {
                cardsDelt / (52 * deckSize),                                                                                                  //noramlize cards dealt agains size of one deck
                (float)cardCount.GetSuitCount(CardSuit.Heart) / (float)(14 * deckSize),                                                       //noramlize suits dealt agains max amount of suits in deck
                (float)cardCount.GetSuitCount(CardSuit.Dimond) / (float)(14 * deckSize),
                (float)cardCount.GetSuitCount(CardSuit.Spades) / (float)(14 * deckSize),
                (float)cardCount.GetSuitCount(CardSuit.Clubs) / (float)(14 * deckSize),
                (float)((int)cardLocations[0].card.suit + (int)cardLocations[0].card.face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace), //normalize card agains all possible cards
                (float)((int)cardLocations[1].card.suit + (int)cardLocations[1].card.face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace),
                0, 0, 0, 0,                                                                                                                    //set 0 for now and add cards in depeding on turn
                turn / 3,                                                                                                                      //normalize betting turn
                currenCurrency / topCurrency                                                                                                   //normalzie own currenzy against top currency
            };

            if (turn >= 2)
            {
                inputs[7] = (float)((int)table.GetCard(0).suit + (int)table.GetCard(0).face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace);    //normalize card agains all possible cards
                inputs[8] = (float)((int)table.GetCard(1).suit + (int)table.GetCard(1).face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace);
                inputs[9] = (float)((int)table.GetCard(2).suit + (int)table.GetCard(2).face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace);
            }

            if (turn >= 3)
            {
                inputs[10] = (float)((int)table.GetCard(3).suit + (int)table.GetCard(3).face) / (float)((int)CardSuit.Clubs * (int)CardFace.Ace);   //normalize card agains all possible cards
            }

            float[] outputs = network.SendInputs(inputs);

            float topOut   = 0;
            int   outIndex = 0;

            //find larges ouput
            for (int i = 0; i < outputs.Length; i++)
            {
                if (topOut < outputs[i])
                {
                    topOut   = outputs[i];
                    outIndex = i;
                }
            }

            //do decision based on largets value
            switch (outIndex)
            {
            case 0:
                Raise(currenBet);
                break;

            case 1:
                Call(currenBet);
                break;

            case 2:
                Fold();
                break;
            }
        }
        else
        {
            //show buttons
            ChangeButtonVisability(true);
            betPlayer = currenBet;

            //wait for player to press button
            yield return(new WaitWhile(() => betting == true));

            //hide buttons
            ChangeButtonVisability(false);
        }



        yield return(new WaitForSeconds(betDeley));

        betting = false;
        yield return(null);
    }