private bool CanMoveTo(Position pos) { return pos.X < Width && pos.Y < Height && pos.X >= 0 && pos.Y >= 0; }
public int this[Position p] { get { return this[p.X, p.Y]; } set { this[p.X, p.Y] = value; } }
public bool MoveBy(Position moveBy) { var current = this.CurrentPosition; var newPos = current + moveBy; if (!CanMoveTo(newPos)) return false; this.MoveCount++; var source = this[current]; var dest = this[newPos]; this[current] = dest; this[newPos] = source; this.CurrentPosition = newPos; return true; }