Esempio n. 1
0
        /// <summary>
        /// English version
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public virtual float GameChance(Positions p)
        {
            Positions q = p.Clone();

            while (q.NbShots1 > 0 && q.NbShots0 > 0)
            {
                q.Perform(gen.Next(0, q.NbShots1), gen.Next(0, q.NbShots0));
            }
            return(q.Eval);
        }
Esempio n. 2
0
        public Nodes BestChild()
        {
            if (childNodes[indexBestChild1, indexBestChild0] != null)
            {
                return(childNodes[indexBestChild1, indexBestChild0]);
            }
            Positions q = p.Clone();

            q.Perform(indexBestChild1, indexBestChild0);
            childNodes[indexBestChild1, indexBestChild0] = new Nodes(this, q);
            return(childNodes[indexBestChild1, indexBestChild0]);
        }
Esempio n. 3
0
        public void Start(bool display = true)
        {
            _mctssPlayer.NewPart();
            _humanPlayer.NewPart();
            do
            {
                if (display)
                {
                    pCurrent.Poster(); Console.WriteLine();
                }

                Task <int> t1 = Task.Run(() => _mctssPlayer.Play(pCurrent.Clone(), true));
                Task <int> t0 = Task.Run(() => _humanPlayer.Play(pCurrent.Clone(), false));
                t1.Wait(); t0.Wait();
                pCurrent.Perform(t1.Result, t0.Result);

                //int rep1 = j1.Jouer(pCourante.Clone(), true);
                //int rep0 = j0.Jouer(pCourante.Clone(), false);
                //pCourante.EffectuerCoup(rep1, rep0);

                _mctssPlayer.Des();
                _humanPlayer.Des();
            } while (pCurrent.NbShots1 > 0 && pCurrent.NbShots0 > 0);
            r = pCurrent.Eval;
            if (display)
            {
                pCurrent.Poster();
                int re = 0;
                if (r > 0)
                {
                    re = 1;
                }
                if (r < 0)
                {
                    re = -1;
                }
                switch (re)
                {
                case 1: Console.WriteLine("MCTS Player {0} won {1}.", _mctssPlayer, r); break;

                case -1: Console.WriteLine("Human Player {0} won {1}.", _humanPlayer, -r); break;

                case 0: Console.WriteLine("Drawn game."); break;

                default: Console.WriteLine("Default."); break;
                }
            }
        }