misc: cleanup debug

This commit is contained in:
2025-11-20 16:13:59 -05:00
Unverified
parent 3669a54eea
commit 11bfe07b68
2 changed files with 7 additions and 11 deletions

View File

@@ -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):