Beispiel #1
0
def AIMove(board, type) :
    global moveList
    global outputFile
    global maxDepth

    #move = AI.decideMoveMinMax(board, maxDepth, type)
    move = AI.decideMoveAlphaBeta(board, maxDepth, type)

    boardNum = int(move[0])
    pos = int(move[2])
    boardRotate = move[4]
    rotateDir = move[5]

    board.addPiece(boardNum, pos, type)

    winCheck = board.checkWin()
    if (winCheck == -1) :
        if (rotateDir.lower() == 'l') :
            board.shiftLeft(int(boardRotate))
        else :
            board.shiftRight(int(boardRotate))
    moveList.append(move)
    outputFile.write(str(board) + "\n")
    outputFile.write(str(moveList) + "\n")

    print("AI move: " + str(move))
Beispiel #2
0
def testAI() :
    global maxDepth
    test = Board()

    # diagonal win configs
    
    test.addPiece(1, 1, 'w')
    test.addPiece(1, 5, 'b')
    test.addPiece(1, 2, 'w')

    """
    test.addPiece(1, 9, 'b')
    test.addPiece(4, 1, 'b')
    test.addPiece(4, 5, 'b')
    test.addPiece(4, 9, 'b')

    test.addPiece(2, 3, 'b')
    test.addPiece(2, 5, 'b')
    test.addPiece(2, 7, 'b')
    test.addPiece(3, 3, 'b')
    test.addPiece(3, 5, 'b')
    test.addPiece(3, 7, 'b')
    """

    test2 = test.copyBoard()

    test2.addPiece(1, 1, 'w')
    print(test)
    #print(test2)

    #AIMove(test, 'b')

    print(test)
    print(test.heuristicValue())
    AI.decideMoveAlphaBeta(test, maxDepth, 'b')
    print("Done!")