Пример #1
0
 public Block(Position b1, Position b2)
 {
     this.b1 = b1;
     this.b2 = b2;
     if ((b1.X > b2.X) || (b1.Y > b2.Y))
     {
         throw new InvalidArgumentException("b2 is 'smaller' then b1");
     }
 }
Пример #2
0
 public Terrain(String name, bool[,] map, Position start, Position goal)
 {
     this.name = name;
     this.width = map.GetLength(1);
     this.height = map.GetLength(0);
     this.map = map;
     this.start = start;
     this.goal = goal;
     this.startBlock = new Block(this.start, this.start);
     this.block = this.startBlock;
 }
Пример #3
0
 public bool check(Position position)
 {
     return check(position.x, position.y);
 }
Пример #4
0
 private static Terrain parseTerrain(String fileName, int width, List<String> lines)
 {
     bool[,] map = new bool[lines.Count, width];
     Position start = null;
     Position goal = null;
     int i = 0;
     foreach (String line in lines)
     {
         int j = 0;
         foreach (char c in line)
         {
             map[i,j] = Terrain.isField(c);
             if (c == Terrain.START)
             {
                 start = new Position(i, j);
             }
             else if (c == Terrain.GOAL)
             {
                 goal = new Position(i, j);
             }
             j++;
         }
         i++;
     }
     if ((start != null) && (goal != null))
     {
         return new Terrain(Path.GetFileNameWithoutExtension(fileName), map, start, goal);
     }
     else
     {
         throw new InvalidMapFileException(fileName, "There is no start and/or goal position in file.");
     }
 }