Step by Step Explanation of A* Pathfinding Algorithm in Java

preview_player
Показать описание
Here's a step-by-step explanation of how to create an A* path search algorithm demo program in Java.

A*(star) pathfinding algorithm is widely used in video game development to let characters find their path from point A to B.

Timestamps:
0:00 Introduction
2:40 Creating a demo panel
5:01 Creating Node class
7:45 Placing nodes on the panel
9:15 Setting the start node and the goal node
13:35 Setting solid nodes
15:13 G cost, H cost and F cost
21:52 How A* algorithm evaluate nodes
27:12 Open, evaluate and check
38:15 Implementing key input
40:20 Auto-search
42:27 Backtrack the nodes and draw the path
44:03 FINAL RESULT
Рекомендации по теме
Комментарии
Автор

*CORRECTION*
41:44 I used the "step" variable in the search() method but it was supposed to be in the autoSearch() method! It was my silly mistake. (Thank you Aung Linn for pointing this out)

Also, I realized I didn't use the checkedList at all in this video. I thought I might use it to check what nodes are checked and when I reset the search result but we can handle both with the checked boolean so the list was not really necessary :P

RyiSnow
Автор

Theres no way, Ive been following your tutorials and just had to make my own A star pathfinding algorithm in java, I finished it yesterday and now today you upload a video on it.

jamesconwell
Автор

Wow you are the first person to make a great algothim demo in java! Thank you so much! Your video's mean so much!

od
Автор

Hello, I am very grateful to you for this video! Thank you so much. It works; One tip for MacOS users. For me the tiles would not change color by just using the method setBackground(); For example to make the start tile blue, I had to add setOpaque(true) and setBoarderPainted(false) as follows.

public void setAsStart()

setForeground(Color.WHITE);
setText("S");
setOpaque(true); // ensure that the button completely covers any background behind it.
setBorderPainted(false); // if set to true The button will draw its border.
start = true;
}

NoahMoussa-suyd
Автор

Congrats! You are the first person to make me understand A*

mousabthebest
Автор

Great!!! I just implemented it too... I also learned this: To move many entities, there is also the solution using Flow Fields, its algorithm is similar to A* one, I implemented it in Java recently and the performance are good. With it you have to generate just one field for all the entities, the drawback is you have to generate one vector for each tile of the map, so for big maps you have to make tradeoffs. But with many entities it should outperform A* calculation for each entity.

lucaxtal
Автор

Really good tutorial! I'm not coding in Java but I was able to follow along just fine implementing this in a C# based project. I was quite suprised at how intuitive A* pathfinding is in terms of set up

johndoubleub
Автор

you dont understand how badly i wanted this video

daryoushkian
Автор

Just GREAT!! After a lot of searching this is far the best i have seen from all views.. GREAT JOB!

STERGIOSTOULIOUDAS
Автор

I just found your channel and I'm already a fan. I'm already arranging to watch all your videos. Thank you so much for the content, you are amazing! <3

felipemiranda
Автор

Thank you very much, I was struggling to understand A* pathfinding, but this video helped me so much and I adapted it into my project which uses MVC architecture. Great tutorial.

rlfpotatoking
Автор

I sincerely want to thank you very much for giving me the energy to love coding even more

Nadi_Kassapa
Автор

You are a treasure for us, thanks for these tutorials <3 <3

adnan
Автор

Heeey RyiSnow!! That's awesome. I saw that recently in my cs major, really liked to see it here. Thank you for another video!

PedroHenrique-hyyw
Автор

Please continue to create these amazing tutorials!

LolBruh
Автор

Wow. This is perfect.
This will make my pacman's ghost ai so much better. Thank you.

bood_kr
Автор

i started off watching your videos but stopped and started working on my own but had a nice base to work off of, this is extremely helpful for me!!!! thank

forte
Автор

This is cool! Very well done and meticulously explained.

edrperez
Автор

As always amazing! Worth to mention it is closely related to Breadth First Search very useful for solving programming challenges of different sort!

bartoszjozwicki
Автор

Hi,
I haven't been here for a long time, but I'm slowly coming back. All I can say is that one big WOW.

Both this algorithm and the trading system. This is so great, I can't wait to do it myself.

Please tell us if you plan to do quests? If I can ask, I would ask for a minimap and a day and night system. And most importantly, that you develop this project. You are the best java game developer na yt: D

michajurkiewicz