Use distance<file>() function in endgame.cpp