22 std::vector<int> config(mm);
23 for (
unsigned int x = 0; x < config.size(); x++)
35 std::vector<int> config(mm);
36 for (
unsigned int x = 0; x < config.size(); x++)
47 if (!
data[stateID].expanded)
57 if (!
data[stateID].expanded)
67 return (state == goal);
72 return data[gs].config;
78 for (
unsigned int x = 0; x < configuration.size(); x++)
80 if (configuration[x] == 0)
86 return GetState(configuration, zeroLoc);
91 static std::vector<int> config(configuration.size());
92 config.resize(configuration.size());
94 assert(zeroLoc != -1);
95 for (
unsigned int x = 0; x < config.size(); x++)
96 config[x] = configuration[(zeroLoc+x)%configuration.size()];
117 for (
int x = 0; x <
length; x++)
126 data[stateID].expanded =
true;
133 int tmp = arrangement[index];
134 int otherSide = (index+radius-1)%arrangement.size();
135 arrangement[index] = arrangement[otherSide];
136 arrangement[otherSide] = tmp;
138 index = (index+1)%arrangement.size();
146 return data[state].hashKey;
151 if ( s == 0)
return 0;
153 std::vector<int> cfg =
data[s].config;
154 std::vector<int> dualCfg = cfg;
155 for (
unsigned int x=0;x<cfg.size();x++) {
176 int MAX_TILES = config_size;
177 int num_tiles = config_size;
178 int8_t tiles[ MAX_TILES ],
loc[ MAX_TILES ];
183 loc[ tiles[ i ] = config[ i ] ] = i;
184 }
while( ++i != num_tiles );
186 rank = tiles[ i = 0 ];
188 while( i != num_tiles - 1 )
190 tiles[
loc[ end ] ] = tiles[ i ];
191 loc[ tiles[ i ] ] =
loc[ end ];
194 rank = rank * ( num_tiles - i ) + tiles[ i ];
208 std::vector<int> pdb_pos(config.size());
209 for (
unsigned int x = 0; x < config.size(); x++)
210 pdb_pos[config[x]] = x;
212 int MAX_TILES = config.size();
214 int num_tiles = config.size();
216 int8_t tiles[ MAX_TILES ],
loc[ MAX_TILES ];
218 memset(
loc, pdb_size, num_tiles );
222 loc[ tiles[ i ] = pdb_pos[ i ] ] = i;
223 }
while( ++i != pdb_size );
225 rank = tiles[ i = 0 ];
227 while( i != pdb_size - 1 ) {
228 tiles[
loc[ end ] ] = tiles[ i ];
229 loc[ tiles[ i ] ] =
loc[ end ];
232 rank = rank * ( num_tiles - i ) + tiles[ i ];
245 for ( i = puzzleSize - pdb_size; i < puzzleSize; i++ ) {
257 :ts(0), pdb(pdbStates)
260 sprintf(filename,
"TS_%d_%d_%d.db", psize, spin,
pdb);
261 FILE *f = fopen(filename,
"r");
264 printf(
"Can't load PDB!\n");
280 if ((s1 != 0) && (s2 != 0))
282 printf(
"Error -- one state must be canonical goal state\n");