def test_backtrack(): testCrossword = generate.Crossword(structure, words) creator = generate.CrosswordCreator(testCrossword) creator.enforce_node_consistency() creator.ac3() result = creator.backtrack(dict()) assert result == solution1 or result == solution2
def test_revise(): testCrossword = generate.Crossword(structure, words) creator = generate.CrosswordCreator(testCrossword) creator.enforce_node_consistency() x = crossword.Variable(2, 1, 'across', 12) y = crossword.Variable(1, 12, 'down', 7) y2 = crossword.Variable(2, 1, 'down', 5) assert creator.revise(x, y) == False assert creator.revise(x, y2) == True
def test_assignment_complete(): assignment1 = {2: "string1", 3: "string2", 2394: "String 1"} assignment2 = {2: "string1", 3: "string2"} variables1 = {2: "other data", 3: "other data", 2394: "other data"} testCrossword = generate.Crossword(structure, words) creator = generate.CrosswordCreator(testCrossword) creator.enforce_node_consistency() assert creator.assignment_complete(assignment=assignment1, variables=variables1) == True assert creator.assignment_complete(assignment=assignment2, variables=variables1) == False
def test_ac3(): testCrossword = generate.Crossword(structure, words) creator = generate.CrosswordCreator(testCrossword) creator.enforce_node_consistency() assert creator.ac3() == True
def test_enforce_node_consistency(): testCrossword = generate.Crossword(structure, words) creator = generate.CrosswordCreator(testCrossword) creator.enforce_node_consistency() assert creator.domains == enforce_node_consistency_Results