def insert_unit(self, token, prev_unit_id=None, prob=1.0): """Inserts a new token, possibly connected to a previous unit, with a particular probability value.""" if prev_unit_id: prev_unit = self.units[prev_unit_id] prev_state_unit = [ x for x in self.units.values() if x.grounded_in == prev_unit ][0] else: prev_unit, prev_state_unit = None, None new_unit = IUnit("token", token, previous=prev_unit) self.units[new_unit.id] = new_unit if prev_state_unit is None: previous_state = np.zeros(30) else: previous_state = prev_state_unit.payload encoded_token = utils.encode_token(token) incremental_inputs = [ np.reshape(np.array([encoded_token]), (1, 1)), np.reshape(previous_state, (1, len(previous_state))) ] new_state = self.neural_model.predict(incremental_inputs)[0] if prob < 1.0: new_state = (1 - prob) * previous_state + prob * new_state new_state_unit = IUnit("state", new_state, previous=prev_state_unit, grounded_in=new_unit) self.units[new_state_unit.id] = new_state_unit return new_unit.id
def __get_request_token(user): payload = { "username": user.username, "is_active": user.is_active, "is_admin": user.is_admin, "full_name": user.full_name, "sex": user.sex, "time": time.time(), "id": user.id } token = encode_token(payload) result = { "success": True, "code": 200, "message": u"登录成功", "token": token, # "token": 'Token {}'.format(token.key), "details": payload } return result
def main(screen=None, color_count=None, max_attempts=None, code_length=None): if screen is None: try: token = curses.wrapper( main ) # Use curses to handle user input, screen clearing and simplify other display management tools if token is not None: # If the game has been interrupted and a token to resume was generated, show a message to inform the user print( "This game has been interrupted. To resume, copy paste this token:", token) except KeyboardInterrupt: pass except Exception as e: if utils.DEBUG: traceback.print_exc() else: print("Oops! An error occured:", e) return curses.start_color() # Enable curses' colors curses.use_default_colors() curses.curs_set( 0 ) # Hide the cursor as we will use a custom way to show the selected color if color_count is None or color_count <= 0: color_count = utils.DEFAULT_COLOR_COUNT if max_attempts is None or max_attempts <= 0: max_attempts = utils.DEFAULT_MAX_ATTEMPTS if code_length is None or code_length <= 0: code_length = utils.DEFAULT_CODE_LENGTH global score, games score, games = 0, 0 code, attempts = None, None # Create a token containing the settings requested by the user token = utils.encode_token(1, score, games, color_count, max_attempts, [0xFFFF] * code_length, []) global client_socket, line username = "" initialized, first = False, True while True: # Play an infinite number of games until the user quits the program (with Ctrl+C) if client_socket is None: # If the client isn't connected to the server yet, connect to it screen.clear() screen.addstr("Connecting to the server, please wait...\n\r") screen.refresh( ) # Refresh the screen, because the following code could block for a few seconds try: client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) client_socket.connect( (utils.SERVER_HOST, utils.SERVER_PORT)) # Connect to socket server client_socket.settimeout( 2 ) # Let the server 2 seconds to understand our request and answer it, or disconnect except socket.error as e: screen.clear() raise Exception( "Failed to connect to server. Please try again later.") # TODO: GDPR Prompt utils.send_packet(client_socket, "OK".encode("utf8")) while not initialized: # While the game hasn't fully been created and started on the server, don't start it locally try: status = int.from_bytes(utils.receive_packet(client_socket), "big") if status == 401 or status == 403: # Status 401: Unknown user; Status 403: Unknown user, username provided taken username = "" while not username: screen.clear() screen.addstr( "Please enter a username which will represent you in the Online Ranked Games scoreboard.\n\r" ) screen.addstr( "WARNING: This username CAN NOT BE CHANGED and will be linked to your address. It must be UNIQUE.\n\r" ) screen.addstr("\n\r") screen.addstr("Username: \n\r") if status == 403: screen.addstr( "Invalid username. Please try again.") curses.curs_set(2) curses.echo() username = screen.getstr(3, 10).decode("utf8") curses.noecho() curses.curs_set(0) screen.clear() screen.addstr("Registering new user, please wait...\n\r") screen.refresh() utils.send_packet(client_socket, username.encode("utf8")) elif status == 204: # Status 204: Known user, no game started if not username: username = utils.receive_packet(client_socket).decode( "utf8") if not first: display_scoreboard(screen) screen.clear() screen.addstr( "Initializing new Online Ranked Game, please wait...\n\r" ) screen.refresh() utils.send_packet( client_socket, token.encode("utf8") ) # Send the token containing all the settings requested by the user to the server elif status == 200: # Status 200: Known user, game pending if not username: username = utils.receive_packet(client_socket).decode( "utf8") token = utils.receive_packet(client_socket).decode("utf8") # Get all the required information about the game from the server _, score, games, color_count, max_attempts, code, attempts = utils.decode_token( token) code_length = len(code) curses.init_pair(0, -1, utils.find_nearest_color(0, 0, 0)) curses.init_pair(1, -1, utils.find_nearest_color(1, 1, 1)) for color in range( 2, color_count + 2 ): # Initialize all the colors we will need, generating them around the color wheel # Each color is uniformly spread around the color spectrum, keeping its saturation and value to the max (excludes black and white) h, s, v = (color - 2) / color_count, 1.0, 1.0 r, g, b = colorsys.hsv_to_rgb( h, s, v ) # Convert the color from HSV (easier to generate) to RGB (easier to manipulate) # Because we can't use custom colors in most terminals, we find the closest available one and pair it to the color's id with a white foreground curses.init_pair(color, -1, utils.find_nearest_color(r, g, b)) initialized = True break elif status == 409: # Status 409: Known user, game already running screen.clear() raise Exception( "A user is already playing an Online Ranked Game from this address." ) elif not status: screen.clear() raise Exception( "Server disconnected unexpectedly. Please try again later." ) else: screen.clear() raise Exception( "Unknown status {} returned by server.".format(status)) except socket.timeout: pass screen.clear() line = 0 first = False try: if code is None: code = [0xFFFF] * code_length if attempts is None: attempts = [] game_score = play_game(screen, color_count, max_attempts, code, attempts) code, attempts = None, None # Reset the code and the attempts to make the next game independent except KeyboardInterrupt: screen.move(line, 0) screen.clrtoeol( ) # Clear the current line, just in case some text was there token = utils.encode_token(1, score, games, color_count, max_attempts, code, attempts) return token if game_score > 0: score += game_score # If the user won this game, we increment his score and the number of (consecutive) games he played games += 1 else: score, games = 0, 0 # If he lost, we reset his score and the number of (consecutive) games initialized = False
def main(screen=None, color_count=None, max_attempts=None, score=0, games=0, code=None, attempts=None): if screen is None: try: token = curses.wrapper( main ) # Use curses to handle user input, screen clearing and simplify other display management tools if token is not None: # If the game has been interrupted and a token to resume was generated, show a message to inform the user print( "This game has been interrupted. To resume, copy paste this token:", token) except KeyboardInterrupt: pass except Exception as e: if utils.DEBUG: traceback.print_exc() else: print("Oops! An error occured:", e) return curses.start_color() # Enable curses' colors curses.use_default_colors() curses.curs_set( 0 ) # Hide the cursor as we will use a custom way to show the selected color code_length = len(code) if code is not None else utils.DEFAULT_CODE_LENGTH if color_count is None or color_count <= 0: color_count = utils.DEFAULT_COLOR_COUNT if max_attempts is None or max_attempts <= 0: max_attempts = utils.DEFAULT_MAX_ATTEMPTS curses.init_pair(0, -1, utils.find_nearest_color(0, 0, 0)) curses.init_pair(1, -1, utils.find_nearest_color(1, 1, 1)) for color in range( 2, color_count + 2 ): # Initialize all the colors we will need, generating them around the color wheel # Each color is uniformly spread around the color spectrum, keeping its saturation and value to the max (excludes black and white) h, s, v = (color - 2) / color_count, 1.0, 1.0 r, g, b = colorsys.hsv_to_rgb( h, s, v ) # Convert the color from HSV (easier to generate) to RGB (easier to manipulate) # Because we can't use custom colors in most terminals, we find the closest available one and pair it to the color's id with a white foreground curses.init_pair(color, -1, utils.find_nearest_color(r, g, b)) global line while True: # Play an infinite number of games until the user quits the program (with Ctrl+C) screen.clear() line = 0 try: if code is None: code = utils.generate_code( code_length, color_count ) # Generate a random code to "play against the computer" if attempts is None: attempts = [] game_score = play_game(screen, color_count, max_attempts, code, attempts) code, attempts = None, None # Reset the code and the attempts to make the next game independent except KeyboardInterrupt: screen.move(line, 0) screen.clrtoeol( ) # Clear the current line, just in case some text was there if games > 0: screen.addstr("Average score: {}\n\r".format(score / games)) screen.refresh() curses.napms(3000) token = utils.encode_token(2, score, games, color_count, max_attempts, code, attempts) return token if game_score > 0: score += game_score # If the computer won this game, we increment his score and the number of (consecutive) games he played games += 1 if game_score <= 0: score, games = 0, 0 # If he lost, we reset his score and the number of (consecutive) games
def tick_client(conn, address, data, user_list, scoreboard): try: buff = data["inputs"].pop( 0) if data["inputs"] else utils.receive_packet(conn) if buff: if data["status"] == 200: game = user_list[address[0]]["game"] guess = [0xFFFF] * len(game["code"]) for i in range(len(game["code"])): guess[i] = int.from_bytes(buff[2 * i:2 * (i + 1)], "big") perfect, partial = utils.compare_codes(guess, game["code"]) if game["color_count"] == 6 and len( game["code"]) == 4 and guess == [0, 1, 0, 0]: utils.send_packet(conn, (418).to_bytes(2, "big")) utils.send_packet( conn, perfect.to_bytes(2, "big") + partial.to_bytes(2, "big")) if perfect == len(game["code"]): game["score"] += game["max_attempts"] - len( game["attempts"]) game["games"] += 1 game["code"] = utils.generate_code(len(game["code"]), game["color_count"]) game["attempts"] = [] if utils.DEBUG: print("Client {}:{} won a game on thread #{}.".format( *address, thread.ident)) else: game["attempts"].append(guess) if len(game["attempts"]) >= game["max_attempts"]: token = utils.encode_token( game["gamemode"], game["score"], game["games"], game["color_count"], game["max_attempts"], game["code"], game["attempts"]) utils.send_packet(conn, token.encode("utf8")) total_attempts = (game["max_attempts"] + 1) * game["games"] - game["score"] normalized_score = game["score"] normalized_score *= game["color_count"]**len( game["code"]) / 1000 normalized_score /= 1.2**game["max_attempts"] / 10 normalized_score = int(normalized_score) entry = (address[0], user_list[address[0]]["username"], game["score"], game["games"], total_attempts, normalized_score, game["color_count"], len(game["code"]), game["max_attempts"], time.time()) for i, other in enumerate(scoreboard): if other[5] < entry[5] or ( other[5] == entry[5] and other[3] < entry[3] or (other[3] == entry[3] and other[4] > entry[4])): scoreboard.insert(i, entry) break else: scoreboard.append(entry) del user_list[address[0]]["game"] user_list[address[0]]["connected"] = False data["status"] = 204 utils.send_packet(conn, data["status"].to_bytes(2, "big")) if utils.DEBUG: print("Client {}:{} lost a game on thread #{}.". format(*address, thread.ident)) elif address[0] in user_list and "connected" in user_list[ address[0]] and user_list[address[0]]["connected"]: data["status"] = 409 utils.send_packet(conn, data["status"].to_bytes(2, "big")) conn.close() if utils.DEBUG: print( "Client {}:{} forcefully disconnected from thread #{}." .format(*address, thread.ident)) return False elif data["status"] == 204: token = buff.decode("utf8") if re.match(r"^SB:\d+ \d+$", token): page_size, offset = map(int, token[3:].split()) answer_bytes = bytes() if len(scoreboard) >= offset: for entry in scoreboard[ offset:min(offset + page_size, len(scoreboard))]: username = entry[1].encode("utf8") if 6 + len(answer_bytes) + len( username) + 6 > 65535: break answer_bytes += (min(len(username), 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += username answer_bytes += (min(entry[5], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += (min(entry[3], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += (min(entry[4], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += (min(entry[4], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += (min(entry[5], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += (min(entry[6], 0xFFFF) & 0xFFFF).to_bytes(2, "big") answer_bytes += ( min(int(entry[8] * 1000), 2**64 - 1) & 2**64 - 1).to_bytes(8, "big") utils.send_packet(conn, answer_bytes) else: gamemode, score, games, color_count, max_attempts, code, attempts = utils.decode_token( token) score, games = 0, 0 code = utils.generate_code(len(code), color_count) user_list[address[0]]["connected"] = True game = { "gamemode": gamemode, "score": score, "games": games, "color_count": color_count, "max_attempts": max_attempts, "code": code, "attempts": [] } user_list[address[0]]["game"] = game if len(attempts) > max_attempts: attempts = attempts[:max_attempts] for attempt in attempts: attempt_bytes = bytes() if len(attempt) > len(code): attempt = attempt[:len(code)] elif len(attempt) < len(code): attempt += [0] * (len(code) - len(attempt)) for color in attempt: attempt_bytes += (min(color, 0xFFFF) & 0xFFFF).to_bytes(2, "big") data["inputs"].append(attempt_bytes) if attempt == code: break data["status"] = 200 utils.send_packet(conn, data["status"].to_bytes(2, "big")) fake_code = [0xFFFF] * len(game["code"]) fake_token = utils.encode_token(game["gamemode"], game["score"], game["games"], game["color_count"], game["max_attempts"], fake_code, attempts) utils.send_packet(conn, fake_token.encode("utf8")) if utils.DEBUG: print("Client {}:{} started a new game on thread #{}.". format(*address, thread.ident)) elif data["status"] == 401 or data["status"] == 403: username = buff.decode("utf8") if buff == b"\x36\x39": for chars in itertools.product(*[ [ b"\x4e", b"\x6e", b"\xc3\xb1", b"\xc5\x84", b"\xc3\x91", b"\xc5\x83" ], [ b"\x69", b"\x49", b"\xc3\xae", b"\xc3\xaf", b"\xc3\xac", b"\xc3\xad", b"\xc4\xaf", b"\xc4\xab", b"\xc3\x8e", b"\xc3\x8f", b"\xc3\x8c", b"\xc3\x8d", b"\xc4\xae", b"\xc4\xaa" ], [ b"\x63", b"\x43", b"\xc3\xa7", b"\xc4\x87", b"\xc4\x8d", b"\xc3\x87", b"\xc4\x86", b"\xc4\x8c" ], [ b"\x65", b"\x45", b"\xc3\xa9", b"\xc3\xa8", b"\xc3\xaa", b"\xc3\xab", b"\xc4\x99", b"\xc4\x97", b"\xc4\x93", b"\xc3\x89", b"\xc3\x88", b"\xc3\x8a", b"\xc3\x8b", b"\xc4\x98", b"\xc4\x96", b"\xc4\x92" ] ]): username = "".join( map(lambda x: x.decode("utf8"), chars)) for other_address in user_list: if username == user_list[other_address][ "username"]: data["status"] = 403 utils.send_packet( conn, data["status"].to_bytes(2, "big")) break else: break else: username = "" if 3 <= len(username) <= 32 and set( username) <= USERNAME_CHARACTERS: for other_address in user_list: if username == user_list[other_address]["username"]: data["status"] = 403 utils.send_packet( conn, data["status"].to_bytes(2, "big")) break else: user_list[address[0]] = {"username": username} data["status"] = 204 utils.send_packet(conn, data["status"].to_bytes(2, "big")) else: data["status"] = 403 utils.send_packet(conn, data["status"].to_bytes(2, "big")) elif data["status"] == 300: if buff.decode("utf8") == "OK": if address[0] in user_list: if not "connected" in user_list[address[ 0]] or not user_list[address[0]]["connected"]: if "game" in user_list[address[0]] and user_list[ address[0]]["game"] is not None: game = user_list[address[0]]["game"] user_list[address[0]]["connected"] = True attempts = game["attempts"] game["attempts"] = [] if len(attempts) > game["max_attempts"]: attempts = attempts[:game["max_attempts"]] for attempt in attempts: attempt_bytes = bytes() if len(attempt) > len(game["code"]): attempt = attempt[:len(game["code"])] elif len(attempt) < len(game["code"]): attempt += [0] * (len(game["code"]) - len(attempt)) for color in attempt: attempt_bytes += (min(color, 0xFFFF) & 0xFFFF).to_bytes( 2, "big") data["inputs"].append(attempt_bytes) if attempt == game["code"]: break data["status"] = 200 utils.send_packet( conn, data["status"].to_bytes(2, "big")) utils.send_packet( conn, user_list[address[0]] ["username"].encode("utf8")) fake_code = [0xFFFF] * len(game["code"]) fake_token = utils.encode_token( game["gamemode"], game["score"], game["games"], game["color_count"], game["max_attempts"], fake_code, attempts) utils.send_packet(conn, fake_token.encode("utf8")) if utils.DEBUG: print( "Client {}:{} resumed a game on thread #{}." .format(*address, thread.ident)) else: data["status"] = 204 utils.send_packet( conn, data["status"].to_bytes(2, "big")) utils.send_packet( conn, user_list[address[0]] ["username"].encode("utf8")) else: data["status"] = 409 utils.send_packet( conn, data["status"].to_bytes(2, "big")) conn.close() if utils.DEBUG: print( "Client {}:{} forcefully disconnected from thread #{}." .format(*address, thread.ident)) return False else: data["status"] = 401 utils.send_packet(conn, data["status"].to_bytes(2, "big")) return True except socket.error as e: if hasattr(e, "skipped_data"): data = e.skipped_data if data.decode("utf8").startswith("GET "): data += conn.recv(65536 - len(e.skipped_data)) if re.match(r"^GET .*? HTTP/\d+(?:\.\d+)*\r\n", data.decode("utf8")): conn.send( base64.b64decode( "SFRUUC8xLjEgMjAwIE9LDQpDb250ZW50LVR5cGU6aW1hZ2UvZ2lmDQpDb25uZWN0aW9uOmNsb3NlZA0KDQpHSUY4OWEQAA4A8gAA/wEqFf5J4esIoOc5K+7IycenAAAAAAAAIfkECQQAAAAh/hlPcHRpbWl6ZWQgdXNpbmcgZXpnaWYuY29tACH/C05FVFNDQVBFMi4wAwEAAAAh/wt4bXAgZGF0YXhtcP8/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG10YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS4zLWMwMTEgNjYuMTQ1NjYxLCAyMDEyLzAyLzA2LTE0OjU2OjI3ICAgICAgICAiPjxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53Lm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZjphYm91dD0iIiD/eG1sbnM6eG1wPSJodHRwOi8vbnMuYWRv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190Gu+EazqatAAAAAAAAAzsIugxTjREBByEwDlummJGzeRTYjML3TdliXWRKNMEbX/T2ysTADIEa7ML5BYM6XQt4bCIVOqdUJJ0CEgAh+QQFBAAAACwAAAAAEAAOAIIAAAD+QwQm/hsI/l3D2R1G7r8AAAAAAAADPwi63K5lifHULFjgSrT4Q+gQHTiAEUN+aDE1pRZmAhyH4WfH7KuSvE5KQQoEgEjComhsIlPIphFJJBylThIgAQA7" )) conn.close() if utils.DEBUG: print("Client {}:{} disconnected from thread #{}.". format(*address, thread.ident)) return False if e.errno == errno.EWOULDBLOCK: return True elif utils.DEBUG: traceback.print_exc() else: print(e) except Exception as e: if utils.DEBUG: traceback.print_exc() else: print(e) pass conn.close() if address[0] in user_list and "connected" in user_list[ address[0]] and user_list[address[0]]["connected"]: user_list[address[0]]["connected"] = False if utils.DEBUG: print("Client {}:{} disconnected from thread #{}.".format( *address, thread.ident)) return False