我想了解一下五子棋AI A演算法,可是怎麼都看不明白啊誰能詳細講講啊

時間 2022-05-22 16:20:08

1樓:匿名使用者

/*源程式太多了,要的話給油箱*/

#define nrow 15

tmpzth="" && 行狀態

tmpztl="" && 列狀態

for i=1 to nrow

for j=1 to nrow

tmpzth=tmpzth+azt(i,j)

tmpztl=tmpztl+azt(j,i)

endfor

&& 行判斷

do case

********** y 連 5 ***********

case "nyyyy" $ tmpzth

thisform.plc_h(i,j,at("nyyyy",tmpzth),0 ,1) && 1 的得出方法 :at("n","nyyyy")

case "ynyyy" $ tmpzth

thisform.plc_h(i,j,at("ynyyy",tmpzth),1 ,1)

case "yynyy" $ tmpzth

thisform.plc_h(i,j,at("yynyy",tmpzth),2 ,1)

case "yyyny" $ tmpzth

thisform.plc_h(i,j,at("yyyny",tmpzth),3 ,1)

case "yyyyn" $ tmpzth

thisform.plc_h(i,j,at("yyyyn",tmpzth),4 ,1)

********** b 連 5 **********

case "nbbbb" $ tmpzth

thisform.plc_h(i,j,at("nbbbb",tmpzth),0 ,2)

case "bnbbb" $ tmpzth

thisform.plc_h(i,j,at("bnbbb",tmpzth),1 ,2)

case "bbnbb" $ tmpzth

thisform.plc_h(i,j,at("bbnbb",tmpzth),2 ,2)

case "bbbnb" $ tmpzth

thisform.plc_h(i,j,at("bbbnb",tmpzth),3 ,2)

case "bbbbn" $ tmpzth

thisform.plc_h(i,j,at("bbbbn",tmpzth),4 ,2)

********** y 衝 4 ***********

case "nynyyn" $ tmpzth

thisform.plc_h(i,j,at("nynyyn",tmpzth),2 ,3)

case "nyynyn" $ tmpzth

thisform.plc_h(i,j,at("nyynyn",tmpzth),3 ,3)

case "nyyynn" $ tmpzth

thisform.plc_h(i,j,at("nyyynn",tmpzth),4 ,3)

case "nnyyyn" $ tmpzth

thisform.plc_h(i,j,at("nnyyyn",tmpzth),1 ,3)

********* b 衝 4 ************

case "nbnbbn" $ tmpzth

thisform.plc_h(i,j,at("nbnbbn",tmpzth),2 ,5)

case "nbbnbn" $ tmpzth

thisform.plc_h(i,j,at("nbbnbn",tmpzth),3 ,5)

case "nbbbnn" $ tmpzth

thisform.plc_h(i,j,at("nbbbnn",tmpzth),4 ,5)

case "nnbbbn" $ tmpzth

thisform.plc_h(i,j,at("nnbbbn",tmpzth),1 ,5)

********** y 連 4 ***********

case "nnyyyb" $ tmpzth

thisform.plc_h(i,j,at("nnyyyb",tmpzth),1 ,4)

case "nynyyb" $ tmpzth

thisform.plc_h(i,j,at("nynyyb",tmpzth),2 ,4)

case "nyynyb" $ tmpzth

thisform.plc_h(i,j,at("nyynyb",tmpzth),3 ,4)

case "nyyynb" $ tmpzth

thisform.plc_h(i,j,at("nyyynb",tmpzth),1 ,4)

case "byyynn" $ tmpzth

thisform.plc_h(i,j,at("byyynn",tmpzth),4 ,4)

case "byynyn" $ tmpzth

thisform.plc_h(i,j,at("byynyn",tmpzth),3 ,4)

case "bynyyn" $ tmpzth

thisform.plc_h(i,j,at("bynyyn",tmpzth),2 ,4)

case "bnyyyn" $ tmpzth

thisform.plc_h(i,j,at("bnyyyn",tmpzth),1 ,4)

********** b 連 4 ***********

case "nnbbby" $ tmpzth

thisform.plc_h(i,j,at("nnbbby",tmpzth),1 ,9)

case "nbnbby" $ tmpzth

thisform.plc_h(i,j,at("nbnbby",tmpzth),2 ,9)

case "nbbnby" $ tmpzth

thisform.plc_h(i,j,at("nbbnby",tmpzth),3 ,9)

case "nbbbny" $ tmpzth

thisform.plc_h(i,j,at("nbbbny",tmpzth),1 ,9)

case "ybbbnn" $ tmpzth

thisform.plc_h(i,j,at("ybbbnn",tmpzth),4 ,9)

case "ybbnbn" $ tmpzth

thisform.plc_h(i,j,at("ybbnbn",tmpzth),3 ,9)

case "ybnbbn" $ tmpzth

thisform.plc_h(i,j,at("ybnbbn",tmpzth),2 ,9)

case "ynbbbn" $ tmpzth

thisform.plc_h(i,j,at("ynbbbn",tmpzth),1 ,9)

********** y 衝 3 ***********

case "nynynn" $ tmpzth

thisform.plc_h(i,j,at("nynynn",tmpzth),2 ,6)

case "nnyynn" $ tmpzth

thisform.plc_h(i,j,at("nnyynn",tmpzth),4 ,6)

********* b 衝 3 ************

case "nbnbnn" $ tmpzth

thisform.plc_h(i,j,at("nbnbnn",tmpzth),2 ,8)

case "nnbbnn" $ tmpzth

thisform.plc_h(i,j,at("nnbbnn",tmpzth),4 ,8)

********** 1個 ***********

case "nnynnn" $ tmpzth

thisform.plc_h(i,j,at("nnynnn",tmpzth),3, 7)

case "nnnynn" $ tmpzth

thisform.plc_h(i,j,at("nnnynn",tmpzth),2 ,7)

case "nnbnnn" $ tmpzth

thisform.plc_h(i,j,at("nnbnnn",tmpzth),3 ,10)

case "nnnbnn" $ tmpzth

thisform.plc_h(i,j,at("nnnbnn",tmpzth),2 ,10)

endcase

&& 列判斷

do case

********** 5個 ***********

case "nyyyy" $ tmpztl

thisform.plc_l(i,j,at("nyyyy",tmpztl),0 ,1) && 1 的得出方法 :at("n","nyyyy")

case "ynyyy" $ tmpztl

thisform.plc_l(i,j,at("ynyyy",tmpztl),1 ,1)

case "yynyy" $ tmpztl

thisform.plc_l(i,j,at("yynyy",tmpztl),2 ,1)

case "yyyny" $ tmpztl

thisform.plc_l(i,j,at("yyyny",tmpztl),3 ,1)

case "yyyyn" $ tmpztl

thisform.plc_l(i,j,at("yyyyn",tmpztl),4 ,1)

case "nbbbb" $ tmpztl

thisform.plc_l(i,j,at("nbbbb",tmpztl),0 ,2)

case "bnbbb" $ tmpztl

thisform.plc_l(i,j,at("bnbbb",tmpztl),1 ,2)

case "bbnbb" $ tmpztl

thisform.plc_l(i,j,at("bbnbb",tmpztl),2 ,2)

case "bbbnb" $ tmpztl

thisform.plc_l(i,j,at("bbbnb",tmpztl),3 ,2)

case "bbbbn" $ tmpztl

thisform.plc_l(i,j,at("bbbbn",tmpztl),4 ,2)

********** 4個 ***********

case "nynyyn" $ tmpztl

thisform.plc_l(i,j,at("nynyyn",tmpztl),2 ,3)

case "nyynyn" $ tmpztl

thisform.plc_l(i,j,at("nyynyn",tmpztl),3 ,3)

case "nyyynn" $ tmpztl

thisform.plc_l(i,j,at("nyyynn",tmpztl),4 ,3)

case "nnyyyn" $ tmpztl

thisform.plc_l(i,j,at("nnyyyn",tmpztl),1 ,3)

case "nbnbbn" $ tmpztl

thisform.plc_l(i,j,at("nbnbbn",tmpztl),2 ,5)

case "nbbnbn" $ tmpztl

thisform.plc_l(i,j,at("nbbnbn",tmpztl),3 ,5)

case "nbbbnn" $ tmpztl

thisform.plc_l(i,j,at("nbbbnn",tmpztl),4 ,5)

case "nnbbbn" $ tmpztl

thisform.plc_l(i,j,at("nnbbbn",tmpztl),1 ,5)

********** 3個 ***********

case "nnyyyb" $ tmpztl

thisform.plc_l(i,j,at("nnyyyb",tmpztl),1 ,4)

case "nynyyb" $ tmpztl

thisform.plc_l(i,j,at("nynyyb",tmpztl),2 ,4)

case "nyynyb" $ tmpztl

thisform.plc_l(i,j,at("nyynyb",tmpztl),3 ,4)

case "nyyynb" $ tmpztl

thisform.plc_l(i,j,at("nyyynb",tmpztl),1 ,4)

case "byyynn" $ tmpztl

thisform.plc_l(i,j,at("byyynn",tmpztl),4 ,4)

case "byynyn" $ tmpztl

thisform.plc_l(i,j,at("byynyn",tmpztl),3 ,4)

case "bynyyn" $ tmpztl

thisform.plc_l(i,j,at("bynyyn",tmpztl),2 ,4)

case "bnyyyn" $ tmpztl

thisform.plc_l(i,j,at("bnyyyn",tmpztl),1 ,4)

case "nnbbby" $ tmpztl

thisform.plc_l(i,j,at("nnbbby",tmpztl),1 ,9)

case "nbnbby" $ tmpztl

thisform.plc_l(i,j,at("nbnbby",tmpztl),2 ,9)

case "nbbnby" $ tmpztl

thisform.plc_l(i,j,at("nbbnby",tmpztl),3 ,9)

case "nbbbny" $ tmpztl

thisform.plc_l(i,j,at("nbbbny",tmpztl),1 ,9)

case "ybbbnn" $ tmpztl

thisform.plc_l(i,j,at("ybbbnn",tmpztl),4 ,9)

case "ybbnbn" $ tmpztl

thisform.plc_l(i,j,at("ybbnbn",tmpztl),3 ,9)

case "ybnbbn" $ tmpztl

thisform.plc_l(i,j,at("ybnbbn",tmpztl),2 ,9)

case "ynbbbn" $ tmpztl

thisform.plc_l(i,j,at("ynbbbn",tmpztl),1 ,9)

********** 2個 ***********

case "nynynn" $ tmpztl

thisform.plc_l(i,j,at("nynynn",tmpztl),2 ,6)

case "nnyynn" $ tmpztl

thisform.plc_l(i,j,at( "nnyynn",tmpztl),4 ,6)

case "nbnbnn" $ tmpztl

thisform.plc_l(i,j,at("nbnbnn",tmpztl),2 ,8)

case "nnbbnn" $ tmpztl

thisform.plc_l(i,j,at("nnbbnn",tmpztl),4 ,8)

********** 1個 ***********

case "nnynnn" $ tmpztl

thisform.plc_l(i,j,at("nnynnn",tmpztl),3, 7)

case "nnnynn" $ tmpztl

thisform.plc_l(i,j,at("nnnynn",tmpztl),2 ,7)

case "nnbnnn" $ tmpztl

thisform.plc_l(i,j,at("nnbnnn",tmpztl),3 ,10)

case "nnnbnn" $ tmpztl

thisform.plc_l(i,j,at("nnnbnn",tmpztl),2 ,10)

endcase

tmpzth=""

tmpztl=""

endfor

下五子棋有什麼訣竅?五子棋的技巧的訣竅

多練習,跟高手玩的時候,他們都有很多技巧,反正就是不知不覺輸了,你留心一下,輸了就記一下那種陷阱怎麼布,我有時就拿筆記下來的,然後經常玩,就你較容易看出來了。多練習,眼力很重要,不要被動,被動一般不好嬴。注意那裡有三顆棋子連在一起而且兩頭都沒有自己的棋子就要注意了。最簡單的方法就是進攻,牽著對手走。...

怎麼玩五子棋大戰,下五子棋作文460個字

最簡單地說就是要謹慎,不要讓對方有五個子連在一起就行。antiyoy怎麼玩 一塊屬於你的地區,金幣成負數,小兵就會全部死亡,這一點要注意。那個黑色的塔可以防禦周圍6個,紅色兵種以上的都可以攻打。兩個小人走到一起就會合成一個等級更高的小人。可以通過,讓小人走到森林來持續獲得金幣,可以選擇一塊入口較小的...

五子棋技巧玩了好長時間的五子棋(就是瞎下)也不是總輸也不是總贏我發現和高手下棋不管看得再緊都輸

天使 基本規則 黑白雙方依次落子,任一方先在棋盤上形成橫向 豎向 斜向的連續的相同顏色的五個 含五個以上 棋子的一方為勝。禁手規則 鑑於無禁手規則黑棋必勝,人們不斷採用一些方法限制黑棋先行的優勢,以平衡黑白雙方的形式。於是針對黑棋的各種禁手逐漸形成。禁手最簡單地說就是一手棋形成長連 連成五個以上連續...