Queue<StatePair> currentExplorationBoundary = new LinkedList<StatePair>();// FIFO queue
currentExplorationBoundary.add(pair);currentExplorationBoundary.offer(null);
while(!foundKTail)
{
StatePair currentPair = currentExplorationBoundary.remove();
if (currentPair == null)
{// we got to the end of a wave
if (currentExplorationBoundary.isEmpty())
break;// we are at the end of the last wave, stop looping.
// mark the end of a wave.
currentExplorationBoundary.offer(null);
}
else
{
Map<Label,CmpVertex> targetRed = coregraph.transitionMatrix.get(currentPair.getR()),
targetBlue = coregraph.transitionMatrix.get(currentPair.getQ());
for(Entry<Label,CmpVertex> redEntry:targetRed.entrySet())
{
CmpVertex nextBlueState = targetBlue.get(redEntry.getKey());
if (nextBlueState != null)
{// both states can make a transition
if (!AbstractLearnerGraph.checkCompatible(redEntry.getValue(),nextBlueState,coregraph.pairCompatibility))
return -1;// incompatible states
// if(RPNIUniversalLearner.state_outgoing.get(currentPair.getQ())==null || RPNIUniversalLearner.state_outgoing.get(currentPair.getQ()).get(redEntry.getKey())==null)
matchscore++;
// else if(RPNIUniversalLearner.state_outgoing.get(currentPair.getQ()).get(redEntry.getKey()) > 0.0)
// matchscore++;
StatePair nextStatePair = new StatePair(nextBlueState,redEntry.getValue());
currentExplorationBoundary.offer(nextStatePair);
}
// if the red can make a move, but the blue one cannot, ignore this case.
}
}