資源簡介
用matlab實現了一個帶圖形化界面、鼠標操作的井字棋AI
代碼片段和文件信息
function?[?ret?]?=?AIinput(??)
%AIINPUT?Choose?the?best?position?to?put?the?tictactoe?piece
????global?map;
????INF?=?1000000;
????Valuation?=?-INF-1;?
????X?=?0;?Y?=?0;
????ret?=?0;
????
????%?find?the?best?position
????for?i?=?1:3
????????for?j?=?1:3
????????????if?map(ij)?~=?0
????????????????continue;
????????????end
????????????map(ij)?=?1;
????????????if?CheckWin()?~=?1
????????????????val?=?-Cut(0?1?-1);
????????????else
????????????????val?=?INF;
????????????end
????????????map(ij)?=?0;
????????????if?val?>?Valuation
????????????????Valuation?=?val;
????????????????X?=?i;?Y?=?j;
????????????end
????????end
????end
????
????%?put?the?tictactoe?piece
????if?X+Y?~=?0
????????map(XY)?=?1;
????end
end
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????755??2016-03-12?20:54??AIinput.m
?????文件?????????749??2016-03-12?20:00??CheckWin.m
?????文件????????2195??2016-03-12?22:15??Cut.m
?????文件????????1039??2016-03-12?17:41??GetValue.m
?????文件????????1225??2016-03-12?23:34??main.m
?????文件????????1175??2016-03-15?23:32??PrintBoard.m
?????文件?????????469??2016-03-12?23:40??Userinput.m
?????文件???????59488??2016-03-15?22:59??微信截圖_20160315225905.png
?????文件???????70595??2016-03-15?22:59??微信截圖_20160315225921.png
?????文件???????70946??2016-03-15?22:59??微信截圖_20160315225936.png
- 上一篇:MATLAB實現的人工免疫算法
- 下一篇:matlab多項式擬合GUI
評論
共有 條評論