private List <CellPostion> ConsturctPath(CellPostion state, Dictionary <CellPostion, CellPostion?> meta) { var result = new List <CellPostion>(); var end = state; while (true) { var row = meta[state]; if (row != null) { state = (CellPostion)row; result.Add((CellPostion)row); } else { break; } } result.Reverse(); if (result.Count > 0) { result.Remove(result[0]); } result.Add(end); return(result); }
public List <CellPostion> GetNeighbors(CellPostion cellPostion, string matchPattern) { var result = new HashSet <CellPostion>(); int col = cellPostion.Y; int row = cellPostion.X; for (int y = col - 1; y <= (col + 1); y += 1) { for (int x = row - 1; x <= (row + 1); x += 1) { if ( !((y == col) && (x == row)) ) { if (VaildCellPostion(x, y)) { var cell = Cells[y][x]; if (!cell.CollectiveTags.Any(i => Regex.IsMatch(i, matchPattern))) { result.Add(new CellPostion(y, x)); } } } } } return(result.ToList()); }
public Postion2D Transform(CellPostion cellPostion) { double left = cellPostion.X * CELL_SIZE; double top = cellPostion.Y * CELL_SIZE; return(new Postion2D(left, top)); }
public bool Equals(CellPostion other) { return(this.X == other.X && this.Y == other.Y); }
public Node(CellPostion cellPostion) { Visted = false; Expanded = false; CellPostion = cellPostion; }
public int GetHeuristic(CellPostion cell, CellPostion target) { int result = Math.Abs(cell.X - target.X) + Math.Abs(cell.Y - target.Y); return(result); }
public double DistanceBetween(CellPostion a, CellPostion b) { return(Math.Sqrt(Math.Pow(b.X - a.X, 2) + Math.Pow(b.Y - a.Y, 2))); }