Added threading support (defaults to using std::thread::hardware_concurrency() for the max thread count). To turn off threading, pass "-nothreading" to the command-line arguments. Changed the A* search heuristic; lower brick counts are now more important relative to other values. The lego definition file no longer needs both an entry for the length-wise piece and the width-wise piece, as non-square shaped are rotated within code. The given brick definition list is now sorted on peg-count over price ratio (so bigger plates are favored during initial testing). While stepping through the edge of possible pixel candidates, we now move the given lego brick to each four corner, to not favor any direction or shape; this helps when starting filling on certain images.

Here are results from hand-tweaking the heuristic function:

return float( m_cost ) / float( m_pegCount ) * float( m_brickList.size() )

> Total bricks: 449
> Total cost: $46.25

return float( m_cost ) / float( m_pegCount )

> Total bricks: 449
> Total cost: $46.25

return float( m_cost ) / float( m_pegCount ) / float( m_brickList.size() )
> Total bricks: 450
> Total cost: $46.35

return float( m_cost ) - float( m_pegCount ) * 10

> Total bricks: 418
> Total cost: $46.20

return float( m_cost ) - float( m_pegCount ) * 100

> Total bricks: 414
> Total cost: $46.0

return -float( m_pegCount )

> Total bricks: 413
> Total cost: $45.85

return - ( float( m_pegCount ) / float( m_brickList.size() ) ) * 100.0f - float( m_cost )

> Total bricks: 413
> Total cost: $45.80

> Total bricks: 410
> Total cost: $45.75

Bug fixes:

> Total bricks: 412
> Total cost: $45.95

> Total bricks: 410
> Total cost: $45.75

Here are some very casual testing with varying thread counts (2013 Macbook Pro 13-inch, i7 Core Duo, using the Samus.png image):

With std:: thread count: 11 seconds
With 4 threads:  9 seconds
With 2 threads:  12 seconds
With 8 threads:  8 seconds
With 1 threads:  15 seconds
With no thread:  13 seconds