Example #1
0
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
Example #2
0
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
Example #3
0
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
Example #4
0
def test_ac3():
    testCrossword = generate.Crossword(structure, words)
    creator = generate.CrosswordCreator(testCrossword)
    creator.enforce_node_consistency()
    assert creator.ac3() == True
Example #5
0
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