public static int Point(Koma k)
        {
            int res = 0, poss = 0;

            res += 5;
            Random r = new Random();

            if (k.canbeH && !k.isNari)
            {
                res += r.Next(3, 7); poss++;
            }
            if (k.canbeH && k.isNari)
            {
                res += r.Next(12, 18); poss++;
            }
            if (k.canbeK)
            {
                res += r.Next(6, 14); poss++;
            }
            if (k.canbeZ)
            {
                res += r.Next(6, 14); poss++;
            }
            if (k.canbeL)
            {
                res += r.Next(3, 7); poss++;
            }
            if (poss - 2 > 0)
            {
                res /= poss - 2;
            }
            return(res);
        }
        public Koma Clone(Game game)
        {
            Koma k = (Koma)MemberwiseClone();

            k.game = game;
            return(k);
        }
 public Game()
 {
     onboards = new Koma[3, 4];
     motoas   = new Koma[4]; motobs = new Koma[4]; komas = new Koma[8];
     mochias  = new List <Koma>(); mochibs = new List <Koma>();
 }
        public bool Preexamine(Koma[] ks)
        {
            bool update = true; int cnt = 0;

            while (update)
            {
                update = false;
                cnt++;
                if (cnt > 1000)
                {
                    throw new Exception("Infinite Examine");
                }

                bool[,] poss = new bool[4, 4];
                for (int i = 0; i < 4; i++) for (int g = 0; g < 4; g++) poss[i, g] = false;

                for (int a = 0; a < 4; a++)
                {
                    if (!ks[0].GetCanBe(a)) continue;
                    for (int b = 0; b < 4; b++)
                    {
                        if (!ks[1].GetCanBe(b) || b == a) continue;
                        for (int c = 0; c < 4; c++)
                        {
                            if (!ks[2].GetCanBe(c) || c == a || c == b) continue;
                            for (int d = 0; d < 4; d++)
                            {
                                if (!ks[3].GetCanBe(d) || d == a || d == b || d == c) continue;
                                poss[0, a] = true; poss[1, b] = true; poss[2, c] = true; poss[3, d] = true;
                            }
                        }
                    }
                }

                for (int i = 0; i < 4; i++)
                {
                    for (int g = 0; g < 4; g++)
                    {
                        if (!poss[i, g] && ks[i].GetCanBe(g))
                        {
                            ks[i].SetCanBe(g, false);
                            update = true;
                        }
                    }
                }

                for (int i = 0; i < 4; i++)
                {
                    int n = 0, g0 = 0;
                    for (int g = 0; g < 4; g++) if (ks[i].GetCanBe(g)) { n++; g0 = g; }
                    if (n == 0)
                    {
                        return false;
                    }
                    if (n == 1 && !ks[i].only)
                    {
                        ks[i].only = true;
                        for (int j = 0; j < 4; j++) if (i != j) ks[j].SetCanBe(g0, false);
                        update = true;
                    }
                }
            }
            return true;
        }
 public static int Point(Koma k)
 {
     int res = 0, poss = 0;
     res += 5;
     Random r = new Random();
     if (k.canbeH && !k.isNari) { res += r.Next(3, 7); poss++; }
     if (k.canbeH && k.isNari) { res += r.Next(12, 18); poss++; }
     if (k.canbeK) { res += r.Next(6, 14); poss++; }
     if (k.canbeZ) { res += r.Next(6, 14); poss++; }
     if (k.canbeL) { res += r.Next(3, 7); poss++; }
     if (poss - 2 > 0) res /= poss - 2;
     return res;
 }
 public Game()
 {
     onboards = new Koma[3, 4];
     motoas = new Koma[4]; motobs = new Koma[4]; komas = new Koma[8];
     mochias = new List<Koma>(); mochibs = new List<Koma>();
 }