public static Predicate <ASCase> byPos(ASPoint point) { return(delegate(ASCase o) { return o.Point == point; }); }
public bool inMap(ASPoint point) { return ((point.X >= 0) && (point.Y >= 0) && (point.X < _lignes) && (point.Y < _colonnes)); }
public static Predicate <ASCase> Proche(ASPoint point, int distance) { return(delegate(ASCase o) { int deltaX = Math.Abs(o.Point.X - point.X); int deltaY = Math.Abs(o.Point.Y - point.Y); return (deltaX + deltaY) < distance; }); }
public override bool Equals(object obj) { if (!(obj is ASPoint)) { return(false); } ASPoint pt = (ASPoint)obj; return(pt == this); }
public bool MovementFree(ASPoint point) { return(!_obstacles.Exists(ASCase.byPos(point))); }
public bool NearMovementFree(ASPoint point) { return(MovementFree(point) && NearFree(point)); }
public bool NearFree(ASPoint point) { return(!_obstacles.Exists(ASCase.Proche(point, 1))); }
public ASCase getCase(ASPoint p) { return(_map[p.X, p.Y]); }
public List <ASCase> getAdjCase(ASCase current, bool bdiagonales = false) { List <ASCase> list = new List <ASCase>(); ASPoint Point = new ASPoint(); // Haut Point.X = current.Point.X; Point.Y = current.Point.Y + 1; if (inMap(Point) && NearMovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 1; list.Add(Case); } // Droite Point.X = current.Point.X + 1; Point.Y = current.Point.Y; if (inMap(Point) && NearMovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 1; list.Add(Case); } // Gauche Point.X = current.Point.X - 1; Point.Y = current.Point.Y; if (inMap(Point) && NearMovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 1; list.Add(Case); } // Bas Point.X = current.Point.X; Point.Y = current.Point.Y - 1; if (inMap(Point) && NearMovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 1; list.Add(Case); } if (bdiagonales) { // Haut gauche Point.X = current.Point.X - 1; Point.Y = current.Point.Y + 1; if (inMap(Point) && MovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 2; list.Add(Case); } // Haut Droite Point.X = current.Point.X + 1; Point.Y = current.Point.Y + 1; if (inMap(Point) && MovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 2; list.Add(Case); } // Bas Gauche Point.X = current.Point.X - 1; Point.Y = current.Point.Y - 1; if (inMap(Point) && MovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 2; list.Add(Case); } // Bas Droite Point.X = current.Point.X + 1; Point.Y = current.Point.Y - 1; if (inMap(Point) && MovementFree(Point)) { ASCase Case = new ASCase(Point.Clone(), current); Case.CalculH(_end); Case.G = current.G + 2; list.Add(Case); } } return(list); }
static public int SquareDistanceTo(ASPoint pointA, ASPoint pointB) { return ((int)Math.Pow(pointA.X - pointB.X, 2) + (int)Math.Pow(pointA.Y - pointB.Y, 2)); }
public ASCase(ASPoint point, ASCase parent) { this.Point = point; this.Parent = parent; }
public ASCase(int X, int Y) { this.Point = new ASPoint(X, Y); }