misc: cleanup debug
This commit is contained in:
@@ -2,13 +2,12 @@ import asyncio
|
|||||||
|
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
async def calculate_move(opponent_move, board):
|
def calculate_move(opponent_move, board):
|
||||||
if opponent_move is not None:
|
if opponent_move is not None:
|
||||||
print(f"Opponent played column {opponent_move}")
|
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
|
# TODO: Implement your move calculation logic here instead
|
||||||
# Use the board variable to see and set the current state of the board
|
return 0
|
||||||
loop = asyncio.get_running_loop()
|
|
||||||
return int(await loop.run_in_executor(None, input, "Column: "))
|
|
||||||
|
|
||||||
|
|
||||||
async def gameloop(socket):
|
async def gameloop(socket):
|
||||||
@@ -23,7 +22,7 @@ async def gameloop(socket):
|
|||||||
case 'GAME':
|
case 'GAME':
|
||||||
if message[1] == 'START':
|
if message[1] == 'START':
|
||||||
if message[2] == '1':
|
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
|
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
|
if (message[1] == 'WINS') | (message[1] == 'LOSS') | (message[1] == 'DRAW') | (message[1] == 'TERMINATED'): # Game has ended
|
||||||
print(message[0]+":"+message[1])
|
print(message[0]+":"+message[1])
|
||||||
@@ -31,7 +30,7 @@ async def gameloop(socket):
|
|||||||
await socket.send('READY')
|
await socket.send('READY')
|
||||||
|
|
||||||
case 'OPPONENT': # Opponent has gone; calculate next move
|
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
|
await socket.send(f'PLAY:{col}') # Send your move to the sever
|
||||||
|
|
||||||
case 'ERROR':
|
case 'ERROR':
|
||||||
|
|||||||
@@ -517,9 +517,6 @@ async fn handle_connection(
|
|||||||
|
|
||||||
// TODO: Start tournaments
|
// TODO: Start tournaments
|
||||||
|
|
||||||
else if text == "PING" {
|
|
||||||
let _ = send(&tx, "PONG");
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
let _ = send(&tx, "ERROR:UNKNOWN");
|
let _ = send(&tx, "ERROR:UNKNOWN");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user