algorithm - Generating all possible combinations with given constraint for Nonogram puzzle (Java) -
my problem have generate possible combinations rows/columns when have constraint. lets have nonogram puzzle , row has size of 40. , have constraints
b,11,g,5,b,9
i have follow constraints:
- there @ least 1 empty box between 2 blocks of boxes filled same color
- there not have empty box between boxes filled different color
- the order of numbers in legend corresponds order of blocks of boxes (from left right, top bottom)
where letters stands color (i.e. b = blue) , following length of block. have class rules. , rules store in arraylist rules.
public class rule { public int size; public char color; public rule(int length, char color){ this.size = length; this.color= color; }
now want generate valid combinations rows/cols can add them arraylist rowcombinations
for (int =0 ; < rowsize ; i++){ rowcombinations.add(makecombinations(some_input)); }
and makecombinations function return mine custom variable class 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<>(); }
so recap... given rules want generate possible combinations of letters , store char array storage int cspvariable class.
Comments
Post a Comment