1.
... nie było ani jednego wystąpienia słowa "graph", a więc jest to sprawa dość uznaniowa.
|
już na samym początku autor cytowanego przez Ciebie artykułu robi założenie
" When you read about pathfinding elsewhere, you will often see people discussing nodes. Why not just call them squares?"
Kiedy czytasz o odnajdywaniu ścieżek gdzie indziej, często widzisz ludzi omawiających węzły. Dlaczego po prostu nie nazwać ich kwadratami?
czyli tam gdzie mówi o "kwadratach" mamy do czynienia z wierzchołkami (wezłami), a "scieżki" są krawędziami.
a z definicji :
"graf to zbiór wierzchołków, które mogą być połączone krawędziami w taki sposób, że każda krawędź kończy się i zaczyna w którymś z wierzchołków."
dlatego w sesie definicyjnym mamy do czynienia z grafem
modny jest teraz "relatywizm" tzn. wszystko jest względne zależy od ...
ale problemy :
"dwukrotnego powiekszenia kwadratowego basenu, gdy w jego rogach rosną 4 palmy bez ich wycinania"
" dwukrotnego powiekszenia kwadratowej sadzawki, gdy w jego rogach rosną 4 jabłonie bez ich wycinania"
jest to ten sam problem.
ale opisowo co innego :)
2.
ps.
algorytm A* - zobaczyłem wczoraj - po Twoim zgłoszeniu - opis nie jest ważny, ale sedno problemu jest takie samo.
przeczytałem wskazany opis i nie widzę różnicy sie od mojego (poza braniu w kolejnym kroku 8 punktów)
czy możesz byc tak uprzejmy i wskazać mi w cytowanej funkcji Pathfind()
kolejne kroki z opisu tego algorytmu
"
1) Add the starting square (or node) to the open list.
2) Repeat the following:
a) Look for the lowest F cost square on the open list. We refer to this as the current square.
b) Switch it to the closed list.
c) For each of the 8 squares adjacent to this current square …
• If it is not walkable or if it is on the closed list, ignore it. Otherwise do the following.
• If it isn’t on the open list, add it to the open list. Make the current square the parent of this square. Record the F, G, and H costs of the square.
• If it is on the open list already, check to see if this path to that square is better, using G cost as the measure. A lower G cost means that this is a better path. If so, change the parent of the square to the current square, and recalculate the G and F scores of the square. If you are keeping your open list sorted by F score, you may need to resort the list to account for the change.
d) Stop when you:
• Add the target square to the closed list, in which case the path has been found (see note below), or
• Fail to find the target square, and the open list is empty. In this case, there is no path.
3) Save the path. Working backwards from the target square, go from each square to its parent square until you reach the starting square. That is your path.
"
napisałem to, bo wydaje mi sie to istotne np.
* Add the starting square (or node) to the open list. -> Ty dodajesz wszystkie
* b) Switch it to the closed list.
ale jak pisałem wcześniej nie rozumiem Twojego algorytmu :)
3.
na samym początku funkcji Pathfind() użyłeś zmiennej/stałej currentMap, ktorej nie ma udostępnionym kodzie.
//Firstly, assign all nodes to a Vector.
col = maps[ currentMap ].colImage;
4.
bad alloc jest dlatego że pętla while(currentNode != beginningNode) wykonuje się zbyt dużo razy, i nadal nie wiem dlaczego.
|
*
użyj przechwytywania wyjatków try ... catch
po przechwyceniu wyświetl stan zmiennych używanych w tej pętli
choć w codeBlock jest normalny debuger -
zatrzymasz i widzisz stan nawet złożonych struktur
*
w pętli deklarujesz nowe zmienne np.
vector < Node > surroundingNodes;
czy nie prowadzi to do wyczerpania zasobów ?
*
openNodes.erase( openNodes.begin() + 0 );
vector < Node > surroundingNodes;
surroundingNodes = getSurroundingNodes( * currentNode, col );
jak się zachowa gdy openNodes jest już pusta ?
wskazujemy na co ?
5.
jezeli tworzysz klasy "class Node", to mógłbyś dodać konstruktor + funkcje
podobnie stworzyc klasę dla "vector < Node >" z odpowiednimi metodami
uprościłoby to kod :)
6.
próbujesz zrealizować "wiele" w jednej funkcji/metodzie/klasie,
a sensem programowania obiektowego jest zrealizować "jedną funkcjonalność"
Powodzenia !