Basic algorithm with move precalculation