我的问题是,当我有一个约束时,我必须为行/列生成所有可能的组合。让我们说有一个非图形拼图,它的行大小为40.我有约束
B,11,G,5,B,9
我必须遵守约束条件:
其中字母代表颜色(即B =蓝色),以下是该块的长度。我有一个规则的课程。这些规则存储在ArrayList规则中。
public class Rule {
public int size;
public char color;
public Rule(int length, char color){
this.size = length;
this.color= color;
}
现在我想生成行/列的所有有效组合,以便我可以将它们添加到ArrayList rowCombinations
for (int i =0 ; i < rowSize ; i++){
rowCombinations.add(makeCombinations(some_input));
}
因此makeCombinations函数将返回我的自定义变量类CSPVariable
public class CSPVariable {
public ArrayList<char[]> storage;
public int position;
public boolean Row;
public CSPVariable(int index, boolean Row) {
this.position = index;
this.Row = Row;
this.storage = new ArrayList<>();
}
所以要回顾一下......根据规则,我想生成所有可能的字母组合,并将它存储到char数组存储int CSPVariable类。