Skip to content

Latest commit

 

History

History

greedy-best-first

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Greedy Best-First Search (GBFS)

Introduction

The Greedy Best-First Search (GBFS) algorithm with the Manhattan distance heuristic is an informed search technique that prioritizes expanding nodes that are closest to the goal, measured by the straight-line distance between them (also known as Manhattan distance).

The Manhattan distance is calculated by summing the absolute differences in 𝑥 and 𝑦 coordinates between two points on a plane.

$$\lvert x_{goal} - x_{n} \rvert + \lvert y_{goal} - y_{n} \rvert$$

Where $(x_{goal}, y_{goal})$ are the coordinates of the goal node and $(x_{n}, y_{n})$ are the coordinates of the current node $n$.

Usage

python maze.py maze.txt

Examples

Maze 1

img

Solution 1

img

States Explored: 5

img

Maze 2

img

Solution 2

img

States Explored: 54

img

Maze 3

img

Solution 3

img

States Explored: 175

img

References