-
Notifications
You must be signed in to change notification settings - Fork 5
/
logic.py
32 lines (26 loc) · 1.06 KB
/
logic.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# not all imports are currently used, but they might be in the future and it shows all available functionalities
import math
import random
import time
from typing import Optional, Tuple
from socha import (
Field,
GameState,
Move
)
from socha.api.networking.game_client import IClientHandler
from socha.starter import Starter
class Logic(IClientHandler):
game_state: GameState
# this method is called every time the server is requesting a new move
# this method should always be implemented otherwise the client will be disqualified
def calculate_move(self) -> Move:
return random.choice(self.game_state.possible_moves())
# this method is called every time the server has sent a new game state update
# this method should be implemented to keep the game state up to date
def on_update(self, state: GameState) -> None:
self.game_state = state
if __name__ == "__main__":
Starter(logic=Logic())
# if u wanna have more insights, u can set the logging level to debug:
# Starter(logic=Logic(), log_level=logging.DEBUG)