-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomLogic.py
55 lines (47 loc) · 1.48 KB
/
randomLogic.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import logging
import random
from typing import List
# not all imports are currently used, but they might be in the future and it shows all available functionalities
from socha import (
Accelerate,
AccelerationProblem,
Advance,
AdvanceInfo,
AdvanceProblem,
Board,
CartesianCoordinate,
CubeCoordinates,
CubeDirection,
Field,
FieldType,
GameState,
Move,
Passenger,
Push,
PushProblem,
Segment,
Ship,
TeamEnum,
TeamPoints,
Turn,
TurnProblem,
)
from socha.api.networking.game_client import IClientHandler
from socha.starter import Starter
import networkx as nx
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:
logging.info("Calculate move...")
possible_moves: List[Move] = self.game_state.possible_moves()
return possible_moves[random.randint(0, len(possible_moves) - 1)]
# 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):
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)