コード例 #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
ファイル: Cell.cs プロジェクト: AlexanderChykun/GameLife
 public Cell(ICellable o, Coordinate Offset, char Image = DefImageCell)
 {
     _o      = o;
     _offset = Offset;
     _image  = Image;
 }
コード例 #13
0
ファイル: Predator.cs プロジェクト: AlexanderChykun/GameLife
 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
ファイル: Obstacle.cs プロジェクト: AlexanderChykun/GameLife
 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;
 }