def client_reset(self, u: str, AI, logger, pos): self.username = u # create a gRPC channel + stub channel = grpc.insecure_channel(address + ':' + str(port)) self.conn = rpc.GameStub(channel) self.ai = AI self._lock = threading.Lock() self._decision_so_far = [ ] # history of the decision info from the server self._new_response = [] # response list from the server self._new_request = [] # request list waiting to send to the server self.mypos = pos self.initMoney = -1 self.bigBlind = -1 self.totalPlayer = -1 self.button = -1 self.logger = logger self.step = -1 if self.logger is None: self.logger = simple_logger() self.state = State(self.logger, self.totalPlayer, self.initMoney, self.bigBlind, self.button) self.initialized = False self.stoped = False self.round = 0 self.allowheartbeat = True self.heartbeaklock = threading.Lock()
class ClientJob(object): def __init__(self, c): self.client = c def run(self): # print('run for client:%d'%(self.client.mypos)) client_start(self.client) #**********************************NOTICE************************************** # You should make sure that your username is unique and can only contain letters, numbers and '_'. # You should never keep more than one connection to the server at the same time. #****************************************************************************** if __name__ == '__main__': # ************************************ modify here to use your own username! *********************** # if len(sys.argv) == 1: # print('Error: enter the name for the client!') username = '******' # sys.argv[1] # username = "******" logger = simple_logger() # **************************************************************************************************** # ************************************ modify here to use your own AI! ******************************** c = Client(username, ai(), logger) ClientJob(c).run()