0% found this document useful (0 votes)
60 views20 pages

Term Project Report CIS 667

This document is a term project report for an AI class on developing a Red-Green-Blank puzzle solver using state space search algorithms. The project involves creating a solver agent that finds solutions to puzzles by moving a blank cell around a grid. The solver is designed with a Node class to represent puzzle states, driver code to set up problems and display solutions, and implementations of search algorithms like BFS, DFS, and A* to solve puzzles. The challenges of developing the solver include limiting run time for unsolvable puzzles, comparing algorithm performance across problem sets, and handling invalid user input.

Uploaded by

Khushboo Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views20 pages

Term Project Report CIS 667

This document is a term project report for an AI class on developing a Red-Green-Blank puzzle solver using state space search algorithms. The project involves creating a solver agent that finds solutions to puzzles by moving a blank cell around a grid. The solver is designed with a Node class to represent puzzle states, driver code to set up problems and display solutions, and implementations of search algorithms like BFS, DFS, and A* to solve puzzles. The challenges of developing the solver include limiting run time for unsolvable puzzles, comparing algorithm performance across problem sets, and handling invalid user input.

Uploaded by

Khushboo Gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

RBG Puzzle Solver

Term Project Report

CIS 667

Introduction to Artificial Intelligence

Professor : Garrett Katz

Submitted by:
Khushboo Gupta

Submitted On: 3rd December 2018


Khushboo Gupta CIS -667 Term Project Report

1. Introduction

1.1 Purpose
The purpose of the project is to create a Red-Green-Blank Puzzle Solver using State
Space Search algorithms and compare the performance of each algorithm based on
generated results given variety of inputs.

1.2 PEAS Description


This software acts a single agent bot which finds the solution to the puzzle based on a
valid set of actions and given percepts. There are 4 actions which include - Up, Down,
Left, Right. The precepts for this system is the Blank cell and its immediate neighbours.
The PEAS for this system is as below -
Performance - The number of steps taken to reach the goal grid, time taken to find the
solution, nodes generated and nodes explored to reach the goal
Environment - A n*n grid with a pattern of one Blank cell and rest as Red and Green
cells.
Actuators​ - Displaying of results to user using screen and solution steps to text file.
Sensors - Supporting code that takes user input in form of options to use a specific
algorithm, initial grid and goal grid.

1.3 Problem Description


The problem consists of a variant of n-puzzle, where instead of numbers, we have a n*n
grid of Red-Blank-Green cells. The grid only has one Blank cell and rest cells consist of
Red and Green cells. The Blank cell is the only cell allowed to move around one step
at a time by exchanging its position with it’s max neighbour i.e. only up, down, left and
right actions are allowed. So the puzzle is setup by accepting an initial grid
configuration and goal grid configuration from the user and the output is generated
using the selected algorithm. The output consists of a text file consisting of the steps
Blank should take to reach the goal state, along with other facts like time to solve,
nodes count to reach the goal grid, which later are used to determine the performance
of all the algorithms implemented. Python 3.x is used to develop the solution for the
described problem.

1.4 Challenges
While developing the solution to the above problem, following factors can be
challenging and needs to be be dealt with -
● There might not be a solution, so there must be a limit on running time of the solver.
● Comparison factors are needed to be clearly incorporated.
● Multiple problem sets are needed to be designed to check the performance of each
algorithm. Need to take care for the cases where problem grid may not reach the
goal.
● As input for puzzle and grids is being asked from the user, proper handling of the
cases is needed where the user input are wrong or invalid.

2
Khushboo Gupta CIS -667 Term Project Report

2. Implementation

2.1 Design of the Puzzle Solver


The design of this RBG puzzle solver is basically divided in 4 parts - Node Class,
Driver, Algorithms and Simulation. The part containing algorithms is described in the next
section.
1. Node Class - It basically is a data structure to hold the details associated with any
grid configuration at a time. It initialises a node based on input board. There are
functions to manipulate the properties associated with the node. Those properties
include node id, node parent, node operator(the valid operator need to reach the
current board configuration), node cost, node heuristic value, node board. The cost
and heuristic values are only being used in the informed search algorithms.
2. Driver - The driver part contains functions setting up the problem, presentation
support functions and oracle functions for the puzzle solver. setinitialboard(filename)
takes filename as input from user and setups the root node for the problem tree.
setgoalboard(filename) also takes file name for a goal grid from the user and sets
up goal board for comparison.
printboard(board) just prints the board configuration to the screen. The function
setoperators() initiallizes a list with the set of operators(Up, down, left, right).
Function testgoal(board,goal) returns True if the given board and goal is equal.
Solution(node, filename) prints the solutions steps for a node to the given filename.
def Solution(node, filename):
If node has no parent or node id is 1:
"Node is same as goal"
Else:
Opr = []
current = node
while(current.parent is not None):
O = current.operator
Opr = O + Opr
Current = current.parent
Write Opr to filename
lookBlank(board) function checks for the location of the Blank cell on the grid and
return the same.
def lookBlank(board):
Loc = []
row, col = 0
For i in boardsize:
col = i%boardlength
If board[i] == B:

3
Khushboo Gupta CIS -667 Term Project Report

Loc.add(row,col)
Break
If (i+1)%boardlength == 0:
Increment row by 1
return loc
Function validmoves(board, operator) returns True if the operator is valid move for
the Blank and False otherwise.
def validmoves(board, operator):
Loc = lookBlank(board)
If operator == Up
return True if loc[0] is not 0, else False
If operator == Down
return True if loc[0] is not boardlength-1, else False
If operator == Left
return True if loc[1] is not 0, else False
If operator == Up
return True if loc[1] is not boardlength-1​, else False
Function updateboard(board, operator) updates the board to next configuration if
the operation is valid. The function just checks if the operator is Up, Down, Left or
Right and based on the operator, it uses a temporary list as an intermediate to
exchange the position of Blank on the board. Then the updated board is returned.
def updateboard(board, oper):
childboard = board
loc = lookBlank(board)
l = boardlength
if oper == "Up":
t = childboard[int((loc[0]*l)+loc[1])]
childboard[int((loc[0]*l)+loc[1])] =
board[int((loc[0]*l)+(loc[1]-l))]
childboard[int((loc[0]*l)+(loc[1]-l))] = t

Else if oper == "Down":


t = childboard[int((loc[0]*l)+loc[1])]
childboard[int((loc[0]*l)+loc[1])] =
board[int((loc[0]*l)+(loc[1]+l))]
childboard[int((loc[0]*l)+(loc[1]+l))] = t

Else if oper == "Left":


t = childboard[int((loc[0]*l)+loc[1])]
childboard[int((loc[0]*l)+loc[1])] =
board[int((loc[0]*l)+(loc[1]-1))]

4
Khushboo Gupta CIS -667 Term Project Report

childboard[int((loc[0]*l)+(loc[1]-1))] = t

else:
t = childboard[int((loc[0]*l)+loc[1])]
childboard[int((loc[0]*l)+loc[1])] =
board[int((loc[0]*l)+(loc[1]+1))]
childboard[int((loc[0]*l)+(loc[1]+1))] = t

return childboard

3. ​Simulation - This sections just acts as front end to run the various algorithms based
on given user inputs as the problem number(1 to 5), input problem file and input goal
file. 1 corresponds to Breadth First Search, 2 corresponds to Depth First Search, 3
corresponds to Iterative Deepening Search, 4 corresponds to Greedy Best First Search
and 5 corresponds to A* Search.

2.2 Algorithms used

1. Uninformed State Search Algorithms ​- The uninformed search algorithms don't use
any domain specific knowledge before generating the tree for searching. In this
case, these approaches don't have any knowledge about the goal grid.
- Breadth First Search - Breadth First Search or BFS searches breadth wise
of left to right in the problem space. It involves a FIFO(First in First Out)
queue to maintain the nodes to be explored, while looking for the potential
candidate for goal. The nodes are generated from the root of the search
tree, and then one level of the tree is explored at a time until the goal state is
found.
This algorithm generates a node whenever the moves for the Blank cell is
validated, and the current node is promoted as parent of the new node
generated, with a check to test if the goal state is found. The pseudocode for
this approach is as below -
bfs_solver(root, goal, filename):
nodesexplored, nodesgenerated = 0
Operators = setOperators()
current is root
Add root to the Queue
If current is goal:
Write solution to filename
Return True
Else while True
If Queue is empty:

5
Khushboo Gupta CIS -667 Term Project Report

Return False
Current = pop first node from Queue
Add current to explored nodes
Increment nodesexplored by 1
For n in operators:
if operator n is valid == True:
board = updateboard(current.getboard(),operator[n])
Child = Node(board)
Child.parent = current
Child.operator = operator[n]
Increment nodesgenerated by 1
If child is not in explored:
If child is goal:
Write solution to filename
Print solution board
Print nodesexplored, nodesgenerated
Return True
Add Child to the Queue

- Depth First Search -​ Depth First Search or DFS, in contrast to BFS,


searches deeper into the problem space. It uses a stack (Last in First Out) to
keep track of which nodes to explore, while looking out for the goal node.
The nodes are generated from the root of the tree and from there the
successor of the deepest node in generated. So it searches through the
whole branch of the tree.
Similar to the BFS approach,generates a node whenever the moves for the
Blank cell is validated, and the current node is promoted as parent of the
new node generated, with a check to test if the goal state is found. The
pseudocode for this approach is as follow -
dfs_solver(root, goal, filename):
nodesexplored, nodesgenerated = 0
Operators = setOperators()
current is root
Add root to the Stack
If current is goal:
Write solution to filename
Return True
Else while True
If Stack is empty:
Return False
Current = popped top node from Stack

6
Khushboo Gupta CIS -667 Term Project Report

Add current to explored nodes


Increment nodesexplored by 1
For n in operators:
if operator n is valid == True:
board = updateboard(current.getboard(),operator[n])
Child = Node(board)
Child.parent = current
Child.operator = operator[n]
Increment nodesgenerated by 1
If child is not in explored:
If child is goal:
Write solution to filename
Print solution board
Print nodesexplored, nodesgenerated
Return True
Add Child to the Stack

- Iterative Deepening Search - Iterative Deepening Search or IDS searches


the problem tree by implementing DFS in BFS fashion. It utilises the space
efficiency of DFS and speed of BFS. The top level nodes in the tree are
visited multiple times as IDS starts searching from root node in every
iteration, going one level deeper. But as most nodes are at the bottom of the
problem tree, it turns out not very expensive.
In the implementation, the nodes generated and explored are initialized
globally to keep track of all the nodes generated and explored throughout
the iteration. Recursive IDS is used to implement the search based on the
depth and main driver function calls the Recursive IDS function iteratively to
look for the goal grid.Instead of infinite, the max depth is taken to be 100
here. The pseudocode is as follow -
nodesgenerated, nodesexplored = 0
def R_depthlsearch(node, depth, goal):
Operators = setOperators()
If depth is 0:
return node
Increment nodesexplored by 1
If node is goal:
return node
Else:
For n in operators:
if operator n is valid == True:
board = updateboard(current.getboard(),operator[n])

7
Khushboo Gupta CIS -667 Term Project Report

Child = Node(board)
Child.parent = current
Child.operator = operator[n]
Increment nodesgenerated by 1
result = R_depthlsearch(child, depth-1,goal)
If result is goal:
return result
return node

def ids_solver(node, goal, filename):


For i in range 100:
result = R_depthlsearch(node, i, goal)
print depth i
If result is goal:
Write solution to filename
Print result board
Print nodesgenerated and nodesexplored
return True
return False

2. Informed State Search Algorithms - The informed state search algorithms utilize an
evaluation function, which estimates cost to the goal and expands any node based
on this evaluation function. In this domain, two algorithms namely Greedy Best First
Search and A* Search are used.

- Greedy Best First Search - Greedy Best First is a special case of the Best
First Search algorithm which uses a function to estimate the node closest to
the goal node.
In this instance, the heuristic function is based on the how close similar the
cells on the grid of a node is to the goal node. The lower the heuristic value,
the higher priority for the node to be expanded. The pseudocode is given
below -
def greedyH(board, goal):
Hval = 0
For i in boardsize:
If board[i] is not “B”:
If board[i] is not goal[i]:
Increment Hval by 1
return Hval

8
Khushboo Gupta CIS -667 Term Project Report

def gbfs_solver(node, goal, filename):


nodesexplored, nodesgenerated = 0
Operator = setOperators()
current = node
current.setheuristic(greedyH(node.board,goal)
Put current in PriorityQueue based on heuristic
If current is goal:
Write solution to filename
Print solution
return True
Else:
while(True):
If PriorityQueue is empty:
Return False
Current = pop top node from PriorityQueue
Add current to explored
Increment nodesexplored by 1
If current is in explored and is goal:
Write solution to filename
Print solution
Print nodesexplored, nodesgenerated
return True
For n in operators:
if operator n is valid == True:
board = updateboard(current.getboard(),operator[n])
Child = Node(board)
Child.parent = current
Child.operator = operator[n]
Child.setheuristic(greedyH(board, goal))
Increment nodesgenerated by 1
If child is not in explored:
Put child in PriorityQueue

- A* Search -​ The A* algorithm is the combination of best first search and with
cost of the node to efficiently compute optimal solutions. The cost associated
with a node is f(n) = g(n) + h(n), where g(n) is the cost of the path from the
initial state to node n and h(n) is the heuristic estimate to a goal. Hence, f(n)
estimates the lowest total cost of any solution path going through node n. At
each point a node with lowest f value is chosen for expansion. A* algorithm
guides an optimal path to a goal if the heuristic function h(n) is admissible,
meaning it never overestimates actual cost.

9
Khushboo Gupta CIS -667 Term Project Report

In this case, the heuristic function being used is similar to the one being
used in the Greedy Best First Search, so the solution might not be optimal
as the heuristic might overestimate the cost. The pseudocode is as follow -

def greedyH(board, goal):


Hval = 0
For i in boardsize:
If board[i] is not "B":
If board[i] is not goal[i]:
Increment Hval by 1
return Hval

def astar_solver(node, goal, filename):


nodesexplored, nodesgenerated = 0
Operator = setoperators()
current = node
current.setheuristic(greedyH(node.board,goal)
Put current in PriorityQueue based on sum of heuristic and
cost
If current is goal:
Write solution to filename
Print solution
return True
Else:
while(True):
If PriorityQueue is empty:
Return False
Current = pop top node from PriorityQueue
Add current to explored
Increment nodesexplored by 1
If current is in explored and is goal:
Write solution to filename
Print solution
Print nodesexplored, nodesgenerated
return True
For n in operators:
if operator n is valid == True:
board = updateboard(current.getboard(),operator[n])
Child = Node(board)
Child.parent = current
Child.operator = operator[n]
Cost = current.cost +1

10
Khushboo Gupta CIS -667 Term Project Report

F = current.Hval + current.cost
Increment nodesgenerated by 1
If child is not in explored:
Add child to explored
Else if child is in explored :
Check if child.cost>Cost:
Update the child.cost with Cost
Remove the old child from PriorityQueue
Add the updated child to the PriorityQueue

2.3 Implementation Challenges -


● Implementation of priority queue with lookup option in Python. There are modules
already present in Python such as heapq and queue, but both of them don’t support
lookup without removing the elements. Specially for the priority queue
implementation in A-star, I used a combination of list and dictionary. I sorted the
dictionary and added to list. Whenever the lookup was needed, dictionary was used.
While popping the highest priority node, list was used(list was constantly before
popping off the highest priority node) and at the same time popped element was
deleted from the dictionary.
● Finding proper heuristic function for A-star implementation which is admissible for
each problem set as each node in this problem represents a board state, and the
goal is only found the Blank cell is moved to goal position along with all other cells
reaching the same position as in the goal.

2.4 Performance Metrics and Experiments -


For each of the implemented algorithms, the following factors are used to compare the
performance -
1. If there is solution, is it found?
2. Is the solution optimal i.e. minimum possible number of steps needed to reach the
goal node.
3. The time taken to find the solution.
4. Total nodes generated.
5. Total nodes explored.

For performing the experiment, I have made 5 different problem sets. The 5 problem sets
contain initial RBG grids ranging from 2*2 to 6*6 RBG puzzle and their respective goal files.
I ran the same problem set on all 5 of the algorithm solver to collect the performance data.
That gives a total of 25 performance datasets, 1 problem set with each of the 5 algorithms.
Also if in any case, a particular algorithm crossed the 60 seconds mark, I terminated the
execution of the algorithm as other algorithms in the same problem set found the solution
much faster and it was enough to determine the performance of the slower algorithm in
comparison to others in the same problem set.

11
Khushboo Gupta CIS -667 Term Project Report

The results and observations for the experiments are mentioned in the next section.

3. Results and Observations -

The sample output format for one of the problem is -

12
Khushboo Gupta CIS -667 Term Project Report

Below is the the set of 5 problems I used to draw comparison among the 5 algorithms.
Before actually running them, it was necessary to be sure if the goal is possible at all or not.
I have summarized the results these problems generate.
Problem Goal

2*2 Grid RB RR
RG BG

3*3 Grid BRG RGR


GRG GBG
RGR RGR

4*4 Grid GGGR RGGR


RRRR BRRG
GRBG GRRG
RGGR RGGR

5*5 Grid RRRRR RRRRR


RGGGR RGGGR

13
Khushboo Gupta CIS -667 Term Project Report

RGGRR RGBGR
RGGRG RGGGR
RRRBR RRRRR

6*6 Grid RRGGRR RRGGRR


RRGGRR RRGGRR
GGRRGG GGRRGG
GGRRGG GGBRGG
RBGGRR RRGGRR
RRGGRR RRGGRR

Breadth First Search - In all the cases, according to the results BFS always find the optimal
solution(if it exists). However, it seems a bit slower for the cases where the problem is
comparatively smaller and less complicated. It is safe to say, BFS can be used to solve this
puzzle when the expectation is to find optimal step solution to the RBG puzzle, with
reasonable time. However, it generated and explored more nodes in comparison to the
informed state search algorithms in most of the cases.

BFS_Solver Solution Solution Time taken Nodes Nodes


found? Generated Explored

2*2 Grid Yes LD 00.009862 5 3


sec

3*3 Grid Yes RDRULD 00.010150 123 46


sec

4*4 Grid Yes UURDLULL 00.076241 2050 655


D

5*5 Grid Yes URU LL 00.015625 147 43


sec

6*6 Grid Yes URDLUR 00.029889 420 118


sec

Depth First Search - I used 60 seconds as cut off running time for all the algorithms. DFS
performed worst in every possible term. In problems with higher number of cells and the
problem’s board configuration was more different than just 3-4 cells(5*5 and 6*6 problems),
it didn't find any solution within 60 seconds while other 4 algorithms were done within a
second. Also except the 2*2 problem, it didn't find the optimal solution. So DFS is the
poorest choice out of the 5 algorithms in this case.

DFS_Solver Solution Solution Time taken Nodes Nodes

14
Khushboo Gupta CIS -667 Term Project Report

found? Generated Explored

2*2 Grid Yes LD 00.011226 3 2


sec

3*3 Grid Yes RRDLLDRR 00.020180 303 109


ULLDRRUL sec
LDRRULLD
RRULLURR
DLLDRRUL
LDRRULLD
RRULLDRR
ULLURRDL
LDRRULLD
RRULLDRR
ULLDRRUL
LURRDLLD
RRUL

4*4 Grid Yes RRDLLDRR 00.036937 11256 3657


ULLDRRUL sec
LDRRULLD
RRULLURR
DLLDRRUL
LDRRULLD
RRULLDRR
ULLURRDL
LDRRULLD
RRULLDRR
ULLDRRUL
LURRDLLD
RRUL

5*5 Grid No, 60 sec None More than - -


limit 60 sec
exceeded

6*6 Grid No, 60 sec None More than - -


limit 60 sec
exceeded

Iterative Deepening Search - IDS is also one of the best choices to find the optimal solution
for this problem within reasonable time. In all the problem sets, it has always found the
optimal solution. Only with the 4*4 grid, it took 20-25 times of the running time compared to
BFS, DFS and GBFS. That may be because the configuration of the 4*4 grid was very
different from the goal in term of both the position of the cells and distance of the Blank cell
from the position of Blank cell in goal grid.

15
Khushboo Gupta CIS -667 Term Project Report

Also I calculated the nodes explored and generated over the period of all iterations till the
solution is found, so they are reflecting the fact that the deeper the tree is explored, the
nodes are explored multiple times. For example at d, root is explored d times, the children
of root are explored d-1 times and so on.

IDS_Solver Solution Solution Time taken Nodes Nodes


found? Generated Explored

2*2 Grid Yes, depth 2 LD 00.000012 4 7


sec

3*3 Grid Yes, depth 6 RDRULD 00.019745 254 716


sec

4*4 Grid Yes, depth 9 UURDLULL 00.810487 11871 38433


D sec

5*5 Grid Yes, depth 5 URUL.L 00.031241 121 404


sec

6*6 Grid Yes, depth 6 URDLUR 00.029889 555 1963


sec

Greedy Best First Search - GBFS also performs reasonably well considering the heuristic
based on the position of cells with respect to goal grid. The heuristic value of the node is
increased by 1 whenever a cell of node is different from the corresponding cell in the goal
grid node. Out of the 5 problems, GBFS finds optimal solution for 4 of them. Also on
average, it has the lowest running time out of the 5 algorithms. Also compared to the other
4 algorithms, it has the lowest number of nodes generated and nodes explored.

GBFS_Solv Solution Solution Time taken Nodes Nodes


er found? Generated Explored

2*2 Grid Yes LD 00.000001 4 3


sec

3*3 Grid Yes RDRULD 00.009473 32 12

4*4 Grid Yes ULULDRDL 00.020027 435 135


URRD
URRDLULL

5*5 Grid Yes URULL 00.015620 17 6


sec

6*6 Grid Yes URDLUR 00.010137 131 38

16
Khushboo Gupta CIS -667 Term Project Report

A* Search - Given the current heuristic function, A* performs the second worst given the
current problem set. This concludes that the heuristic function used is not admissible for
each node or state. In all the cases except 2*2 grid, where it found solution, it was never
optimal. However in term of running time, is comes close to BFS. Also, it all cases, it has
generated and explored more nodes than GBFS but less than other 3 algorithms.

ASTAR_Sol Solution Solution Time taken Nodes Nodes


ver found? Generated Explored

2*2 Grid Yes LD 00.008456 4 3


sec

3*3 Grid Yes RRDLLDRU 00.010002 232 82


RULDLDRU
URDLDLUU

4*4 Grid No, program - - - -


crashed due
to recursion
limit of
python
object
exceeded

5*5 Grid Yes URDLLLLU 00.015482 55 20


UUURRRRD sec
DLL

6*6 Grid Yes LDRRRULU 00.019458 158 45


RULLLDRR sec
DRDLLLUR
URURDLLL
URRDRULL
LDRR

The respective performance of all 5 algorithms can be determined from the graphs below.
The 4*4 grid problem is the most complicated among the whole problem set.

17
Khushboo Gupta CIS -667 Term Project Report

18
Khushboo Gupta CIS -667 Term Project Report

4. Conclusion -

This RBG puzzle solver implements 5 algorithms and 2 of the algorithms, Breadth First
Search and Iterative Deepening Search always find optimal answers. Depth First Search
performs the worst both with respect to running time and bigger problem size with
complicated grid configuration compared to goal. Greedy Best First Search also performs
quite well , with the lowest running time and nodes explored on average and 4 out of 5
optimal solutions found. A* Search performs the second worst, as it finds non optimal
solution for 4 out of 5 problems, with unnecessary long sequence of steps.
In case of Iterative Deepening Search, the nodes explored were more than nodes
generated while its opposite with other algorithms. It most probably is due to the fact that
with each iteration when the search goes deeper, the nodes are repeatedly explored and
my implementation reflected that fact. The most difficult part of implementing this project
was figuring out priority queue implementation and proper heuristic function for A*. I use the
same heuristic function in both Greedy Best First Search and A*, with way better results in
case of Greedy Best Search. One theory I have about this oddity is the cost associated with
each node. The cost is incremented by 1 each time a child is generated based on the valid
operator(move). As priority queue/frontier for A* holds nodes based on the sum of both the
cost and heuristic value, the cost might have affected the priority for nodes and hence the
wrong nodes or less optimal nodes might get explored. Also as there is no prior way to
figure out the threshold value for the cost and heuristic value combined, no way was
implemented to stop exploring the non optimal nodes for the optimal solution.
For future work, I would like to figure out proper heuristic function for A* algorithm
implementation for this problem. It might be a better direction to explore how Manhattan
and Euclidean distances fit in A*’s heuristic function. However as the problem grid doesn’t
19
Khushboo Gupta CIS -667 Term Project Report

only have different location of the “Blank” cell compared to the goal grid, the configuration
and position of the rest of cells can be very different from the goal grid. The best option may
be to define the heuristic function as a combination of Manhattan distance of the “Blank”
cell from goal’s “Blank” and position of rest of the cells, with respect to goal’s grid. Also,
more problem sets can be generated to get more concrete idea of the performance of all 5
algorithms experimentally.

20

You might also like