Example #1
0
        public bool Who(TCell Pos, out TCheck who)
        {
            who = null;

            if (Pos == null)
            {
                return(false);
            }

            for (int k = 0; k < CW.Count; k++)
            {
                if (CW[k].Pos.Eq(Pos))
                {
                    who = CW[k];
                    return(true);
                }
            }

            for (int k = 0; k < CB.Count; k++)
            {
                if (CB[k].Pos.Eq(Pos))
                {
                    who = CB[k];
                    return(true);
                }
            }

            return(true);
        }
Example #2
0
 public TNode(TNode Parent, TCell Pos, TCheck Killed, int dir)
 {
     this.Parent = Parent;
     this.Pos    = Pos;
     this.Killed = Killed;
     this.dir    = dir;
 }
Example #3
0
        public void AddRuns(TCheck Check, ref TRuns Runs)
        {
            for (int i = 0; i < Lists.Count; i++)
            {
                TNode Node = (TNode)Lists[i];

                TRun Run = new TRun(Check, Node.Pos);

                ArrayList arr = Up(Node);

                for (int j = 0; j < arr.Count; j++)
                {
                    Run.Killed.Add(((TNode)arr[j]).Killed);
                }

                Runs.Add(Run);

                TCell[] Addition = Node.Pos.NearsDama(Node.dir, Pole);

                for (int k = 1; k < Addition.Count(); k++)
                {
                    TRun ARun = new TRun(Check, Addition[k]);

                    for (int j = 0; j < Run.Killed.Count; j++)
                    {
                        ARun.Killed.Add(Run.Killed[j]);
                    }

                    Runs.Add(ARun);
                }
            }
        }
Example #4
0
        public bool Run(TPole Pole, TRun R)
        {
            TRuns RunsKill = GetRunsKill(Pole);

            if (RunsKill.Count > 0)
            {
                TRun Run;
                if (R == null)
                {
                    Run = RunsKill.GetR();
                }
                else
                {
                    Run = R;
                }

                SetPos(Run.PosTo);

                for (int i = 0; i < Run.Killed.Count; i++)
                {
                    TCheck K = (TCheck)Run.Killed[i];
                    g.Children.Remove(K.O[0]);
                    g.Children.Remove(K.O[1]);
                    if (K.C == WB.W)
                    {
                        Pole.CW.Remove(K);
                    }
                    else
                    {
                        Pole.CB.Remove(K);
                    }
                }

                return(true);
            }

            TRuns Runs = GetRuns(Pole);

            if (Runs.Count > 0)
            {
                TRun Run;
                if (R == null)
                {
                    Run = Runs.GetR();
                }
                else
                {
                    Run = R;
                }

                SetPos(Run.PosTo);
                return(true);
            }

            return(false);
        }
 public TRun(TCheck Check, TCell PosTo)
 {
     this.Check = Check;
     this.PosTo = PosTo;
     Killed     = new ArrayList();
 }
        private void cmClick(object sender, MouseButtonEventArgs e)
        {
            Point XY = e.GetPosition(gPole);


            TCell Z = Pole.GetCell(XY);

            if (CheckFor == null)
            {
                Pole.Who(Z, out CheckFor);

                if (CheckFor == null)
                {
                    return;
                }

                if (CheckFor.C != WB.W)
                {
                    CheckFor = null;
                    return;
                }
            }
            else
            {
                ArrayList arr = new ArrayList();

                TRun Run = new TRun(CheckFor, Z);

                TRuns Runs;
                TRuns RunsKill;

                for (int n = 0; n < Pole.CW.Count; n++)
                {
                    RunsKill = Pole.CW[n].GetRunsKill(Pole);

                    for (int k = 0; k < RunsKill.Count; k++)
                    {
                        arr.Add(RunsKill[k]);
                    }
                }
                if (arr.Count > 0)
                {
                    for (int k = 0; k < arr.Count; k++)
                    {
                        TRun R = (TRun)arr[k];

                        if ((Run.Check.Pos.Eq(R.Check.Pos)) && (Run.PosTo.Eq(R.PosTo)))
                        {
                            R.Check.Run(Pole, R);

                            IsW = !IsW;
                            cmRun(null, null);
                            CheckFor = null;
                            return;
                        }
                    }

                    CheckFor = null;
                    return;
                }
                else
                {
                    arr.Clear();

                    for (int n = 0; n < Pole.CW.Count; n++)
                    {
                        Runs = Pole.CW[n].GetRuns(Pole);

                        for (int k = 0; k < Runs.Count; k++)
                        {
                            arr.Add(Runs[k]);
                        }
                    }

                    if (arr.Count > 0)
                    {
                        for (int k = 0; k < arr.Count; k++)
                        {
                            TRun R = (TRun)arr[k];

                            if ((Run.Check.Pos.Eq(R.Check.Pos)) && (Run.PosTo.Eq(R.PosTo)))
                            {
                                R.Check.Run(Pole, R);

                                IsW = !IsW;
                                cmRun(null, null);
                                CheckFor = null;
                                return;
                            }
                        }

                        CheckFor = null;
                        return;
                    }
                    else
                    {
                        IsGame = false;

                        WB Cx;

                        if (IsW)
                        {
                            Cx = WB.W;
                        }
                        else
                        {
                            Cx = WB.B;
                        }

                        Pole.GameOver(Cx);

                        Pole = new TPole(gPole);
                    }
                }
            }
        }
Example #7
0
        public void Move(int n, TCell Pos)
        {
            TCheck Check = this[n];

            Check.SetPos(Pos);
        }
Example #8
0
        public void Remove(TCheck Check)
        {
            Check.Delete();

            arr.Remove(Check);
        }