+}
+
+/**
+ * Gets the closest Piece of a specified colour to a point
+ * @param x The x coordinate of the point
+ * @param y The y coordinate of the point
+ * @param colour The colour that the piece must match (may be Piece::BOTH to match either colour)
+ * @returns Piece* pointing to the closest piece of a matching colour, NULL if no piece found
+ */
+Piece * Board::GetClosest(int x, int y, const Piece::Colour & colour) const
+{
+ if (x < 0 || y < 0 || x >= width || y >= height)
+ return NULL;
+
+ for (int dist = 0; dist < max<int>(width, height); ++dist)
+ {
+
+ for (int yy = y-dist; yy <= y+dist; ++yy)
+ {
+ Piece * get = Get(x+dist, y);
+ if ((get != NULL) && (get->colour == colour || colour == Piece::BOTH))
+ return get;
+ }
+ for (int yy = y-dist; yy <= y+dist; ++yy)
+ {
+ Piece * get = Get(x-dist, y);
+ if ((get != NULL) && (get->colour == colour || colour == Piece::BOTH))
+ return get;
+ }
+ for (int xx = x-dist; xx <= x+dist; ++xx)
+ {
+ Piece * get = Get(xx, y+dist);
+ if ((get != NULL) && (get->colour == colour || colour == Piece::BOTH))
+ return get;
+ }
+ for (int xx = x-dist; xx <= y+dist; ++xx)
+ {
+ Piece * get = Get(xx, y-dist);
+ if ((get != NULL) && (get->colour == colour || colour == Piece::BOTH))
+ return get;
+ }
+
+ }
+
+ return NULL;
+
+
+
+