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_tallies(all_ships):
    "remove ships that conflict with tallies"
    for ship1 in all_ships:
        # prefix, x1, y1, size, d
        _,_,_,size,d = ship1
        points = just_ship(*ship1)
        okay = True
        for x,y in points:
            if across[x] == '?':
                continue
            if down[y] == '?':
                continue
            if across[x] == 0:
                okay = False
            if down[y] == 0:
                okay = False
            if d == 'E' and down[y] < size:
                okay = False
            if d == 'S' and across[x] < size:
                okay = False
        if okay:
            yield ship1
Name:
Mail: (not shown)

Please type this: