コード例 #1
0
        public bool IsTsumi()
        {
            if (gamestate == GameState.over)
            {
                return(false);
            }
            List <Te> posste = PossTe();
            int       n      = posste.Count;

            if (n == 0)
            {
                return(false);
            }
            foreach (var te in posste)
            {
                Game game = Clone();
                te.Go(game);
                if (game.gamestate == GameState.over)
                {
                    return(false);
                }
                else
                {
                    bool lose = false;
                    foreach (var te2 in game.PossTe())
                    {
                        Game game2 = game.Clone();
                        te2.Go(game2);
                        if (game2.gamestate == GameState.over)
                        {
                            lose = true;
                        }
                    }
                    if (!lose)
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        public static int Check(Te te, Game game, int depth)
        {
            te.Go(game);
            if (game.gamestate == GameState.over)
            {
                return(big);
            }
            if (depth >= 1)
            {
                List <Koma> mochi = game.gamestate == GameState.turnB ? game.mochias : game.mochibs;
                int         res   = 0;
                foreach (var k in mochi)
                {
                    res += Point(k);
                }
                foreach (var k in game.onboards)
                {
                    if (k == null)
                    {
                        continue;
                    }
                    if (k.state == ((game.gamestate == GameState.turnB) ? KomaState.OnA : KomaState.OnB))
                    {
                        res += Point(k);
                    }
                }
                return(res);
            }

            int ans = big;

            var aitete = game.PossTe();

            if (depth > 0)
            {
                int c = 0; Te aitete0 = new Te();
                foreach (var te2 in aitete)
                {
                    int d = Check(te2, game.Clone(), big);
                    if (c < d)
                    {
                        c = d; aitete0 = te2;
                    }
                }
                aitete.Clear(); aitete.Add(aitete0);
            }

            foreach (var te2 in aitete)
            {
                int  res   = 0;
                Game game2 = game.Clone();
                te2.Go(game2);
                if (game2.gamestate == GameState.over)
                {
                    ans = 0; continue;
                }
                var jibunte = game2.PossTe();

                if (depth == 1)
                {
                    int c = 0; Te jibunte0 = new Te();
                    foreach (var te3 in jibunte)
                    {
                        int d = Check(te3, game2.Clone(), big);
                        if (c < d)
                        {
                            c = d; jibunte0 = te3;
                        }
                    }
                    jibunte.Clear(); jibunte.Add(jibunte0);
                }
                res = 0;
                foreach (var te3 in jibunte)
                {
                    int c = Check(te3, game2.Clone(), depth + 1);
                    if (res < c)
                    {
                        res = c;
                    }
                }
                ans = Math.Min(ans, res);
            }
            return(ans);
        }
コード例 #3
0
        public static int Check(Te te, Game game, int depth)
        {
            te.Go(game);
            if (game.gamestate == GameState.over)
            {
                return big;
            }
            if (depth >= 1)
            {
                List<Koma> mochi = game.gamestate == GameState.turnB ? game.mochias : game.mochibs;
                int res = 0;
                foreach (var k in mochi) res += Point(k);
                foreach (var k in game.onboards)
                {
                    if (k == null) continue;
                    if (k.state == ((game.gamestate == GameState.turnB) ? KomaState.OnA : KomaState.OnB))
                    {
                        res += Point(k);
                    }
                }
                return res;
            }

            int ans = big;

            var aitete = game.PossTe();

            if (depth > 0)
            {
                int c = 0; Te aitete0 = new Te();
                foreach (var te2 in aitete)
                {
                    int d = Check(te2, game.Clone(), big);
                    if (c < d) { c = d; aitete0 = te2; }
                }
                aitete.Clear(); aitete.Add(aitete0);
            }

            foreach (var te2 in aitete)
            {
                int res = 0;
                Game game2 = game.Clone();
                te2.Go(game2);
                if (game2.gamestate == GameState.over) { ans = 0; continue; }
                var jibunte = game2.PossTe();

                if (depth == 1)
                {
                    int c = 0; Te jibunte0 = new Te();
                    foreach (var te3 in jibunte)
                    {
                        int d = Check(te3, game2.Clone(), big);
                        if (c < d) { c = d; jibunte0 = te3; }
                    }
                    jibunte.Clear(); jibunte.Add(jibunte0);
                }
                res = 0;
                foreach (var te3 in jibunte)
                {
                    int c = Check(te3, game2.Clone(), depth + 1);
                    if (res < c) { res = c; }
                }
                ans = Math.Min(ans, res);
            }
            return ans;
        }