Finished implementation of winning algorithm.