小编MTs*_*ang的帖子

Tic Tac Toe Python的Minimax算法

我有点理解minimax算法如何适用于Tic Tac Toe python,但我不知道如何在Python中实际编码...这是我到目前为止所做的:

from copy import deepcopy

class TicTacToeBrain :

    def __init__(self, player = "x") :
        self._squares = {}
        self._copySquares = {}
        self._winningCombos = (
        [0, 1, 2], [3, 4, 5], [6, 7, 8],
        [0, 3, 6], [1, 4, 7], [2, 5, 8],
        [0, 4, 8], [2, 4, 6])

    def createBoard(self) :
        for i in range(9) :
            self._squares[i] = None
        print(self._squares)

    def showBoard(self) :
        print(self._squares[0], self._squares[1], self._squares[2])
        print(self._squares[3], self._squares[4], self._squares[5])
        print(self._squares[6], self._squares[7], self._squares[8])

    def getAvailableMoves(self) :
        self._availableMoves = [] …
Run Code Online (Sandbox Code Playgroud)

python algorithm minimax

3
推荐指数
1
解决办法
6820
查看次数

标签 统计

algorithm ×1

minimax ×1

python ×1