public void addSpiral() { try { for (int i = 0; i < directions.Count; i++) { do { currentNum++; coords += directions[i]; base[coords] = currentNum; } while (base[coords + directions[i + 1]] != 0); } base[coords] = currentNum; } catch (IndexOutOfRangeException ex) { Console.WriteLine(ex.Message); //Console.WriteLine(ToString()); } currentradius++; bottomy++; topy--; leftx--; rightx++; //currentNum++; }
public SpiralGrid(int spiralRadius) : base(spiralRadius * 2 + 1) { currentNum = 1; center = new intpair(spiralRadius, spiralRadius); coords = new intpair(center.x, center.y); base[coords] = currentNum; coords.x++; currentNum++; base[coords] = currentNum; topy = bottomy = center.y; leftx = rightx = center.x; }
public List <intpair> getDiagonals() { List <intpair> r = new List <intpair>(); for (int i = 0; i < Size; i++) { intpair t = new intpair(); t.x = base[i, i]; if (t.y != 1) { t.y = base[i, Size - 1 - i]; } r.Add(t); } return(r); }
public T this[intpair coords] { get { return(this[coords.x, coords.y]); } set { this[coords.x, coords.y] = value; } }