Skip to main content

Comparing the Hamming and Manhattan Heuristics in Solving the 8—Puzzle by A* Algorithm

  • Conference paper
  • First Online:
Proceedings of the 7th International Conference on the Applications of Science and Mathematics 2021

Part of the book series: Springer Proceedings in Physics ((SPPHY,volume 273))

Abstract

The 8-puzzle is a classical sliding puzzle that consists of 8 numbered tiles placed in random order on a board with 9 cells. The goal is to rearrange the tiles by sliding them horizontally or vertically into the vacant cell such that the number in each tile is ordered in ascending order. 8-puzzles can be solved by using the path searching algorithms such as Best-first search, Depth-fist search, Dijkstra’s algorithm, or the A* algorithm. In this paper, the A* algorithm will be the one chosen. The A* algorithm is known to be an improvement to the Dijkstra’s algorithm since not all potential paths need to be searched before the optimal one is found. The key of the A* algorithm is choosing the right heuristic formula as an estimation to the cost of each path. Two heuristics, the Hamming distance and the Manhattan distance are chosen to be implemented in the A* algorithm. The computing time for our several test puzzles suggests that the Manhattan distance is found to be the more efficient heuristic.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 169.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Hardcover Book
USD 219.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Reference

  1. E.O. Osaghae, An alternative solution to N-puzzle problem. J. Appl. Sci. Environ. Manag. 22(8), 1199–1205 (2018). https://doi.org/10.4314/jasem.v22i8.9

    Article  Google Scholar 

  2. A.K. Mishra, P.C. Siddalingaswamy, Analysis of Tree Based Search Techniques for Solving 8-puzzle Problem. In Conference 2016, LNCS 9999 (Springer Heidelberg, 2016), pp. 1–13

    Google Scholar 

  3. R.E. Korf, Recent Progress in the Design and Analysis of Admissible Heuristic Functions. In International Symposium on Abstraction, Reformulation, and Approximation. (Springer, Berlin, 2000), pp. 45–55. https://doi.org/10.1007/3-540-44914-0_3

  4. B.M. Sathyaraj, L.C. Jain, A. Finn, S. Drake, Multiple UAVs path planning algorithms: A comparative study. Fuzzy Optim. Decis. Making 7(3), 257–267 (2008). https://doi.org/10.1007/s10700-008-9035-0

    Article  MathSciNet  MATH  Google Scholar 

  5. K. Mathew, M. Tabassum, Experimental comparison of uninformed and heuristic AI algorithms for N puzzle and 8 queen puzzle solution. Int. J. Digital Inf. Wirel. Commun. 4(1), 143–154 (2014). https://doi.org/10.17781/P001092

    Article  Google Scholar 

  6. A. Reinefeld, Complete Solution of the Eight-Puzzle and the Benefit of Node Ordering in IDA*. In Proceedings of the 13th International Joint Conference on Artificial Intelligence, vol. 1 (1993), pp. 248–253

    Google Scholar 

  7. R.E. Korf, A. Felner, Disjoint pattern database heuristics. Artif. Intell. 134(2), 9–22 (2002). https://doi.org/10.1016/S0004-3702(01)00092-3

    Article  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Siaw Chong Lee .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 The Author(s), under exclusive license to Springer Nature Singapore Pte Ltd.

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Lee, S.C., See, T.H. (2022). Comparing the Hamming and Manhattan Heuristics in Solving the 8—Puzzle by A* Algorithm. In: Mustapha, A.B., Shamsuddin, S., Zuhaib Haider Rizvi, S., Asman, S.B., Jamaian, S.S. (eds) Proceedings of the 7th International Conference on the Applications of Science and Mathematics 2021. Springer Proceedings in Physics, vol 273. Springer, Singapore. https://doi.org/10.1007/978-981-16-8903-1_19

Download citation

Publish with us

Policies and ethics