How does A* search work given there are multiple goal states? When I have read through the fundamentals of AI, I saw a situation (i.e., a search space) which is illustrated in the following picture.



These are the heuristic estimates:

h(B)=9
h(D)=10
h(A)=2
h(C)=1


If we use the A* algorithm, the node $B$ will be expanded first because $f(B)=1+9=10$, while node $A$ having $f(A)=9+2=11$ and $f(B)&lt;f(A)$, right?

After that, the search tree will go on in the order R -&gt; B -&gt; D -&gt; G2. Will the search go on to also find the goal state G1?

Kindly let me know the order of the search if I am wrong.
Yes. If you leave A* running (i.e. do not impose a goal condition on a newly-encountered state), all states will be explored, just as they would be in breadth- or depth- first search.