Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IEnumerator NonRecursiveTileIterator(int i)
- {
- ulong possibilities = (ulong)Mathf.Pow(2, width*height);
- bool skip_this_iteration;
- while (true)
- {
- currently_checking_for_solutions = true;
- skip_this_iteration = false;
- if (possibilities % 1000000 == 0) yield return null;
- for(int x = 0; x < currentState.Length; x++)
- {
- currentState[x] = ((possibilities & (ulong)(1<<x)) != 0);
- if(lockedTiles[x] && currentState[x] != startingState[x])
- {
- skip_this_iteration = true;
- break;
- }
- }
- if(!skip_this_iteration)
- {
- if(isSolved())
- {
- SolutionList.Add(currentState.Clone());
- }
- }
- if(possibilities==0) yield break;
- possibilities--;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement