Presentation is loading. Please wait.

Presentation is loading. Please wait.

AI人工智慧期末報告 -五子棋 班級:資工四乙 學號:498G0112 姓名:陳銘彥.

Similar presentations


Presentation on theme: "AI人工智慧期末報告 -五子棋 班級:資工四乙 學號:498G0112 姓名:陳銘彥."— Presentation transcript:

1 AI人工智慧期末報告 -五子棋 班級:資工四乙 學號:498G0112 姓名:陳銘彥

2 摘要 五子棋則咸信是流傳於古中國的傳統棋種之一,至今仍在民間廣泛流傳,規則相當簡單。或許因沒有形成一套獨立完整的棋種理論及文化內涵,更無制定公平完善的規則來解決黑白平衡問題,一直沒有得到發展,所以沒有像圍棋、象棋等傳統棋類流傳廣泛,導致缺少可考古的棋具,也沒像直棋、方棋等鄉土棋類記載在地方縣誌、古人筆記等文獻。

3 遊戲玩法 單人玩的五子棋遊戲 一開始可選黑子或白子 按滑鼠左鍵可下子 按滑鼠右鍵可悔棋一步
一開始選白子改成電腦先下 圖形介面美化,棋盤變15x15 AI全面重寫,考慮四三、雙三、雙四等等

4 程式碼-AI部分 //AI攻擊 //判斷是否將可連成三
if (j + 3 <= boarder && j - 1 >= 0 ) //向左 { line = flag[i][j - 1] + "X" + flag[i][j + 1] + flag[i][j + 2] + flag[i][j + 3]; isEqual(i, j, line); } if (j - 2 >= 0 && j+2 <= boarder ) line = flag[i][j - 2] + flag[i][j - 1] + "X" + flag[i][j + 1] + flag[i][j + 2]; if (j - 3 >= 0 && j + 1 <= boarder ) // 向右 line = flag[i][j + 1] + "X" + flag[i][j - 1] + flag[i][j - 2] + flag[i][j - 3];  if (j + 2 <= boarder && j-2 >= 0 ) line = flag[i][j + 2] + flag[i][j + 1] + "X" + flag[i][j - 1] + flag[i][j - 2];

5 //判斷是否將可連成活二 if (j + 2 <= boarder && j - 1 >= 0 ) //向左 { line = flag[i][j - 1] + "X" + flag[i][j + 1] + flag[i][j + 2]; isEqual(i, j, line); } if (j - 2 >= 0 && j + 1 <= boarder ) // 向右 line = flag[i][j + 1] + "X" + flag[i][j - 1] + flag[i][j - 2];

6 //連五 if (e.equals("X2222")) powerC[mi][mj] += 2000; if (e.equals("2X222")) powerC[mi][mj] += 2000; if (e.equals("22X22")) powerC[mi][mj] += 2000; if (e.equals(“X1111”)) powerP[mi][mj] += 2000; if (e.equals("1X111")) powerP[mi][mj] += 2000; if (e.equals("11X11")) powerP[mi][mj] += 2000; //連五End //活四 if (e.equals(“0X2220”)) powerC[mi][mj] += 500; if (e.equals("02X220")) powerC[mi][mj] += 500; if (e.equals("0X1110")) powerP[mi][mj] += 500; if (e.equals("01X110")) powerP[mi][mj] += 500; //活四End

7 //死四 if (e.equals("0X2221")){powerC[mi][mj] += 530; comboC[mi][mj] += 10;} if (e.equals("X02221")){powerC[mi][mj] += 529; comboC[mi][mj] += 10;} if (e.equals("02X221")){powerC[mi][mj] += 530; comboC[mi][mj] += 10;} if (e.equals("20X221")){powerC[mi][mj] += 529; comboC[mi][mj] += 10;} if (e.equals("20X220")){powerC[mi][mj] += 529; comboC[mi][mj] += 10;} if (e.equals("2X0221")){powerC[mi][mj] += 529; comboC[mi][mj] += 10;} if (e.equals("2X0220")){powerC[mi][mj] += 529; comboC[mi][mj] += 10;} if (e.equals("2X202")){powerC[mi][mj] += 529; comboC[mi][mj] += 3;} if (e.equals("12X220")){powerC[mi][mj] += 530; comboC[mi][mj] += 10;} if (e.equals("0X1112")){powerP[mi][mj] += 29; comboP[mi][mj] += 10;} if (e.equals("X01112")){powerP[mi][mj] += 29; comboP[mi][mj] += 10;} if (e.equals("01X112")){powerP[mi][mj] += 29; comboP[mi][mj] += 10;} if (e.equals("10X112")){powerP[mi][mj] += 29; comboP[mi][mj] += 10;} //死四End  

8 //活三 if (e.equals("0X220")){powerC[mi][mj] += 9;comboC[mi][mj] += 1;} if (e.equals("0X0220")){powerC[mi][mj] += 9;comboC[mi][mj] += 1;} if (e.equals("02X20")){powerC[mi][mj] += 9;comboC[mi][mj] += 1;} if (e.equals("0X2020")){powerC[mi][mj] += 8;comboC[mi][mj] += 1;} if (e.equals("02X020")){powerC[mi][mj] += 8;comboC[mi][mj] += 1;} if (e.equals("0X110")){//powerP[mi][mj] += 10;comboP[mi][mj] += 1;} if (e.equals("0X0110")){//powerP[mi][mj] += 9;comboP[mi][mj] += 1;} if (e.equals("01X10")){//powerP[mi][mj] += 10;comboP[mi][mj] += 1;} if (e.equals("0X1010")){//powerP[mi][mj] += 10;comboP[mi][mj] += 1;} if (e.equals("01X010")){//powerP[mi][mj] += 10;comboP[mi][mj] += 1;} //活三End //連二 if (e.equals("0X20")) powerC[mi][mj] += 2; if (e.equals("0X10")) powerP[mi][mj] += 1; //連二End

9 DEMO


Download ppt "AI人工智慧期末報告 -五子棋 班級:資工四乙 學號:498G0112 姓名:陳銘彥."

Similar presentations


Ads by Google