Beispiel #1
0
        /* public Coups minimax(int depth, Echiquier e, bool isMyTurn, Coups bestCoup)
         * {
         *
         *   if (depth == 0)
         *   {
         *       return
         *   }
         *
         * }*/

        static Coups findBestMove(Echiquier e)
        {
            List <Coups> lesCoups = e.playable();



            List <Coups> best      = new List <Coups>();
            int          BestValue = -900000;

            foreach (Coups c in lesCoups)
            {
                e.playMove(c);
                List <Coups> lesCoupsAdv = e.playableAdversary();
                Coups        bestAdv     = null;
                int          valueAdv    = -900000;
                foreach (Coups c2 in lesCoupsAdv)
                {
                    int valuetmp = c2.getValue();
                    if (valuetmp > valueAdv)
                    {
                        valueAdv = valuetmp;
                        bestAdv  = c2;
                    }
                }
                int value = c.getValue() - valueAdv;
                if (value == BestValue)
                {
                    best.Add(c);
                }
                if (value > BestValue)
                {
                    BestValue = value;
                    best      = new List <Coups>();
                    best.Add(c);
                }
                e.undo();
            }


            Random rnd = new Random();
            int    r   = rnd.Next(best.Count);

            return(best[r]);
        }
Beispiel #2
0
        //-----------------------------------METHODES

        //---------------------------------------------------------------------------
        //      Constructeur
        //---------------------------------------------------------------------------
        public IAechec()
        {
            echiquier = new Echiquier();
        }