Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IEnumerator RecursiveTileIterator(int i)
- {
- currently_checking_for_solutions = true;
- numIterations++;
- if(numIterations % 10000 == 0)
- {
- yield return null;
- }
- if(i < (width*height-1))
- {
- if(!lockedTiles[i] && !disabledTiles[i])
- {
- currentState[i] = false;
- if(symbols[i] > 0 && symbols[i] <= 6) tiles[i].symbols[0].SetColor(Color.white);
- //Not part of the above if, just a scope to kill the IEnumerator when we leave it
- {
- IEnumerator count = RecursiveTileIterator(i+1);
- while (count.MoveNext()) if(numIterations % 10000 == 0) yield return null;
- }
- currentState[i] = true;
- if(symbols[i] > 0 && symbols[i] <= 6) tiles[i].symbols[0].SetColor(Color.black);
- //Not part of the above if, just a scope to kill the IEnumerator when we leave it
- {
- IEnumerator count = RecursiveTileIterator(i+1);
- while (count.MoveNext()) if(numIterations % 10000 == 0) yield return null;
- }
- }
- else
- {
- //just a scope to kill the IEnumerator when we leave it
- {
- IEnumerator count = RecursiveTileIterator(i+1);
- while (count.MoveNext()) if(numIterations % 10000 == 0) yield return null;
- RecursiveTileIterator(i+1);
- }
- }
- }
- else
- {
- if(!lockedTiles[i] && !disabledTiles[i])
- {
- currentState[i] = false;
- if(symbols[i] > 0 && symbols[i] <= 6) tiles[i].symbols[0].SetColor(Color.white);
- if(isSolved())
- {
- SolutionList.Add(currentState.Clone());
- }
- currentState[i] = true;
- if(symbols[i] > 0 && symbols[i] <= 6) tiles[i].symbols[0].SetColor(Color.black);
- if(isSolved())
- {
- SolutionList.Add(currentState.Clone());
- }
- }
- else
- {
- if(isSolved())
- {
- SolutionList.Add(currentState.Clone());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement