Example #1
0
 public void counterMinMaxAlfaBeta2()
 {
     ITavola tavola = new Tavola();
     AbsAIPlayer p1 = new MinMaxAlphaBeta(2);
     IPlayer p2 = new HumanPlayer();
     IGioco gioco = new Gioco(tavola);
     Bant bantumi = new Bant(gioco, p1, p2);
     int i = p1.Elaborazione(gioco);
     Assert.AreEqual(2209, p1.OperationCount);
 }
Example #2
0
File: Gioco.cs Project: nickxbs/IA
        public IGioco Clone()
        {
            ITavola tavola = (ITavola)this.Tavola.Clone();
            Gioco newGame = new Gioco(tavola);
            newGame.Vincitore = this.Vincitore;
            newGame._parita = this.Parita;
            newGame._prossimoTurno = this.ProssimoTurno;

            return newGame;
        }
Example #3
0
 public void counterMinMaxAlfaBeta1HVal()
 {
     ITavola tavola = new Tavola();
     AbsAIPlayer p1 = new MinMaxAlphaBeta(1, new HeuristicFunctionValue(Lato.A));
     IPlayer p2 = new HumanPlayer();
     IGioco gioco = new Gioco(tavola);
     Bant bantumi = new Bant(gioco, p1, p2);
     int i = p1.Elaborazione(gioco);
     Assert.AreEqual(97, p1.OperationCount);
 }
Example #4
0
File: Gioco.cs Project: nickxbs/IA
        public IGioco Clone()
        {
            ITavola tavola  = (ITavola)this.Tavola.Clone();
            Gioco   newGame = new Gioco(tavola);

            newGame.Vincitore      = this.Vincitore;
            newGame._parita        = this.Parita;
            newGame._prossimoTurno = this.ProssimoTurno;

            return(newGame);
        }
Example #5
0
        static void Main(string[] args)
        {
            int vittorieA = 0;
            int vittorieB = 0;
            int parita = 0;
            //while (true)
            //{
                ITavola tavola = new Tavola();
                IPlayer p1 = new MinMaxAlphaBeta(4,new HeuristicFunctionValue(Lato.A));
                IPlayer p2 =  new MinMaxAlphaBetaWithOpen(4,new HeuristicFunctionValue(Lato.B));
                //IPlayer p2 = new MinMaxPlayer(Convert.ToInt32(args[0]));
                IGioco gioco = new Gioco(tavola);
                Bant bantumi = new Bant(gioco, p1, p2);
                //gioco.Start();
                Render(gioco.Tavola);
                Console.WriteLine("Muove Player" + gioco.ProssimoTurno);
                Thread.Sleep(sleepTime);
                while (gioco.Vincitore == null && !gioco.Parita)
                {
                    IPlayer player = bantumi.GetPlayer(gioco.ProssimoTurno);
                    if (player is HumanPlayer)
                    {
                        if (gioco.ProssimoTurno == Lato.A)
                        {
                            Console.WriteLine("Player" + Lato.A + " scegli una buca fra 0 e 5");
                        }
                        else
                        {
                            Console.WriteLine("Player" + Lato.B + " scegli una buca fra 7 e 12");
                        }
                        gioco.Muovi(ReadValue(gioco));
                    }
                    else
                    {
                        if (player is IAIPlayer)
                        {
                            IAIPlayer aiPlayer = player as IAIPlayer;
                            int i = aiPlayer.Elaborazione(gioco);

                            Console.WriteLine("MUOVE" + i);

                            gioco.Muovi(i);

                        }
                    }

                    Render(gioco.Tavola);
                    Thread.Sleep(sleepTime);
                }
                if (gioco.Parita)
                {
                    Console.WriteLine("Parità");

                    parita++;
                }
                else
                {

                    if (gioco.Vincitore == Lato.A.ToString())
                    {
                        Console.WriteLine("Ha vinto Player" + gioco.Vincitore);
                        Console.ReadLine();
                        //vittorieA++;
                    }
                    if (gioco.Vincitore == Lato.B.ToString())
                    {
                        Console.WriteLine("Ha vinto Player" + gioco.Vincitore);
                        Console.ReadLine();
                        //vittorieB++;
                    }
                }

            //}
        }
Example #6
0
 public void counterMinMaxAlfaBeta2HAsc()
 {
     ITavola tavola = new Tavola();
     AbsAIPlayer p1 = new MinMaxAlphaBeta(2, new HeuristicFunctionAscendent());
     IPlayer p2 = new HumanPlayer();
     IGioco gioco = new Gioco(tavola);
     Bant bantumi = new Bant(gioco, p1, p2);
     int i = p1.Elaborazione(gioco);
     Assert.AreEqual(3057, p1.OperationCount);
 }
Example #7
0
 public void counterMinMaxNew4()
 {
     ITavola tavola = new Tavola();
     AbsAIPlayer p1 = new MinMax(4);
     IPlayer p2 = new HumanPlayer();
     IGioco gioco = new Gioco(tavola);
     Bant bantumi = new Bant(gioco, p1, p2);
     int i = p1.Elaborazione(gioco);
     Assert.AreEqual(99569593, p1.OperationCount);
 }