prolog 找路例子程序:
=== === === === === ===
Part 1-Adding connections
Part 2-Simple Path
example
| ?- path1(a,b,P,T).
will produce the response:
T = 15
P = [a,b] ?
Part 3 - Non-repeating path
As an example, the query:
?- path2(a,h,P,T).
will succeed and may produce the bindings:
P = [a,depot,b,d,e,f,h]
T = 155
Part 4 - Generating a path below a cost threshold
As an example, the query:
?- path_below_cost(a,[a,b,c,d,e,f,g,h],RS,300).
returns:
RS = [a,b,depot,c,d,e,g,f,h] ?
RS = [a,c,depot,b,d,e,g,f,h] ?
no
==================================
標(biāo)簽:
Part
connections
example
prolog
上傳時(shí)間:
2015-04-24
上傳用戶:ljt101007
//在tc3.0++在運(yùn)行
//a數(shù)組用于隨機(jī)產(chǎn)生1-6數(shù)表示每個(gè)方格后面的圖形.用inita()函數(shù)來實(shí)現(xiàn)
//c數(shù)組用于記錄方格的狀態(tài),用字符L(lock)表示沒有打開的方格
//D(delete)表示已消去的方格.O(open)表示打開的方格.
//變量m表示按回車鍵的有效次數(shù).也是記憶力參數(shù),越小記憶力越好
//變量xpos,ypos用于表示當(dāng)前光標(biāo)所在的位置
//(x1,y1),(x2,y2)用于記錄打開的兩個(gè)方格的位置
//judge()函數(shù)用于控制光標(biāo)范圍,使其不能移出長(zhǎng)方形
//win()函數(shù)用于判斷游戲是否過關(guān),通過判斷每個(gè)方格是否全是 D 狀態(tài)
//xago,yago 用于記錄移動(dòng)前的位置
//ax,ay表示行列式的行與列,用它們來控制游戲的關(guān)數(shù),ax位于3-6之間,ay位于4-7之間
//z來控制方格后的圖形
//第一關(guān)后面的圖形用1-6代表的圖形.第二關(guān)后面的圖形用0-9十個(gè)數(shù)。第三關(guān)后面的圖形用A-O十五個(gè)字母,
//第四關(guān)后面的圖形用A-T二十一個(gè)字母
標(biāo)簽:
inita
lock
3.0
數(shù)組
上傳時(shí)間:
2015-06-19
上傳用戶:hgy9473