Esempio n. 1
0
def setup_match():
    #get games from mongodb
    games = mongo.db.AISinglePlayer
    game = Game()
    #Interesting safari test situation
    if '=' in game.gameID:
        game.gameID = game.gameID.replace('=', '')
    game.playerColor = 'white'  #means black is AI color

    dictGame = game.__dict__
    print(dictGame)
    games.insert(dictGame)
    return jsonify({'color': game.playerColor, 'id': game.gameID}), 201
Esempio n. 2
0
def testAI():
    game_test = Game()
    game_test.playerColor = 'white'
    board_test = []
    for x in range(0, 19):
        board_test.append([''] * 19)

    game_test.board = board_test
    game_test.move = 4
    board_test[0][0] = 'white'
    board_test[1][1] = 'white'
    board_test[2][2] = 'white'
    board_test[3][3] = 'white'
    ''' board_test[16][17] = 'black'
    board_test[15][18] = 'black'
    board_test[18][1] = 'black'
    board_test[18][2] = 'black' '''

    game_test.board = board_test

    comp_row, comp_col = game_test.makeAIMove(5, 6)
    print(board_test)
    return jsonify({'comp_row': comp_row, 'comp_col': comp_col}), 200