/** * This method will recursively generate all possible joint location outcomes for a list of possible outcomes for each agent * @param locOutcomes the list of possible location outcomes for each agent * @param i the index from which to generate possible outcomes in a depth-first manner * @param locArray an array holding the current assignments for a given depth * @param stackedProb the probability of this location set occurring * @param discovered the discovered combinations thus far */ protected void generateAllLocationSetsHelper(List<List<Location2Prob>> locOutcomes, int i, Location2 [] locArray, double stackedProb, List<LocationSetProb> discovered){ if(i == locOutcomes.size()){ //bundle them up List <Location2> locs = new ArrayList<GridGameStandardMechanics.Location2>(locArray.length); Collections.addAll(locs, locArray); LocationSetProb lsp = new LocationSetProb(locs, stackedProb); discovered.add(lsp); return ; } //otherwise we're in recursive step List<Location2Prob> individualOutcomes = locOutcomes.get(i); for(Location2Prob lp : individualOutcomes){ locArray[i] = lp.l; this.generateAllLocationSetsHelper(locOutcomes, i+1, locArray, stackedProb*lp.p, discovered); } }
outcomes.add(new LocationSetProb(new ArrayList<GridGameStandardMechanics.Location2>(desiredPositions), 1.)); return outcomes; LocationSetProb lsp = new LocationSetProb(finalPoses, p); allOutcomes.add(lsp);