game engine improved, taking care of loops in backtracking tree.