def run() -> None: game_state = connectfour_console.new_game() connectfour_UI.print_board(game_state) while connectfour_console.winner(game_state) == 0: game_state = read_move(game_state) connectfour_UI.print_board(game_state) connectfour_UI.print_game_over(game_state)
def play_AI(connection: ServerConnection, username: str): ''' Starts connect four game with server, creates a new game, and prints the winner ''' connectfour_network.send_message(connection, "I32CFSP_HELLO {}".format(username)) print(connectfour_network.receive_message(connection)) # WELCOME name connectfour_network.send_message(connection, "AI_GAME") game_mirror = connectfour_console.new_game() connectfour_UI.print_board(game_mirror) while connectfour_console.winner(game_mirror) == 0: message = read_move() if message == "!q": break else: if connectfour_network.receive_message(connection) == "READY": game_mirror = read_conversation(connection, message, game_mirror) connectfour_UI.print_game_over(game_mirror)
def print_game_over(game_state: GameState) -> None: ''' Prints game over message and who won ''' print("{} player won!".format(num_to_player(connectfour_console.winner(game_state)))) print(">> GAME OVER <<")