public Map ReturnChangedMap(int i, ICellable cell) { Map Temp = CopyThis(); Temp.Cells[i] = cell; return(Temp); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } } }
public int ReturnQuantityOfCells(ICellable cell) { return(Cells.Where(t => t.State == cell.State).Count()); }
private int ReturnNumberOfDiagWins(int i, int lengthtowin, ICellable cell) { return(ReturnNumberOfLDiagWins(i, lengthtowin, cell) + ReturnNumberOfRDiagWins(i, lengthtowin, cell)); }
public Cell(ICellable o, Coordinate Offset, char Image = DefImageCell) { _o = o; _offset = Offset; _image = Image; }
public Predator(ICellable o, Coordinate Offset, char Image = DefImagePredators, int timeToReproduse = 6, int timeToFeed = DefTimeToFeed) : base(o, Offset, Image, timeToReproduse) { _timeToFeed = timeToFeed; }
public Human(ICellable sign, GameSession gs) { Sign = sign; Gs = gs; }
public Computer(ICellable sign, GameSession gs) { Sign = sign; Gs = gs; }
public Obstacle(ICellable o, Coordinate Offset, char Image = DefImageObstacles ) : base(o, Offset, Image) { }
public Prey(ICellable o, Coordinate Offset, char Image = DefImagePrey, int timeToReproduse = DefTimeToReproduse) : base(o, Offset, Image) { _timeToReproduse = timeToReproduse; }