This repository has been archived by the owner on Jul 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmission_template.py
66 lines (42 loc) · 1.75 KB
/
submission_template.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
56
57
58
59
60
61
62
63
64
65
66
from submission_helper.bot_battle import BotBattle
from submission_helper.state import *
from submission_helper.enums import *
from typing import Optional
game_info: Optional[GameInfo] = None
bot_battle = BotBattle()
def get_next_alive_player():
next_alive = (game_info.player_id + 1) % 5
while game_info.players_cards_num[next_alive] == 0:
next_alive = (next_alive + 1) % 5
return next_alive
def move_controller(requested_move: RequestedMove):
if requested_move == RequestedMove.PrimaryAction:
primary_action_handler()
elif requested_move == RequestedMove.CounterAction:
counter_action_handler()
elif requested_move == RequestedMove.ChallengeAction:
challenge_action_handler()
elif requested_move == RequestedMove.ChallengeResponse:
challenge_response_handler()
elif requested_move == RequestedMove.DiscardChoice:
discard_choice_handler()
else:
return Exception(f'Unknown requested move: {requested_move}')
def primary_action_handler():
if game_info.balances[game_info.player_id] >= 7:
target_player_id = get_next_alive_player()
bot_battle.play_primary_action(PrimaryAction.Coup, target_player_id)
else:
bot_battle.play_primary_action(PrimaryAction.Income)
def counter_action_handler():
bot_battle.play_counter_action(CounterAction.NoCounterAction)
def challenge_action_handler():
bot_battle.play_challenge_action(ChallengeAction.NoChallenge)
def challenge_response_handler():
bot_battle.play_challenge_response(0)
def discard_choice_handler():
bot_battle.play_discard_choice(0)
if __name__ == "__main__":
while True:
game_info = bot_battle.get_game_info()
move_controller(game_info.requested_move)