More or less finished up the algorithm. There's a problem where it keeps alternating between two tiles