コード例 #1
0
        /// <summary>
        /// centre de décision de l'IA simple
        /// </summary>
        /// <returns></returns>
        public StructCoo decide()
        {
            StructCoo   coo   = new StructCoo();
            List <Case> cases = this.morpion.Cases;

            foreach (Case c in cases)
            {
                if (c.CochePar == null)
                {
                    coo.x = c.X;
                    coo.y = c.Y;
                }
            }
            return(coo);
        }
コード例 #2
0
        /// <summary>
        /// cette méthode récupère les coordonnées de la case choisie par l'IA, puis ensuite
        /// recherche m'image associé à cette case et dessine un rond (car l'ia est le joueur2)
        /// </summary>
        private void tourIA()
        {
            StructCoo cooIA = this.morpion.choixIa();

            if (cooIA.x == 0 && cooIA.y == 0)
            {
                Image0.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 1 && cooIA.y == 0)
            {
                Image1.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 2 && cooIA.y == 0)
            {
                Image2.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 0 && cooIA.y == 1)
            {
                Image3.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 1 && cooIA.y == 1)
            {
                Image4.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 2 && cooIA.y == 1)
            {
                Image5.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 0 && cooIA.y == 2)
            {
                Image6.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 1 && cooIA.y == 2)
            {
                Image7.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            else if (cooIA.x == 2 && cooIA.y == 2)
            {
                Image8.Source = new BitmapImage(new Uri(@"/Assets/rond.jpg", UriKind.Relative));
            }
            //ensuite on génère l'historique
            genererHistorique(cooIA.x, cooIA.y);
        }
コード例 #3
0
        /// <summary>
        /// centre de décision de l'IA avancée
        /// </summary>
        /// <returns></returns>
        public StructCoo strongIaDecide()
        {
            StructCoo coo = new StructCoo();

            verifCasesCochesParJ1(); //on vérifi la position des croix du joueur 1

            verifCasesCochesParIA(); //on vérifi la position des ronds de l'IA

            if (this.ligne1 >= 2)
            {
                if (this.IAligne1 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 0 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.ligne2 >= 2)
            {
                if (this.IAligne2 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 0 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.ligne3 >= 2)
            {
                if (this.IAligne3 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 0 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.colonne1 >= 2)
            {
                if (this.IAcolonne1 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 0 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 0 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 0 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.colonne2 >= 2)
            {
                if (this.IAcolonne2 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 1 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.colonne3 >= 2)
            {
                if (this.IAcolonne3 == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 2 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.dia_HG_BD >= 2)
            {
                if (this.IAdia_HG_BD == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 0 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 2 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else if (this.dia_HD_BG >= 2)
            {
                if (this.IAdia_HD_BG == 0)
                {
                    foreach (Case c in this.morpion.Cases)
                    {
                        if (c.X == 2 && c.Y == 0)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 1 && c.Y == 1)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                        else if (c.X == 0 && c.Y == 2)
                        {
                            coo.x = c.X;
                            coo.y = c.Y;
                        }
                    }
                }
            }
            else
            {
                foreach (Case c in this.morpion.Cases)
                {
                    if (c.CochePar == null)
                    {
                        coo.x = c.X;
                        coo.y = c.Y;
                    }
                }
            }

            StructCoo   coo2  = new StructCoo();
            List <Case> cases = this.morpion.Cases;

            foreach (Case c in cases)
            {
                if (c.CochePar == null)
                {
                    coo2.x = c.X;
                    coo2.y = c.Y;
                }
            }

            foreach (Case c2 in this.morpion.Cases)
            {
                if (c2.CochePar != null)
                {
                    coo = coo2;
                }
            }

            return(coo);
        }