Example #1
0
        public override int Play(Positions p, bool asj1)
        {
            PositionP4S p4 = (PositionP4S)p;
            // currentNode = new Nodes(null, p);
            int k;

            do
            {
                Console.WriteLine("Choose the column for human player {0} :", asj1 ? "red" : "blue");

                string s = Console.ReadLine();
                k = -10;
                if (s.Length == 1)
                {
                    k = s[0] - 'a' + 1;
                }
            }while (k < 1 || k > PositionP4S.nbCo || p4.cases[0][-1 + k * PositionP4S.nbLi] || p4.cases[1][-1 + k * PositionP4S.nbLi] || p4.cases[2][-1 + k * PositionP4S.nbLi]);
            k--;
            int rep = 0;

            for (int i = 1; i <= k; i++) //b * nbLi + a
            {
                if (!p4.cases[0][-1 + i * PositionP4S.nbLi] && !p4.cases[1][-1 + i * PositionP4S.nbLi] && !p4.cases[2][-1 + i * PositionP4S.nbLi])
                {
                    rep++;
                }
            }

            return(rep);
        }
Example #2
0
 public PositionP4S(PositionP4S p)
 {
     cases         = new BitArray[3];
     this.cases[0] = (BitArray)p.cases[0].Clone();
     this.cases[1] = (BitArray)p.cases[1].Clone();
     this.cases[2] = (BitArray)p.cases[2].Clone();
     Eval          = p.Eval;
     NbShots1      = p.NbShots1;
     NbShots0      = p.NbShots0;
 }
Example #3
0
        public override bool Equals(object obj)
        {
            PositionP4S q = (PositionP4S)obj;

            for (int i = 0; i < nbLi; i++)
            {
                for (int j = 0; j < nbCo; j++)
                {
                    if (cases[0][i + j * nbLi] != q.cases[0][i + j * nbLi])
                    {
                        return(false);
                    }
                    if (cases[1][i + j * nbLi] != q.cases[1][i + j * nbLi])
                    {
                        return(false);
                    }
                    if (cases[2][i + j * nbLi] != q.cases[1][i + j * nbLi])
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }