def connection(self, button): # Handles GUI for button & either disconnects / connects to lobby if self.connect_button.get_stock_id() == gtk.STOCK_DISCONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) server_list = self.lobby_ini.sections() for i in range(0, len(server_list)): default = self.lobby_ini.get(server_list[i], 'Default', 'NO') if default == 'Yes': server = server_list[i] port = self.lobby_ini.getint(server_list[i], 'Port') self.username = self.lobby_ini.get(server_list[i], 'UserName') password = self.lobby_ini.get(server_list[i], 'UserPassword') break self.client = Lobby.client(self) self.client.connect(server, port, self.username, password) self.client.reLogin() elif self.connect_button.get_stock_id() == gtk.STOCK_CONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) self.client.disconnect('User') self.reintialise_server_variables() self.connect_button.set_stock_id(gtk.STOCK_DISCONNECT)
def register_account(self, server_address, server_port, username, encoded_password): if self.connect_button.get_stock_id() == gtk.STOCK_DISCONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) self.client = Lobby.client(self) self.client.connect(server_address, server_port, username, encoded_password) self.client.Register() elif self.connect_button.get_stock_id() == gtk.STOCK_CONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) self.client.disconnect('User') self.reintialise_server_variables() self.connect_button.set_stock_id(gtk.STOCK_DISCONNECT) self.client = Lobby.client(self) self.client.connect(server_address, server_port, username, encoded_password) self.client.Register() else: self.warning('Warning', 'Plz disconnect from lobby server & try again')
def connection(self, button): # Handles GUI for button & either disconnects / connects to lobby if self.connect_button.get_stock_id() == gtk.STOCK_DISCONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) server_list = self.lobby_ini.sections() for i in range(0,len(server_list)): default = self.lobby_ini.get(server_list[i], 'Default', 'NO') if default == 'Yes': server = server_list[i] port = self.lobby_ini.getint(server_list[i], 'Port') self.username = self.lobby_ini.get(server_list[i], 'UserName') password = self.lobby_ini.get(server_list[i], 'UserPassword') break self.client = Lobby.client(self) self.client.connect(server, port, self.username, password) self.client.reLogin() elif self.connect_button.get_stock_id() == gtk.STOCK_CONNECT: self.connect_button.set_stock_id(gtk.STOCK_EXECUTE) self.client.disconnect('User') self.reintialise_server_variables() self.connect_button.set_stock_id(gtk.STOCK_DISCONNECT)
def __init__(self, parent_window): #, table, lobby_ini, setup_ini, setup_profile): # Initialize variables self.username = '' self.server_agreement = '' # Channels self.lobby_channel_vpanes = [] self.lobby_channel_names = [] self.lobby_channel_buffers = [] self.lobby_channel_textview = [] self.lobby_channel_users = [] self.lobby_channel_users_cells = [] self.lobby_channel_users_columns = [] # Pm's self.lobby_pm_vpanes = [] self.lobby_pm_names = [] self.lobby_pm_buffers = [] self.lobby_pm_textview = [] self.lobby_pm_users = [] self.lobby_pm_users_cells = [] self.lobby_pm_users_columns = [] self.window = parent_window.window self.lobby_ini = parent_window.lobby_ini self.lobby_ini_file = parent_window.lobby_ini_file self.ini = parent_window.ini self.setup_profile = parent_window.profile self.unity_location = self.ini.get(self.setup_profile, 'UNITY_INSTALL_DIR') # GUI table = parent_window.lobby_table # User ListStore # 0 Username # 1 Country # 2 Cpu # 3 IP # 4 Status -> InGame / Away # 5 Rank # 6 Moderator self.user_liststore = gtk.ListStore(str, gtk.gdk.Pixbuf, str, str, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) self.country_flags = {} self.rank_images = {} self.status_images = {} # Lobby Notebook self.lobby_notebook = gtk.Notebook() self.lobby_notebook.set_tab_pos(gtk.POS_LEFT) self.lobby_notebook.show() table.attach(self.lobby_notebook,0,1,1,2) gtk.threads_leave() self.create_channel('$local', False) gtk.threads_enter() self.connect_button = gtk.ToolButton(gtk.STOCK_DISCONNECT) self.connect_button.connect("clicked", self.connection) self.connect_button.show() self.preferences_button = gtk.ToolButton(gtk.STOCK_PREFERENCES) self.preferences_button.connect("clicked", self.preferences) self.preferences_button.show() toolbar = gtk.Toolbar() toolbar.insert(self.connect_button, 0) toolbar.insert(self.preferences_button, 1) toolbar.set_style(gtk.TOOLBAR_ICONS) toolbar.show() table.attach(toolbar,0,1,0,1, gtk.FILL, gtk.FILL,0,0) Lobby.client(self)
import socket import threading import time import Lobby #Edit these host and port to change where the server runs on; leave host blank if you want it to run on local host HOST = "10.220.82.180" PORT = 255 lobby = Lobby.Lobby() #This class get incoming connection and put them intot the server class Receiver(): #construtor def __init__(self, host, port, lobby): self.host = host self.port = port self.lobby = lobby self.serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.serverSocket.bind((self.host, self.port)) newLobby = threading.Thread(target=lobby.run) newLobby.start() print("The server is ready to receive...") #this will listen for new clients and creates a new thread for that client def listen(self): self.serverSocket.listen(3) while (True): client, addr = self.serverSocket.accept() newThread = threading.Thread(target=self.ClientController,
model The model for the function to train Returns ------- model The newly trained model """ pass ### End of Abstract methods """ Make a test Agent and run it through one training run on single player mode of streetfighter """ if __name__ == "__main__": parser = argparse.ArgumentParser(description='Processes agent parameters.') parser.add_argument( '-r', '--render', action='store_true', help= 'Boolean flag for if the user wants the game environment to render during play' ) args = parser.parse_args() import Lobby testLobby = Lobby.Lobby(mode=Lobby.Lobby_Modes.SINGLE_PLAYER) agent = HumanAgent() testLobby.addPlayer(agent) testLobby.executeTrainingRun(render=True)
def __init__( self, parent_window): #, table, lobby_ini, setup_ini, setup_profile): # Initialize variables self.username = '' self.server_agreement = '' # Channels self.lobby_channel_vpanes = [] self.lobby_channel_names = [] self.lobby_channel_buffers = [] self.lobby_channel_textview = [] self.lobby_channel_users = [] self.lobby_channel_users_cells = [] self.lobby_channel_users_columns = [] # Pm's self.lobby_pm_vpanes = [] self.lobby_pm_names = [] self.lobby_pm_buffers = [] self.lobby_pm_textview = [] self.lobby_pm_users = [] self.lobby_pm_users_cells = [] self.lobby_pm_users_columns = [] self.window = parent_window.window self.lobby_ini = parent_window.lobby_ini self.lobby_ini_file = parent_window.lobby_ini_file self.ini = parent_window.ini self.setup_profile = parent_window.profile self.unity_location = self.ini.get(self.setup_profile, 'UNITY_INSTALL_DIR') # GUI table = parent_window.lobby_table # User ListStore # 0 Username # 1 Country # 2 Cpu # 3 IP # 4 Status -> InGame / Away # 5 Rank # 6 Moderator self.user_liststore = gtk.ListStore(str, gtk.gdk.Pixbuf, str, str, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf, gtk.gdk.Pixbuf) self.country_flags = {} self.rank_images = {} self.status_images = {} # Lobby Notebook self.lobby_notebook = gtk.Notebook() self.lobby_notebook.set_tab_pos(gtk.POS_LEFT) self.lobby_notebook.show() table.attach(self.lobby_notebook, 0, 1, 1, 2) gtk.threads_leave() self.create_channel('$local', False) gtk.threads_enter() self.connect_button = gtk.ToolButton(gtk.STOCK_DISCONNECT) self.connect_button.connect("clicked", self.connection) self.connect_button.show() self.preferences_button = gtk.ToolButton(gtk.STOCK_PREFERENCES) self.preferences_button.connect("clicked", self.preferences) self.preferences_button.show() toolbar = gtk.Toolbar() toolbar.insert(self.connect_button, 0) toolbar.insert(self.preferences_button, 1) toolbar.set_style(gtk.TOOLBAR_ICONS) toolbar.show() table.attach(toolbar, 0, 1, 0, 1, gtk.FILL, gtk.FILL, 0, 0) Lobby.client(self)
def __init__(self, players, roundsToRun=-1, reviewGames=True, viewGames=True, verbose=False): """ Initializes the Game Master who will organize and execute matches between the players Parameters ---------- players List of the player Agents participating in the tournament roundsToRun Int representing the number of rounds played, i.e. how many matches each Agent will play Setting this to -1 will make the tournament go on indefinitely reviewGames Bool representing if the fighters will train after each match viewGames Bool representing if the environment will be rendered while playing verbose Bool that turns on or off print statements during execution Returns ------- None """ assert (isinstance(players, (list, tuple))) assert (all([ player.__repr__() == "Agent" or issubclass(player.__class__, Agent.Agent) for player in players ])) assert (isinstance(roundsToRun, int)) assert (isinstance(reviewGames, bool)) assert (isinstance(viewGames, bool)) assert (isinstance(verbose, bool)) self.numLobbies = int( len(players) / 2) # Make enough lobbies to hold all the players at once self.openLobbies = [ Lobby.Lobby(mode=Lobby.Lobby_Modes.TWO_PLAYER) for i in range(self.numLobbies) ] self.closedLobbies = [] self.players = players self.waitingPlayers = [player for player in self.players] self.playersInGame = [] self.pauseTournament = False self.endTournament = False self.roundsToRun = roundsToRun # -1 as default makes it so the tournament runs forever self.roundsRun = 0 self.reviewGames = reviewGames self.viewGames = viewGames self.verbose = verbose super(GameMaster, self).__init__() self.daemon = True