Exemplo n.º 1
0
 // Recursive walk to add positions
 void AddPositions(string basename, Rect baserect, List <int> basecoords, int level, BoardDef board)
 {
     for (int i = 0; i < _names[level].Count; i++)
     {
         var name   = basename + _names[level][i];
         var rect   = baserect.Offset(_coords[level].Times(i));
         var coords = new List <int>(basecoords);
         coords.Add(i);
         //var coords_ = coords.AsEnumerable().Concat(new int[] { i }).ToList();
         if (level == _names.Count - 1)
         {
             board.SetPosition(board.GetPosition(name), rect, coords);
         }
         else
         {
             AddPositions(name, rect, coords, level + 1, board);
         }
     }
 }
Exemplo n.º 2
0
 void AddLinks(int dirindex, string fromname, string toname, int level, BoardDef board)
 {
     for (int i = 0; i < _names[level].Count; i++)
     {
         var j = i + _diroffs[dirindex][level];
         if (j >= 0 && j < _names[level].Count)
         {
             var fname = fromname + _names[level][i];
             var tname = toname + _names[level][j];
             if (level == _names.Count - 1)
             {
                 board.AddLink(_directions[dirindex], board.GetPosition(fname), board.GetPosition(tname));
             }
             else
             {
                 AddLinks(dirindex, fname, tname, level + 1, board);
             }
         }
     }
 }