option = options.list[random.randrange(len(options.list))] game = stub.Process(option) game = stub.Reset(game_id) print("{0}th game is finished.".format(i + 1)) def random_games_mmf(server, deck, count): game = server.new_game(deck, deck) for i in range(count): while game.state != 3: options = server.options(game) option = options[random.randrange(len(options))] game = server.process(game, option) game = server.reset(game) print("{0}th game is finished.".format(i + 1)) import cProfile import cProfile import python_pb2_grpc import grpc import sabber_protocol.server server = sabber_protocol.server.SabberStoneServer() stats = cProfile.run('profiler.random_games_mmf(server, r"AAEBAf0EAA8MLU1xwwG7ApUDrgO/A4AEtATmBO0EoAW5BgA=", 100)') channel = grpc.insecure_channel('localhost:50052') stub = python_pb2_grpc.SabberStonePythonStub(channel) stats = cProfile.run('profiler.random_games_rpc(stub, r"AAEBAf0EAA8MLU1xwwG7ApUDrgO/A4AEtATmBO0EoAW5BgA=", 100)')
import grpc import abstract_ai import python_pb2_grpc as rpc from python_pb2 import Empty import random channel = grpc.insecure_channel("localhost:50052") stub = rpc.MatchServiceStub(channel) game_stub = rpc.SabberStonePythonStub(channel) account_name = "TestPythonRandomAI" deck = r"AAEBAQcCrwSRvAIOHLACkQP/A44FqAXUBaQG7gbnB+8HgrACiLACub8CAA==" matchserver_ip = "127.0.0.1" matchserver_port = 50051 ai = abstract_ai.RandomAI(stub, account_name) abstract_ai.start_ai_match(ai, matchserver_ip, matchserver_port, account_name, deck, game_stub)