Пример #1
0
        public Map ReturnChangedMap(int i, ICellable cell)
        {
            Map Temp = CopyThis();

            Temp.Cells[i] = cell;
            return(Temp);
        }
Пример #2
0
 private int ReturnNumberOfRDiagWins(int i, int lengthtowin, ICellable cell)
 {
     if (Cells[i].State != cell.State)
     {
         return(0);
     }
     if (i % Width - (lengthtowin - 1) < 0 || Height - i / Width < lengthtowin)
     {
         return(0);
     }
     for (int j = i; j < i + lengthtowin * Width - lengthtowin; j += Width - 1)
     {
         if (Cells[j].State != cell.State && Cells[j].State != State.Toe)
         {
             return(0);
         }
     }
     for (int j = i; j < i + lengthtowin * Width - lengthtowin; j += Width - 1)
     {
         if (Cells[j].State == State.Toe)
         {
             return(1);
         }
     }
     return(999);
 }
Пример #3
0
 private int ReturnNumberOfVertWins(int i, int lengthtowin, ICellable cell)
 {
     if (Cells[i].State != cell.State)
     {
         return(0);
     }
     if (Height - i / Width < lengthtowin)
     {
         return(0);
     }
     for (int j = i; j < i + lengthtowin * Width; j += Width)
     {
         if (Cells[j].State != cell.State && Cells[j].State != State.Toe)
         {
             return(0);
         }
     }
     for (int j = i; j < i + lengthtowin * Width; j += Width)
     {
         if (Cells[j].State == State.Toe)
         {
             return(1);
         }
     }
     return(999);
 }
Пример #4
0
        private int ReturnMaximalChildWeight()
        {
            ICellable pl = Player.ReturnSign();
            ICellable en = Enemy.ReturnSign();

            if (Childs.Count == 0)
            {
                return(Map.ReturnWeight(Lengthtowin, pl, en));
            }

            if (Childs[0].Childs.Count == 0)
            {
                return(EndChildMaximalWeight());
            }

            List <int> childsWeights = new List <int>();

            foreach (Node ch in Childs)
            {
                childsWeights.Add(ch.ReturnMinimalChildWeight());
            }

            var maxWeight = childsWeights.Max();

            return(maxWeight);
        }
Пример #5
0
 private int ReturnNumberOfHorizWins(int i, int lengthtowin, ICellable cell)
 {
     if (Cells[i].State != cell.State)
     {
         return(0);
     }
     if (Width - i % Width < lengthtowin)
     {
         return(0);
     }
     for (int j = i; j < i + lengthtowin; j++)
     {
         if (Cells[j].State != cell.State && Cells[j].State != State.Toe)
         {
             return(0);
         }
     }
     for (int j = i; j < i + lengthtowin; j++)
     {
         if (Cells[j].State == State.Toe)
         {
             return(1);
         }
     }
     return(999);
 }
Пример #6
0
        private int QuantityOfDiagWins(ICellable cell, int lengthtowin)
        {
            int counter = 0;

            for (int i = 0; i < Cells.Length; i++)
            {
                counter += ReturnNumberOfDiagWins(i, lengthtowin, cell);
            }
            return(counter);
        }
Пример #7
0
        public int ReturnWeight(int lengthtowin, ICellable cell, ICellable enemyCell)
        {
            int cellWins = QuantityOfHorWins(cell, lengthtowin)
                           + QuantityOfVerWins(cell, lengthtowin)
                           + QuantityOfDiagWins(cell, lengthtowin);
            int enemyWins = QuantityOfHorWins(enemyCell, lengthtowin)
                            + QuantityOfVerWins(enemyCell, lengthtowin)
                            + QuantityOfDiagWins(enemyCell, lengthtowin);

            return(cellWins - enemyWins);
        }
Пример #8
0
        private List <int> EndChild()
        {
            List <int> childsWeights = new List <int>();
            ICellable  pl            = Player.ReturnSign();
            ICellable  en            = Enemy.ReturnSign();

            foreach (Node ch in Childs)
            {
                childsWeights.Add(ch.Map.ReturnWeight(Lengthtowin, pl, en));
            }

            return(childsWeights);
        }
Пример #9
0
        private void Move(int depth, IPlayer Author)
        {
            ICellable pl = Player.ReturnSign();
            ICellable en = Enemy.ReturnSign();

            if (depth == 0 || Map.ReturnWeight(Lengthtowin, pl, en) > 100 || Map.ReturnWeight(Lengthtowin, pl, en) < -100)
            {
                return;
            }

            int       len        = Map.Cells.Length;
            ICellable playerSign = Author.ReturnSign();

            for (int i = 0; i < len; i++)
            {
                if (Map.Cells[i].State == State.Toe)
                {
                    Map  childMap = Map.ReturnChangedMap(i, playerSign);
                    Node newChild = new Node(childMap, Player, Enemy, this, Lengthtowin);
                    Childs.Add(newChild);
                }
            }
        }
Пример #10
0
 public int ReturnQuantityOfCells(ICellable cell)
 {
     return(Cells.Where(t => t.State == cell.State).Count());
 }
Пример #11
0
 private int ReturnNumberOfDiagWins(int i, int lengthtowin, ICellable cell)
 {
     return(ReturnNumberOfLDiagWins(i, lengthtowin, cell) + ReturnNumberOfRDiagWins(i, lengthtowin, cell));
 }
Пример #12
0
 public Cell(ICellable o, Coordinate Offset, char Image = DefImageCell)
 {
     _o      = o;
     _offset = Offset;
     _image  = Image;
 }
Пример #13
0
 public Predator(ICellable o, Coordinate Offset, char Image = DefImagePredators, int timeToReproduse = 6, int timeToFeed = DefTimeToFeed)
     : base(o, Offset, Image, timeToReproduse)
 {
     _timeToFeed = timeToFeed;
 }
Пример #14
0
 public Human(ICellable sign, GameSession gs)
 {
     Sign = sign;
     Gs   = gs;
 }
Пример #15
0
 public Computer(ICellable sign, GameSession gs)
 {
     Sign = sign;
     Gs   = gs;
 }
Пример #16
0
 public Obstacle(ICellable o, Coordinate Offset, char Image = DefImageObstacles
                 )
     : base(o, Offset, Image)
 {
 }
Пример #17
0
 public Prey(ICellable o, Coordinate Offset, char Image = DefImagePrey, int timeToReproduse = DefTimeToReproduse)
     : base(o, Offset, Image)
 {
     _timeToReproduse = timeToReproduse;
 }