From 11bfe07b68e26d14d824748f88de0e1cfd87b163 Mon Sep 17 00:00:00 2001 From: Joshua Higgins Date: Thu, 20 Nov 2025 16:13:59 -0500 Subject: [PATCH] misc: cleanup debug --- example_client.py | 13 ++++++------- src/main.rs | 5 +---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/example_client.py b/example_client.py index 6ef0308..ff8686d 100644 --- a/example_client.py +++ b/example_client.py @@ -2,13 +2,12 @@ import asyncio import websockets -async def calculate_move(opponent_move, board): +def calculate_move(opponent_move, board): if opponent_move is not None: print(f"Opponent played column {opponent_move}") + # TODO: Use the board variable to see and set the current state of the board # TODO: Implement your move calculation logic here instead - # Use the board variable to see and set the current state of the board - loop = asyncio.get_running_loop() - return int(await loop.run_in_executor(None, input, "Column: ")) + return 0 async def gameloop(socket): @@ -23,7 +22,7 @@ async def gameloop(socket): case 'GAME': if message[1] == 'START': if message[2] == '1': - col = await calculate_move(None, board) # calculate_move is some arbitrary function you have created to figure out the next move + col = calculate_move(None, board) # calculate_move is some arbitrary function you have created to figure out the next move await socket.send(f'PLAY:{col}') # Send your move to the sever if (message[1] == 'WINS') | (message[1] == 'LOSS') | (message[1] == 'DRAW') | (message[1] == 'TERMINATED'): # Game has ended print(message[0]+":"+message[1]) @@ -31,12 +30,12 @@ async def gameloop(socket): await socket.send('READY') case 'OPPONENT': # Opponent has gone; calculate next move - col = await calculate_move(message[1], board) # Give your function your opponent's move + col = calculate_move(message[1], board) # Give your function your opponent's move await socket.send(f'PLAY:{col}') # Send your move to the sever case 'ERROR': print(f"{message[0]}: {':'.join(message[1:])}") - + await socket.close() async def join_server(username): diff --git a/src/main.rs b/src/main.rs index 93d373d..271e785 100644 --- a/src/main.rs +++ b/src/main.rs @@ -516,10 +516,7 @@ async fn handle_connection( } // TODO: Start tournaments - - else if text == "PING" { - let _ = send(&tx, "PONG"); - } + else { let _ = send(&tx, "ERROR:UNKNOWN"); }