Ejemplo n.º 1
0
        void AddRunKill(TCell StartPos, int dir, TNode Parent)
        {
            TCell  Near;
            TCheck Who;
            TCheck W2;

            if (StartPos == null)
            {
                Near = Pos.Near(dir);
            }
            else
            {
                Near = StartPos.Near(dir);
            }


            if (Pole.Who(Near, out Who))
            {
                if (Who == null)
                {
                }
                else
                {
                    if (Who.C != C)
                    {
                        Near = Who.Pos.Near(dir);

                        if (Pole.Who(Near, out W2))
                        {
                            if (W2 == null)
                            {
                                TNode Cur = new TNode(Parent, Near, Who, dir);

                                if (Tree == null)
                                {
                                    Tree = new TTree(Cur, Pole);
                                }
                                Tree.Count++;

                                int Count = Tree.Count;

                                for (int i = 1; i <= 4; i++)
                                {
                                    if (((dir == 1) && (i == 4)) || ((dir == 2) && (i == 3)) ||
                                        ((dir == 3) && (i == 2)) || ((dir == 4) && (i == 1)))
                                    {
                                        continue;
                                    }

                                    AddRunKill(Near, i, Cur);
                                }

                                if (Count == Tree.Count)
                                {
                                    Tree.Lists.Add(Cur);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public TRuns GetRunsKill(TPole Pole)
        {
            this.Pole = Pole;

            TRuns Res = new TRuns();

            if (Dama)
            {
                Tree = null;
                AddRunKillDama(null, 1, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }


                AddRunKillDama(null, 2, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }

                AddRunKillDama(null, 3, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }

                AddRunKillDama(null, 4, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }
            }
            else
            {
                Tree = null;
                AddRunKill(null, 1, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }


                AddRunKill(null, 2, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }

                AddRunKill(null, 3, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }

                AddRunKill(null, 4, null);
                if (Tree != null)
                {
                    Tree.AddRuns(this, ref Res);
                    Tree = null;
                }
            }

            return(Res);
        }
Ejemplo n.º 3
0
        void AddRunKillDama(TCell StartPos, int dir, TNode Parent)
        {
            ArrayList arr = new ArrayList();

            TCell Near;

            if (StartPos == null)
            {
                Near = Pos.NearDama(dir, Pole);
            }
            else
            {
                Near = StartPos.NearDama(dir, Pole);
            }

            TCheck Who;

            Pole.Who(Near, out Who);

            if (Who == null)
            {
                return;
            }

            if (Who.C == C)
            {
                return;
            }

            Near = Near.Near(dir);

            TCheck W2;

            if (Pole.Who(Near, out W2))
            {
                if (W2 == null)
                {
                    TNode Cur = new TNode(Parent, Near, Who, dir);

                    if (Tree == null)
                    {
                        Tree = new TTree(Cur, Pole);
                    }
                    Tree.Count++;

                    int Count = Tree.Count;

                    TCell[] Nears;

                    for (int i = 1; i <= 4; i++)
                    {
                        if (((dir == 1) && (i == 4)) || ((dir == 2) && (i == 3)) ||
                            ((dir == 3) && (i == 2)) || ((dir == 4) && (i == 1)))
                        {
                            continue;
                        }

                        Nears = Near.NearsDama(dir, Pole);

                        for (int k = 0; k < Nears.Count(); k++)
                        {
                            AddRunKillDama(Nears[k], i, Cur);
                        }
                    }

                    if (Count == Tree.Count)
                    {
                        Tree.Lists.Add(Cur);
                    }
                }
            }
        }