예제 #1
0
from mock.tools import Tools
import os
import sys

sys.path.append(os.path.abspath('../tic-tac-toe-thegame'))
from tictactoe import TicTacToe

__author__ = 'phizaz'

bot_desc = {
    'name': 'BotRLBetterDiscovery',
    'exploratory': 1,
    'rounds': 100000,
}

bot = Bot(name=1, q_table=Tools.load_source(bot_desc))
# bot starts first, but alternatively afterwards
start_turn = bot.name
while True:
    game = TicTacToe()
    game.restart(start=start_turn)
    whose_turn = start_turn
    start_turn = start_turn % 2 + 1
    print('game start : ')
    while True:
        if whose_turn is bot.name:
            # bot action
            action = bot.take_turn(game.table)
        else:
            # user action
            action = (int(input('row:')),
예제 #2
0
sys.path.append(os.path.abspath("../tic-tac-toe-thegame"))
from tictactoe import TicTacToe

# import the game from another project
import json
import time
import tictactoebot
import environment
import player

num_workers = max(multiprocessing.cpu_count() // 2, 1)

experiments = [
    {"name": "BotSimpleRL", "bot": tictactoebot.BotSimpleRL, "rounds": rounds, "exploratory": exploratory}
    for rounds, exploratory in Tools.cartesian_product(
        [3 ** power * 10000 for power in range(0, 6)], [i / 10 for i in range(1, 10 + 1)]
    )
] + [
    {
        "name": "BotRLBetterDiscovery",
        "bot": tictactoebot.BotRLBetterDiscovery,
        "rounds": rounds,
        "exploratory": exploratory,
    }
    for rounds, exploratory in Tools.cartesian_product(
        [3 ** power * 10000 for power in range(0, 6)], [i / 10 for i in range(1, 10 + 1)]
    )
]


def instance(name, bot, exploratory, rounds):