Assignment1 AI
Assignment1 AI
Spring 2025
Assignment #1
Initial State:
All N queens are placed in the top row (one per column). For example, when N = 4, the initial
state is represented as:
Q Q Q Q
Moves (Actions):
At each step, a queen can be moved one cell in any of the four cardinal directions: up (U), down
(D), left (L), or right (R). However, there are two restrictions:
Goal State:
A state is considered a goal if:
1. Every row on the board contains exactly one queen.
2. No two queens conflict with each other. Two queens are said to conflict if they are in the
same row, same column, or on the same diagonal (in any of the eight directions).
Heuristic Function:
For the heuristic-based search, you will also implement a heuristic function. This function
computes the total number of conflicts by counting conflicts for every queen (i.e., if queen A
conflicts with queen B, the conflict is counted twice). For example, after taking the move (0,
'D') in the initial state for N = 4, the conflict count should be eight (value = 8).
Objectives
By the end of this assignment, you should be able to:
Note: For N>=7, you may need to use any efficient approach to solve the
problem. In these cases, a simple heuristic may not work or take too long. For
example, from this webpage (https://en.wikipedia.org/wiki/Eight_queens_puzzle)
you can get some ideas of how the state space grows and how to tackle it. For
this, you can try different options; for example, change how the actions are taken,
how a heuristic is computed, how a goal state is defined, how collisions are
counted, etc. However, prioritize solving the original problem. If necessary,
consider making minimal changes to the game to solve for higher values of N.
o Mention any modifications used to efficiently find the solutions for higher values
of N.