它是對一類有隨機算法特性的歸納. 是一種使用隨機方法的統計.html
相似於抽樣調查, 雖沒法保證最優解, 但也是近似解.python
<蒙特卡羅方法入門>, 這篇文章不錯, 經過幾個例子讓你更加了解此方法的原理.git
全稱 Monte Carlo Tree Searchgithub
使用蒙特卡羅方法對樹進行搜索, 是一種人工智能問題中作出最優決策的方法.通常用於組合博弈中的行動規劃.算法
全稱 The Upper Confidence BoundAlgorithmapp
UCB1算法以下, ide
其中 v 是節點估計的值,n 是節點被訪問的次數,而 N 則是其父節點已經被訪問的總次數。C 是可調整參數。函數
更多細節可參考 <UCB算法> , 文章寫得不錯學習
全稱 Upper Confidence Bounds for Trees測試
是經過UCB算法進行的樹搜索
UCT 能夠被描述爲 MCTS 的一個特例, 即 UCT = MCTS + UCB, 後面介紹MCTS即指UCT算法.
在GitHub下載 mittmcts.
介紹一下, 使用方法,
首先定義Game類, 實現特定函數
class Game(object): @classmethod def initial_state(cls): return state # 返回初始狀態 @classmethod # 參數: 傳入此類名, 當前的狀態, 下一步 # 返回值: 走了step這步後的狀態 def apply_move(cls, state, step): return state @staticmethod # 參數: 傳入狀態信息 # 返回值: (是否不隨機選擇, 全部可能的下一步棋) def get_moves(state): return False, choices @staticmethod # 返回值: 此情況下的獲勝者, 若是平局, 則返回mittmcts.Draw, 若是沒有結局, 則返回None def get_winner(state): return state.winner @staticmethod # 返回值: 當前執行者 def current_player(state): return state.current_player
而後, 經過MCTS獲得計算結果
from mittmcts import MCTS def main(): result = (MCTS(Game) .get_simulation_result(1000)) # 測試1000次, 獲得結果 move = result.move # 下一步
轉自: http://www.gcsjj.cn/articles/2019/04/20/1555740616718.html