final version.

fixed compare method to ensure proper comparsion for priority
calculation. 

Cached priority for Board class to reduce overhead computation.

format code.
removed comments