小编Ver*_*era的帖子

如何使我的AI算法播放9板井字游戏?

为了让其他人轻松地帮助我, 我将所有代码都放在此处https://pastebin.com/WENzM41k ,它将在2个代理相互竞争时开始。

我正在尝试实现Monte Carlo树搜索以在Python中播放9板tic-tac-toe。游戏规则类似于常规的井字游戏,但带有9个3x3子板。最后一块的放置位置决定放置一块子板。这有点像最终的井字游戏,但如果赢得了一个分牌,游戏就会结束。

我正在尝试学习MCTS,并且在这里找到了一些代码:http : //mcts.ai/code/python.html

我在网站上使用了节点类和UCT类,并添加了我的9局井字游戏状态类和一些其他代码。所有代码都在这里:

from math import log, sqrt
import random
import numpy as np
from copy import deepcopy


class BigGameState:
    def __init__(self):
        self.board = np.zeros((10, 10), dtype="int8")
        self.curr = 1
        self.playerJustMoved = 2 # At the root pretend the player just moved is player 2 - player 1 has the first move

    def Clone(self):
        """ Create a deep clone of this game state.
        """
        st = BigGameState()
        st.playerJustMoved = self.playerJustMoved
        st.curr = …
Run Code Online (Sandbox Code Playgroud)

python algorithm montecarlo monte-carlo-tree-search

5
推荐指数
1
解决办法
627
查看次数