Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        jeu   = this.GetComponentInParent <LogicGame>();
        IA    = this.gameObject.transform.parent.GetComponentInChildren <IA>();
        pot   = jeu.gameObject.GetComponentInChildren <LogicPot>();
        _menu = jeu.gameObject.transform.Find("Menu").GetComponent <MenuPlay>();

        jeton  = this.transform.parent.gameObject.GetComponent <AudioSource>();
        toc    = IA.gameObject.GetComponent <AudioSource>();
        couche = jeu.gameObject.GetComponent <AudioSource>();

        this.Initcartes();

        _grossePile = this.transform.Find("JetonPile_1").GetComponent <SpriteRenderer>();
        _moyenPile  = this.transform.Find("JetonPile_2").GetComponent <SpriteRenderer>();
        _petitePile = this.transform.Find("JetonPile_3").GetComponent <SpriteRenderer>();
        _grosTas    = this.transform.Find("JetonTas_1").GetComponent <SpriteRenderer>();
        _moyenTas   = this.transform.Find("JetonTas_3").GetComponent <SpriteRenderer>();
        _petitTas   = this.transform.Find("JetonTas_4").GetComponent <SpriteRenderer>();
        _PersoBras  = this.transform.Find("PersoBras").GetComponent <SpriteRenderer>();
        _PersoMise  = this.transform.Find("PersoMise").GetComponent <SpriteRenderer>();
        _deal       = this.transform.Find("deal").GetComponent <SpriteRenderer>();
        _textMise   = this.transform.Find("Canvas").Find("TextMise").GetComponent <Text>();
        _textJeton  = this.transform.Find("Canvas").Find("TextJeton").GetComponent <Text>();
        _Alea       = this.transform.parent.GetComponentInChildren <AleaVar>();

        _textMise.gameObject.SetActive(false);



        _grossePile.enabled = false;
        _moyenPile.enabled  = false;
        _petitePile.enabled = false;
        _grosTas.enabled    = false;
        _moyenTas.enabled   = false;
        _petitTas.enabled   = false;
        _deal.enabled       = false;
        _PersoBras.enabled  = false;
        _PersoMise.enabled  = false;

        this.AddToNbJeton(3000);

        double bluff = PlayerPrefs.GetInt("Bluff");

        //print("coeff" + bluff);
        _coeffBluff = _Alea.LoiNormale(bluff / 100.0, 0.1);
        if (_coeffBluff < 0)
        {
            _coeffBluff = 0;
        }
        if (_coeffBluff > 1)
        {
            _coeffBluff = 1;
        }
    }
Example #2
0
    void VirtualJouer()
    {
        if (!_isCoucher)
        {
            double esperance = IA.CalculEsperances(this, this._cartes, pot.potCards());

            int  IAchoix   = 0;
            bool bluffDesc = false;
            if (jeu.CurrentTour() != 1)
            {
                double bluffDecision = _Alea.LoiBeta(1.3 + 2 * _coeffBluff, 4.8);
                //print("bluff" + bluffDecision);
                if (bluffDecision > 0.5 && esperance < 0.5)
                {
                    esperance += 0.3;
                }
                if (bluffDecision > 0.5 && esperance > 0.5)
                {
                    esperance -= 0.3; bluffDesc = true;
                }
            }

            if (jeu.CurrentTour() != 1 && !bluffDesc)
            {
                double coucheDecision = _Alea.LoiBeta(4.3, 5.6 - esperance * 5);
                if (coucheDecision < 0.4)
                {
                    IAchoix = -1;
                }
            }

            if (IAchoix == 0 && jeu.CurrentTour() != 1)
            {
                double aleaDecision = PlayerPrefs.GetInt("Decision");
                double newEsperance = _Alea.LoiNormale(esperance, aleaDecision / 1000.0);
                if (newEsperance < 0)
                {
                    newEsperance = 0;
                }
                if (newEsperance > 1)
                {
                    newEsperance = 1;
                }
                //print("newEsperance" + newEsperance);
                double pari = _Alea.LoiGamma(newEsperance);
                if (pari > 1)
                {
                    pari = 1;
                }
                //print("pari" + pari);
                int misePotentiel = (int)Math.Floor((_currentMiseManche + _nbJeton) * pari / 5);
                //print("miseManche" + _currentMiseManche);
                //print("misePotentiel" + misePotentiel);
                if (jeu.CurrentRelance() + _currentMiseManche < misePotentiel)
                {
                    IAchoix = misePotentiel - _currentMiseManche;
                }
            }


            //print(esperance);
            //print("point" + _point);
            //int IAchoix = IA.Choisir(this);
            switch (IAchoix)
            {
            case -1:     // Se coucher
                this.Coucher();

                break;

            case 0:     // Checker / Suivre
                if (jeu.CurrentRelance() == 0)
                {
                    //print("check");
                    this.Check();
                }
                else
                {
                    //print("suivre");
                    this.Suivre();
                }
                break;

            default:     // Miser / Relancer
                this.Relancer(IAchoix);
                break;
            }
        }
    }