星期四, 4月 02, 2009

試試

最近剛好在寫 A* Algorithm , vim 有把純文字轉成 html (:TOhtml)的功能,來試試

 1 Add START to OPEN list
2 while OPEN not empty
3 get node n from OPEN that has the lowest f(n)
4 if n is GOAL then return path
5 move n to CLOSED
6 for each n’ = CanMove(n , direction)
7 g(n’) = g(n) + cost(n,n’)
8 calculate f(n’)=g(n’)+h(n’)
9 if n’ in OPEN list and new n’ is not better , continue
10 if n’ in CLOSED list and new n’ is not better , continue
11 remove any n’ from OPEN and CLOSED
12 add n as n’s parent
13 add n’ to OPEN ….. coming up in OPEN
14 end for
15 end while
16 if we get here , then there is No Solution

雖然轉出來的code很醜,如果效果不錯,以後就會用它了... 畢竟我不會寫CSS XD


---
寫完再好好解釋這個 Algorithm :)

沒有留言: