Algorithm for Counting Identities
I've been thinking about writing a program to calculate and count duplicate positions - roughly speaking, those positions that are half way through an identity. What I have in mind will probably be a more time consuming program to write than I would prefer. So I wonder if I could ask Herbert Kociemba and/or mdlazreg to post a little something about the programs they have already written to find identities. It may well be that there is a much simpler approach to calculating duplicate positions than what I have in mind.
What I have in mind is an iterative deepening depth first search beginning at the Start position. If that's all I did, the search would simply count 12n maneuvers for each distance from n, and it would not extract any useful information about how many duplicate positions there are for each n. To solve these problems, I propose to store all the duplicate positions and not to store those positions that are not duplicate. This would be for the quarter turn metric. The program I have in mind would not be able to handle the face turn metric.
By storing the duplicate positions, the following should be possible:
- After making a move, determine the EndsWith value for the resulting position. EndsWith is an attribute of positions rather than of maneuvers. For example, the maneuver FF yields a position that has an EndsWith value of {F,F'} because FF=F'F'. By knowing the EndsWith value associated with the position that results from a maneuver, it is possible to prune a depth first search down to maneuvers that are the same length as the associated position. For example, maneuvers such as FF' and FFF would be pruned from the search.
- After making a move, determine whether the resulting position is a duplicate position or not. And if the position is duplicate, determine whether the current maneuver is the first maneuver for the position that is encountered in the depth first search. For example, suppose FF comes before F'F' in the search. The program I have in mind would be able to determine that FF is a duplicate position and that FF is the first maneuver in the depth first search that produces the position. The program would also be able to determine that F'F' is a duplicate position and that F'F' is not the first maneuver in the depth first search that produces the position. So the program would count FF and not count F'F'. Upon encountering duplicate positions, they would be counted and stored. Upon encountering non-duplicate positions, they would be counted but they would not be stored or otherwise processed.