コード例 #1
0
ファイル: Comb.cs プロジェクト: profMagija/MasterMindrw2
 public bool identTo(Comb b)
 {
     bool p = true;
     for (int i = 0; (i < 3) && p; i++)
         p = p && (this[i] == b[i]);
     return p;
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: profMagija/MasterMindrw2
 public Game(int p)
 {
     secret = new Comb(
         p % 6 + 1,
         (p / 6) % 6 + 1,
         (p / 36) % 6 + 1,
         (p / 216) % 6 + 1
         );
     start = DateTime.Now;
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: profMagija/MasterMindrw2
 public Game(int p)
 {
     secret = new Comb(
         p % 6 + 1,
         (p / 6) % 6 + 1,
         (p / 36) % 6 + 1,
         (p / 216) % 6 + 1
         );
     start = DateTime.Now;
 }
コード例 #4
0
ファイル: Comb.cs プロジェクト: profMagija/MasterMindrw2
        public bool identTo(Comb b)
        {
            bool p = true;

            for (int i = 0; (i < 3) && p; i++)
            {
                p = p && (this[i] == b[i]);
            }
            return(p);
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: profMagija/MasterMindrw2
 internal Guess Try(Comb p)
 {
     if (attempts < 6)
     {
         attempts++;
         bool cor = p.identTo(secret);
         solved = solved || cor;
         return secret.compare(p);
     }
     return new Guess(0, 0);
 }
コード例 #6
0
ファイル: Game.cs プロジェクト: profMagija/MasterMindrw2
 internal Guess Try(Comb p)
 {
     if (attempts < 6)
     {
         attempts++;
         bool cor = p.identTo(secret);
         solved = solved || cor;
         return(secret.compare(p));
     }
     return(new Guess(0, 0));
 }
コード例 #7
0
ファイル: Comb.cs プロジェクト: profMagija/MasterMindrw2
        public Guess compare(Comb b)
        {
            int t = 0, d = 0;
            int[] c1 = this.count(), c2 = b.count();

            for (int i = 1; i <= 6; i++)
                t += Math.Min(c1[i], c2[i]);

            for (int i = 0; i < 4; i++)
                d += (this[i] == b[i]) ? 1 : 0;

            return new Guess(d, t - d);
        }
コード例 #8
0
 public int[] Try(int[] c)
 {
     Comb com = new Comb(
         c[0],
         c[1],
         c[2],
         c[3]);
     if (g != null)
     {
         Guess asdf = g.Try(com);
         int[] arr = asdf.toArray();
         return arr;
     }
     return null;
 }
コード例 #9
0
        public int[] Try(int[] c)
        {
            Comb com = new Comb(
                c[0],
                c[1],
                c[2],
                c[3]);

            if (g != null)
            {
                Guess asdf = g.Try(com);
                int[] arr  = asdf.toArray();
                return(arr);
            }
            return(null);
        }
コード例 #10
0
ファイル: Comb.cs プロジェクト: profMagija/MasterMindrw2
        public Guess compare(Comb b)
        {
            int t = 0, d = 0;

            int[] c1 = this.count(), c2 = b.count();

            for (int i = 1; i <= 6; i++)
            {
                t += Math.Min(c1[i], c2[i]);
            }

            for (int i = 0; i < 4; i++)
            {
                d += (this[i] == b[i]) ? 1 : 0;
            }

            return(new Guess(d, t - d));
        }