Battleship

Solving Battleships with SAT

Comments are moderated. It may take a few minutes before your comment appears.
Markdown is supported in your comments.

def filter_givens(all_ships):
    "remove ships that conflict with board givens"
    knowns = set(xy for xy in table if table[xy] != '.')
    for ship1 in all_ships:
        points = exact_ship(*ship1)
        okay = not any(points[xy] != table[xy] for xy in knowns & set(points))
        if okay:
            yield ship1
Name:
Mail: (not shown)

Please type this: