我使用 Minimax 和 Alpha Beta Pruning 制作了一个 Tic Tac Toe 游戏。我想为 Tic Tac Toe (10x10) 游戏制作计算机 AI,但它的游戏树大小大得离谱。
我的代码是这样的,我只需要更改两个变量即可更改连续所需的棋盘大小 + 单元格数。例子:
boardSize = 3 // This is for 3x3 tic tac toe
boardSize = 4 // This is for 4x4 tic tac toe
boardSize = 10 // This is for 10x10 tic tac toe
和
winStreak = 3 // Need to make 3 cells in a row to win
winStreak = 4 // Need to make 4 cells in a row …
javascript machine-learning tic-tac-toe minimax alpha-beta-pruning
我想在调用之前更改"lol"按钮的颜色testFunction().
function testFunction() {
for (var i = 0; i < 200; i++) {
console.log(i);
}
return 0;
}
$("button").click(function() {
$("button").css("background-color", "#6ddc5d");
testFunction();
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>lol</button>Run Code Online (Sandbox Code Playgroud)
如果没有功能,我怎么能这样做呢?示例代码如下:
$("button").click(function() {
$("button").css("background-color", "#6ddc5d");
// change color, then run this below operation
for (var i = 0; i < 200; i++)
console.log(i);
// more stuff here
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>lol</button>Run Code Online (Sandbox Code Playgroud)