Q1. python
(a) If V is list of queen positions on an 8x8 chess board, write a program to determine how many pairs of attacking queens there are. A list of queen positions is a list or string of integers between 0 and 7, e.g., 31046715, which means column 0 has a queen on row 3 and column 1 has a queen on row 1. (Any solution must have exactly 1 queen in each column, so this is an acceptable simplification).
(b) Write a program for a beam search, that takes the beam size k as input, and that uses the heuristic developed in (a) to solve 8-queen problems. Make sure you have a termination condition, either successful (cost=0) or not (local cost minimum).
(c) Generate a large number (100) of 8 queen problems (using random numbers), and solve
them using your beam search for k=1, k=10 and k=50. Generate a graph that shows the
number of solutions found for each value of k (average several runs for each k) and explain
those results
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 1 | 2 | 3 | 4 | 5 |