Beispiel #1
0
            public List <Place> PathVerFirst(Place from, Place to)
            {
                List <Place> path = new List <Place> {
                    from
                };
                Place current = from;
                int   row     = current.Row();

                while (row != to.Row())
                {
                    int   newRow = (row < to.Row()) ? row + 1 : row - 1;
                    Place next   = device.PlaceAt(newRow, current.Column());
                    path.Add(next);
                    row     = newRow;
                    current = next;
                }
                int col = from.Column();

                while (col != to.Column())
                {
                    int   newCol = (col < to.Column()) ? col + 1 : col - 1;
                    Place next   = device.PlaceAt(current.Row(), newCol);
                    path.Add(next);
                    col     = newCol;
                    current = next;
                }
                return(path);
            }
Beispiel #2
0
 public bool CanStepTo(Place from, Place to, int clearance)
 {
     for (int i = to.Row() - clearance; i < to.Row() + clearance; i++)
     {
         for (int j = to.Column() - clearance; j < to.Column() + clearance; j++)
         {
             Place[,] places = KDeviceHandler.device.places;
             if (i >= 0 && i < places.GetLength(0) && j >= 0 && j < places.GetLength(1))
             {
                 Place place = places[i, j];
                 if (place != from && place != null && IsOccupied(place))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Beispiel #3
0
 public Direction StepDirection(Place from, Place to, Style style)
 {
     if (from.Column() + 1 == to.Column() && from.Row() == to.Row())
     {
         return(Direction.Rht);
     }
     else if (from.Column() - 1 == to.Column() && from.Row() == to.Row())
     {
         return(Direction.Lft);
     }
     else if (from.Column() == to.Column() && from.Row() + 1 == to.Row())
     {
         return(Direction.Bot);
     }
     else if (from.Column() == to.Column() && from.Row() - 1 == to.Row())
     {
         return(Direction.Top);
     }
     else
     {
         throw new Error("ERROR: StepDirection");
     }
 }
Beispiel #4
0
 public void CheckIsOccupied(Place place)
 {
     if (!IsOccupied(place))
     {
         throw new Error("No sample found on device at row " + place.Row().ToString() + ", column " + place.Column().ToString());
     }
 }