Recognizer Driver
static void Main(string[] args) {
int totalCalls = 0;
int totalGridsEvaluated = 0;
for (int left = 0; left<WIDTH; ++left)
for (int right = left; right<WIDTH; ++right)
for (int bottom = 0; bottom<HEIGHT; ++bottom)
for (int top = bottom; top<HEIGHT; ++top) {
Grid grid = new Grid(left, right, bottom, top);
Shape shape = Recognize(grid);
totalCalls += grid.TotalCalls;
++totalGridsEvaluated;
bool gridIsSquare = (right - left == top - bottom);
if (shape == Shape.Square) {
if (!gridIsSquare)
throw new Exception("Square was incorrectly recognized.");
}
else {
if (gridIsSquare)
throw new Exception("Rectangle was incorrectly recognized.");
}
}
Console.WriteLine("Looked at " + totalGridsEvaluated + " grids.");
Console.WriteLine("Called CountBlocksSet " + totalCalls + " times.");
Console.WriteLine("Average calls per grid " + (double)totalCalls / (double)totalGridsEvaluated);
}
- Anonymous
May 20, 2005
I mentioned in an earlier post that I was moving to the C# team. Well, I’ve moved now and I’ve been spending...