I have stared at this assignment for far too long now and I simply don't understand what I am supposed to do exactly. We are given a 3x3 chess board and have to produce some propositonal clauses to this problem. This is what information we have been given:
Write a Python program that generates the input for a SAT solver to solve the 3-Towers problem:
a) Write a function pair2int(r,c) which maps (1,1), (1,2), ..., (3,3) to 1 to 9 using the formula 3*(r-1)+c.
b) Write nested for-loops that go through all positions on the board from (1,1) to (3,3) and produces clauses that represent attacks.
c) Write a for-loop that produces clauses that specify that all 3 rows contain a tower
We are expected to write clauses in Conjunctive normal form as far as I understand. Could also be done directly in DIMACS
So I have done the a part, but I simply don't understand how I am supposed to express attacks or even what an attack constitutes, exactly.
This is the part of the program that I have done (a):
def pair2int(r):
return [3*(p[0]-1)+p[1] for p in r]
print(pair2int([(1,1),(1,2),(1,3),(2,1),(2,2),(2,3),(3,1),(3,2),(3,3)]))
which simply returns a list of positions 1-9 on a 3x3 board:
[1,2,3,4,5,6,7,8,9]
I don't understand what I am supposed to do with this. Can somebody push me in the right direction?